Beispiel #1
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
Beispiel #2
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)
            runner.info('Completing outstanding export and DR transactions...')
            checkstats.check_export_dr(runner)
            runner.info('Completing outstanding client transactions.')
            checkstats.check_clients(runner)
            runner.info('Completing outstanding importer requests.')
            checkstats.check_importer(runner)
            runner.info('Cluster is ready for shutdown')
            if runner.opts.save:
                columns = [VOLT.FastSerializer.VOLTTYPE_BIGINT]
                shutdown_params = [zk_pause_txnid]
        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
Beispiel #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.")
    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
Beispiel #4
0
def shutdown(runner):
    runner.info('Cluster shutdown in progress.')
    if runner.opts.forcing == False:
        try:
            runner.info('Preparing for shutdown')
            status = runner.call_proc('@PrepareShutdown', [],
                                      []).table(0).tuple(0).column_integer(0)
            if status <> 0:
                runner.error(
                    'The preparation for shutdown failed with status: %d' %
                    status)
                return
            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.error(
                    'The cluster has failed to be quiesce with status: %d' %
                    status)
                return
            runner.info('Completing outstanding export and DR transactions...')
            checkstats.check_export_dr(runner)
            runner.info('Completing outstanding client transactions.')
            checkstats.check_clients(runner)
            runner.info('Completing outstanding importer requests.')
            checkstats.check_importer(runner)
            runner.info('Cluster is ready for shutdown')
        except (KeyboardInterrupt, SystemExit):
            runner.info(
                'The cluster shutdown process has stopped. The cluster is still in a paused state.'
            )
            runner.info(
                'You may shutdown the cluster with the "voltadmin shutdown --force" command, or continue to wait with "voltadmin shutdown".'
            )
            return
    response = runner.call_proc('@Shutdown', [], [], check_status=False)
    print response
Beispiel #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.')
    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