Example #1
0
def pause(runner):
    #Check the STATUS column. runner.call_proc() detects and aborts on errors.
    status = runner.call_proc('@Pause', [],
                              []).table(0).tuple(0).column_integer(0)
    if status <> 0:
        runner.error('The cluster has failed to pause with status: %d' %
                     status)
        return
    runner.info('The cluster is paused.')
    if runner.opts.waiting:
        status = runner.call_proc('@Quiesce', [],
                                  []).table(0).tuple(0).column_integer(0)
        if status <> 0:
            runner.error('The cluster has failed to quiesce with status: %d' %
                         status)
            return
        runner.info('The cluster is quiesced.')
        try:
            checkstats.check_exporter(runner)
            checkstats.check_dr_producer(runner)
        except (KeyboardInterrupt, SystemExit):
            runner.info(
                'The pause process has stopped. The cluster is in a paused state.'
            )
            runner.abort(
                'Transactions may not be completely drained. You may continue monitoring the outstanding transactions with @Statistics'
            )
Example #2
0
def pause(runner):
    if runner.opts.timeout <= 0:
        runner.abort_with_help('The timeout value must be more than zero seconds.')

    #Check the STATUS column. runner.call_proc() detects and aborts on errors.
    status = runner.call_proc('@Pause', [], []).table(0).tuple(0).column_integer(0)
    if status <> 0:
        runner.abort('The cluster has failed to pause with status: %d' % status)
    runner.info('The cluster is paused.')
    if runner.opts.waiting:
        status = runner.call_proc('@Quiesce', [], []).table(0).tuple(0).column_integer(0)
        if status <> 0:
            runner.abort('The cluster has failed to quiesce with status: %d' % status)
        runner.info('The cluster is quiesced.')
        actionMessage = 'Transactions may not be completely drained. You may continue monitoring the outstanding transactions with @Statistics'
        try:
            checkstats.check_exporter(runner)
            checkstats.check_dr_producer(runner)
        except StatisticsProcedureException as proex:
            runner.info('The previous command has timed out and stopped waiting... The cluster is in a paused state.')
            runner.error(proex.message)
            if proex.isTimeout:
                runner.info(actionMessage)
            sys.exit(proex.exitCode)
        except (KeyboardInterrupt, SystemExit):
            runner.info('The previous command has stopped waiting... The cluster is in a paused state.')
            runner.abort(actionMessage)
Example #3
0
def shutdown(runner):
    if runner.opts.forcing and runner.opts.save:
       runner.abort_with_help('You cannot specify both --force and --save options.')
    if runner.opts.timeout <= 0:
        runner.abort_with_help('The timeout value must be more than zero seconds.')
    shutdown_params = []
    columns = []
    zk_pause_txnid = 0

    communityVersion = isCommunityVersion(runner)

    runner.info('Cluster shutdown in progress.')
    if not runner.opts.forcing:
        stateMessage = 'The cluster shutdown process has stopped. The cluster is still in a paused state.'
        actionMessage = 'You may shutdown the cluster with the "voltadmin shutdown --force" command, or continue to wait with "voltadmin shutdown".'
        try:
            runner.info('Preparing for shutdown...')
            resp = runner.call_proc('@PrepareShutdown', [], [])
            if resp.status() != 1:
                runner.abort('The preparation for shutdown failed with status: %d' % resp.response.statusString)
            zk_pause_txnid = resp.table(0).tuple(0).column_integer(0)
            runner.info('The cluster is paused prior to shutdown.')

            runner.info('Writing out all queued export data...')
            status = runner.call_proc('@Quiesce', [], []).table(0).tuple(0).column_integer(0)
            if status <> 0:
                runner.abort('The cluster has failed to be quiesce with status: %d' % status)

            checkstats.check_clients(runner)
            checkstats.check_importer(runner)

            if not communityVersion:
                checkstats.check_command_log(runner)
                runner.info('All transactions have been made durable.')

            if runner.opts.save:
               actionMessage = 'You may shutdown the cluster with the "voltadmin shutdown --force" command, or continue to wait with "voltadmin shutdown --save".'
               columns = [VOLT.FastSerializer.VOLTTYPE_BIGINT]
               shutdown_params =  [zk_pause_txnid]
               #save option, check more stats
               checkstats.check_dr_consumer(runner)
               runner.info('Starting resolution of external commitments...')
               checkstats.check_exporter(runner)
               checkstats.check_dr_producer(runner)
               runner.info('Saving a final snapshot, The cluster will shutdown after the snapshot is finished...')
            else:
                checkstats.check_exporter(runner)
                runner.info('Shutting down the cluster...')
        except StatisticsProcedureException as proex:
             runner.info(stateMessage)
             runner.error(proex.message)
             if proex.isTimeout:
                 runner.info(actionMessage)
             sys.exit(proex.exitCode)
        except (KeyboardInterrupt, SystemExit):
            runner.info(stateMessage)
            runner.abort(actionMessage)
    response = runner.call_proc('@Shutdown', columns, shutdown_params, check_status = False)
    print response
Example #4
0
def pause(runner):
    if runner.opts.timeout <= 0:
        runner.abort_with_help(
            'The timeout value must be more than zero seconds.')

    #Check the STATUS column. runner.call_proc() detects and aborts on errors.
    status = runner.call_proc('@Pause', [],
                              []).table(0).tuple(0).column_integer(0)
    if status != 0:
        runner.abort('The cluster has failed to pause with status: %d' %
                     status)
    runner.info('The cluster is paused.')
    if runner.opts.waiting:
        status = runner.call_proc('@Quiesce', [],
                                  []).table(0).tuple(0).column_integer(0)
        if status != 0:
            runner.abort('The cluster has failed to quiesce with status: %d' %
                         status)
        runner.info('The cluster is quiesced.')
        actionMessage = 'Transactions may not be completely drained. You may continue monitoring the outstanding transactions with @Statistics'
        try:
            checkstats.check_exporter(runner)
            status = runner.call_proc('@Quiesce', [],
                                      []).table(0).tuple(0).column_integer(0)
            if status != 0:
                runner.abort(
                    'The cluster has failed to quiesce with status: %d' %
                    status)
            checkstats.check_dr_producer(runner)
        except StatisticsProcedureException as proex:
            runner.info(
                'The previous command has timed out and stopped waiting... The cluster is in a paused state.'
            )
            runner.error(proex.message)
            if proex.isTimeout:
                runner.info(actionMessage)
            sys.exit(proex.exitCode)
        except (KeyboardInterrupt, SystemExit):
            runner.info(
                'The previous command has stopped waiting... The cluster is in a paused state.'
            )
            runner.abort(actionMessage)
Example #5
0
def shutdown(runner):
    if runner.opts.forcing and runner.opts.save:
        runner.abort_with_help("You cannot specify both --force and --save options.")
    shutdown_params = []
    columns = []
    zk_pause_txnid = 0
    runner.info("Cluster shutdown in progress.")
    if not runner.opts.forcing:
        try:
            runner.info("Preparing for shutdown...")
            resp = runner.call_proc("@PrepareShutdown", [], [])
            if resp.status() != 1:
                runner.abort("The preparation for shutdown failed with status: %d" % resp.response.statusString)
            zk_pause_txnid = resp.table(0).tuple(0).column_integer(0)
            runner.info("The cluster is paused prior to shutdown.")
            runner.info("Writing out all queued export data...")
            status = runner.call_proc("@Quiesce", [], []).table(0).tuple(0).column_integer(0)
            if status <> 0:
                runner.abort("The cluster has failed to be quiesce with status: %d" % status)
            checkstats.check_clients(runner)
            checkstats.check_importer(runner)
            checkstats.check_command_log(runner)
            runner.info("All transactions have been made durable.")
            if runner.opts.save:
                columns = [VOLT.FastSerializer.VOLTTYPE_BIGINT]
                shutdown_params = [zk_pause_txnid]
                # save option, check more stats
                checkstats.check_dr_consumer(runner)
                runner.info("Starting resolution of external commitments...")
                checkstats.check_exporter(runner)
                checkstats.check_dr_producer(runner)
                runner.info("Saving a final snapshot, The cluster will shutdown after the snapshot is finished...")
            else:
                runner.info("Shutting down the cluster...")
        except (KeyboardInterrupt, SystemExit):
            runner.info("The cluster shutdown process has stopped. The cluster is still in a paused state.")
            runner.abort(
                'You may shutdown the cluster with the "voltadmin shutdown --force" command, or continue to wait with "voltadmin shutdown".'
            )
    response = runner.call_proc("@Shutdown", columns, shutdown_params, check_status=False)
    print response
Example #6
0
def pause(runner):
    # Check the STATUS column. runner.call_proc() detects and aborts on errors.
    status = runner.call_proc("@Pause", [], []).table(0).tuple(0).column_integer(0)
    if status <> 0:
        runner.error("The cluster has failed to pause with status: %d" % status)
        return
    runner.info("The cluster is paused.")
    if runner.opts.waiting:
        status = runner.call_proc("@Quiesce", [], []).table(0).tuple(0).column_integer(0)
        if status <> 0:
            runner.error("The cluster has failed to quiesce with status: %d" % status)
            return
        runner.info("The cluster is quiesced.")
        try:
            checkstats.check_exporter(runner)
            checkstats.check_dr_producer(runner)
        except (KeyboardInterrupt, SystemExit):
            runner.info("The pause process has stopped. The cluster is in a paused state.")
            runner.abort(
                "Transactions may not be completely drained. You may continue monitoring the outstanding transactions with @Statistics"
            )
Example #7
0
def shutdown(runner):
    if runner.opts.forcing and runner.opts.save:
        runner.abort_with_help(
            'You cannot specify both --force and --save options.')
    if runner.opts.cancel and runner.opts.save:
        runner.abort_with_help(
            'You cannot specify both --cancel and --save options.')
    if runner.opts.cancel and runner.opts.forcing:
        runner.abort_with_help(
            'You cannot specify both --cancel and --force options.')
    if runner.opts.timeout <= 0:
        runner.abort_with_help(
            'The timeout value must be more than zero seconds.')
    shutdown_params = []
    columns = []
    zk_pause_txnid = 0

    if runner.opts.cancel:
        runner.info('Canceling cluster shutdown ...')
        response = runner.call_proc('@CancelShutdown', [], [])
        if response.status() != 1:
            runner.abort('Cancel shutdown failed with status: %d' %
                         resp.response.statusString)
        else:
            runner.info('Shutdown canceled.')
    else:
        runner.info('Cluster shutdown in progress.')
        if not runner.opts.forcing:
            response = runner.call_proc('@SystemInformation',
                                        [VOLT.FastSerializer.VOLTTYPE_STRING],
                                        ['OVERVIEW'])

            # Convert @SystemInformation results to objects.
            hosts = Hosts(runner.abort)
            for tuple in response.table(0).tuples():
                hosts.update(*tuple)
            host = hosts.hosts_by_id.itervalues().next()
            if host.get('clustersafety') == "REDUCED":
                runner.info(
                    'Since cluster is in reduced k safety mode, taking a final snapshot before shutdown.'
                )
                runner.opts.save = True

            stateMessage = 'The cluster shutdown process has stopped. The cluster is still in a paused state.'
            actionMessage = 'You may shutdown the cluster with the "voltadmin shutdown --force" command, '\
                            + 'continue to wait with "voltadmin shutdown",\n'\
                            + 'or cancel the shutdown with the "voltadmin shutdown --cancel" command'
            try:
                runner.info('Preparing for shutdown...')
                resp = runner.call_proc('@PrepareShutdown', [], [])
                if resp.status() != 1:
                    runner.abort(
                        'The preparation for shutdown failed with status: %d' %
                        resp.response.statusString)
                zk_pause_txnid = resp.table(0).tuple(0).column_integer(0)
                runner.info('The cluster is paused prior to shutdown.')

                runner.info('Writing out all queued export data...')
                status = runner.call_proc(
                    '@Quiesce', [], []).table(0).tuple(0).column_integer(0)
                if status <> 0:
                    runner.abort(
                        'The cluster has failed to be quiesce with status: %d'
                        % status)

                checkstats.check_clients(runner)
                checkstats.check_importer(runner)

                # Checking command log regardless of whether we're community or enterprise
                checkstats.check_command_log(runner)
                runner.info(
                    'If running Enterprise Edition, all transactions have been made durable.'
                )

                if runner.opts.save:
                    actionMessage = 'You may shutdown the cluster with the "voltadmin shutdown --force" command, '\
                             + 'continue to wait with "voltadmin shutdown --save",\n'\
                             + 'or cancel the shutdown with the "voltadmin shutdown --cancel" command.'
                    columns = [VOLT.FastSerializer.VOLTTYPE_BIGINT]
                    shutdown_params = [zk_pause_txnid]
                    # save option, check more stats
                    checkstats.check_dr_consumer(runner)
                    runner.info(
                        'Starting resolution of external commitments...')
                    checkstats.check_exporter(runner)
                    status = runner.call_proc(
                        '@Quiesce', [], []).table(0).tuple(0).column_integer(0)
                    if status <> 0:
                        runner.abort(
                            'The cluster has failed to quiesce with status: %d'
                            % status)
                    checkstats.check_dr_producer(runner)
                    runner.info(
                        'Saving a final snapshot, The cluster will shutdown after the snapshot is finished...'
                    )
                else:
                    checkstats.check_exporter(runner)
                    runner.info('Shutting down the cluster...')
            except StatisticsProcedureException as proex:
                runner.info(stateMessage)
                runner.error(proex.message)
                if proex.isTimeout:
                    runner.info(actionMessage)
                sys.exit(proex.exitCode)
            except (KeyboardInterrupt, SystemExit):
                runner.info(stateMessage)
                runner.abort(actionMessage)
        response = runner.call_proc('@Shutdown',
                                    columns,
                                    shutdown_params,
                                    check_status=False)
        print response