def process_voltdbroot_args(runner): if (runner.opts.directory_spec) and (runner.opts.voltdbroot): utility.abort( 'Cannot specify both --dir and command line argument. Please use --dir option.' ) os.environ['PATH'] += os.pathsep + os.pathsep.join( s for s in sys.path if os.path.join('voltdb', 'bin') in s) # If database directory is given, derive voltdbroot path to store results of systemcheck in voltdbroot directory if runner.opts.directory_spec: if os.path.isdir(runner.opts.directory_spec) and os.access( runner.opts.directory_spec, os.R_OK | os.W_OK | os.X_OK): voltdbrootDir = os.path.join(runner.opts.directory_spec, 'voltdbroot') else: utility.abort('Specified database directory is not valid', runner.opts.directory_spec) elif runner.opts.voltdbroot: utility.warning( 'Specifying voltdbroot directory using command argument is deprecated. Consider using --dir ' 'option to specify database directory.') voltdbrootDir = runner.opts.voltdbroot else: voltdbrootDir = os.path.join(os.getcwd(), 'voltdbroot') runner.args.extend(['--voltdbroot=' + voltdbrootDir]) performSystemCheck(runner, voltdbrootDir)
def process_outputfile_args(runner): if runner.opts.output and runner.opts.prefix: utility.abort('Cannot specify both --output and --prefix. Please use --output option.') if runner.opts.output: runner.args.extend(['--outputFile=' + runner.opts.output]) elif runner.opts.prefix: utility.warning('Specifying prefix for outputfile name is deprecated. Consider using --output option to specify' ' output file name.') runner.args.extend(['--prefix=' + runner.opts.prefix])
def process_voltdbroot_args(runner) : if (runner.opts.directory_spec) and (runner.opts.voltdbroot): utility.abort('Cannot specify both --dir and command line argument. Please use --dir option.') os.environ['PATH'] += os.pathsep + os.pathsep.join(s for s in sys.path if os.path.join('voltdb', 'bin') in s) # If database directory is given, derive voltdbroot path to store results of systemcheck in voltdbroot directory if runner.opts.directory_spec: if os.path.isdir(runner.opts.directory_spec) and os.access(runner.opts.directory_spec, os.R_OK|os.W_OK|os.X_OK): voltdbrootDir = os.path.join(runner.opts.directory_spec, 'voltdbroot') else: utility.abort('Specified database directory is not valid', runner.opts.directory_spec) elif runner.opts.voltdbroot: utility.warning('Specifying voltdbroot directory using command argument is deprecated. Consider using --dir ' 'option to specify database directory.'); voltdbrootDir = runner.opts.voltdbroot else: voltdbrootDir = os.path.join(os.getcwd(), 'voltdbroot') runner.args.extend(['--voltdbroot=' + voltdbrootDir]) performSystemCheck(runner, voltdbrootDir)
def package(self, output_dir_in, force, *args): """ Create python-runnable package/zip file. """ if output_dir_in is None: output_dir = '' else: output_dir = output_dir_in if not os.path.exists(output_dir): os.makedirs(output_dir) if args: # Package other verbspaces. for name in args: if name not in self.internal_verbspaces: utility.abort( 'Unknown base command "%s" specified for packaging.' % name) verbspace = self.internal_verbspaces[name] self._create_package(output_dir, verbspace.name, verbspace.version, verbspace.description, force) else: # Package the active verbspace. self._create_package(output_dir, self.verbspace.name, self.verbspace.version, self.verbspace.description, force) # Warn for Python version < 2.6. compat_msg = compatibility_warning % dict(name=self.verbspace.name) if sys.version_info[0] == 2 and sys.version_info[1] < 6: utility.warning(compat_msg) # Generate README.<tool> file. readme_path = os.path.join(output_dir, 'README.%s' % self.verbspace.name) readme_file = utility.File(readme_path, mode='w') readme_file.open() try: readme_file.write(readme_template % dict(name=self.verbspace.name, usage=self.get_usage(), warning=compat_msg)) finally: readme_file.close()
def package(self, output_dir_in, force, *args): """ Create python-runnable package/zip file. """ if output_dir_in is None: output_dir = '' else: output_dir = output_dir_in if not os.path.exists(output_dir): os.makedirs(output_dir) if args: # Package other verbspaces. for name in args: if name not in self.internal_verbspaces: utility.abort('Unknown base command "%s" specified for packaging.' % name) verbspace = self.internal_verbspaces[name] self._create_package(output_dir, verbspace.name, verbspace.version, verbspace.description, force) else: # Package the active verbspace. self._create_package(output_dir, self.verbspace.name, self.verbspace.version, self.verbspace.description, force) # Warn for Python version < 2.6. compat_msg = ('''\ The program package requires Python version 2.6 or greater. It will crash with older Python versions that can't detect and run zip packages. If a newer Python is not the default you can run by passing the package file to an explicit python version, e.g. python2.6 %s''' % self.verbspace.name) if sys.version_info[0] == 2 and sys.version_info[1] < 6: utility.warning(compat_msg) # Generate README.<tool> file. readme_path = os.path.join(output_dir, 'README.%s' % self.verbspace.name) readme_file = utility.File(readme_path, mode = 'w') readme_file.open() try: readme_file.write('%s\n\nWARNING: %s\n' % (self.get_usage(), compat_msg)) finally: readme_file.close()
def package(self, output_dir_in, force, *args): """ Create python-runnable package/zip file. """ if output_dir_in is None: output_dir = '' else: output_dir = output_dir_in if not os.path.exists(output_dir): os.makedirs(output_dir) if args: # Package other verbspaces. for name in args: if name not in self.internal_verbspaces: utility.abort('Unknown base command "%s" specified for packaging.' % name) verbspace = self.internal_verbspaces[name] self._create_package(output_dir, verbspace.name, verbspace.version, verbspace.description, force) else: # Package the active verbspace. self._create_package(output_dir, self.verbspace.name, self.verbspace.version, self.verbspace.description, force) # Warn for Python version < 2.6. compat_msg = compatibility_warning % dict(name = self.verbspace.name) if sys.version_info[0] == 2 and sys.version_info[1] < 6: utility.warning(compat_msg) # Generate README.<tool> file. readme_path = os.path.join(output_dir, 'README.%s' % self.verbspace.name) readme_file = utility.File(readme_path, mode = 'w') readme_file.open() try: readme_file.write(readme_template % dict(name = self.verbspace.name, usage = self.get_usage(), warning = compat_msg)) finally: readme_file.close()
def find_log4j_config(self): if 'LOG4J_CONFIG_PATH' in os.environ: path = os.environ['LOG4J_CONFIG_PATH'] utility.debug('LOG4J_CONFIG_PATH=%s' % path) if not os.path.exists( path): # warn only, since this was not previously checked utility.warning( 'LOG4J_CONFIG_PATH refers to a nonexistent file: %s' % path) return path if not self.log4j_default: utility.abort('log4j_default not defined for verb') for fname in self.log4j_default: for dir in ('$VOLTDB_LIB/../src/frontend', '$VOLTDB_VOLTDB'): path = os.path.join(os.path.realpath(os.path.expandvars(dir)), fname) if os.path.exists(path): os.environ[ 'LOG4J_CONFIG_PATH'] = path # define this for back-compatibility utility.debug('LOG4J_CONFIG_PATH=%s' % path) return path utility.abort( 'Could not find log4j configuration file and LOG4J_CONFIG_PATH variable not set.' )
def warning(self, *msgs): """ Display WARNING level messages. """ utility.warning(*msgs)
def go(self, verb, runner): if self.check_environment_config: incompatible_options = checkconfig.test_hard_requirements() for k,v in incompatible_options.items(): state = v[0] if state == 'PASS' : pass elif state == "WARN": utility.warning(v[1]) elif state == 'FAIL' : if k in checkconfig.skippableRequirements.keys() and runner.opts.skip_requirements and checkconfig.skippableRequirements[k] in runner.opts.skip_requirements: utility.warning(v[1]) else: utility.abort(v[1]) else: utility.error(v[1]) final_args = None if self.subcommand in ('create', 'recover'): if runner.opts.replica: final_args = [self.subcommand, 'replica'] if self.supports_live: if runner.opts.block: final_args = [self.subcommand] else: final_args = ['live', self.subcommand] elif final_args == None: final_args = [self.subcommand] if self.safemode_available: if runner.opts.safemode: final_args.extend(['safemode']) if self.needs_catalog: catalog = runner.opts.catalog if not catalog: catalog = runner.config.get('volt.catalog') if not catalog is None: final_args.extend(['catalog', catalog]) if runner.opts.deployment: final_args.extend(['deployment', runner.opts.deployment]) if runner.opts.placementgroup: final_args.extend(['placementgroup', runner.opts.placementgroup]) if runner.opts.host: final_args.extend(['host', runner.opts.host]) else: utility.abort('host is required.') if runner.opts.clientport: final_args.extend(['port', runner.opts.clientport]) if runner.opts.adminport: final_args.extend(['adminport', runner.opts.adminport]) if runner.opts.httpport: final_args.extend(['httpport', runner.opts.httpport]) if runner.opts.license: final_args.extend(['license', runner.opts.license]) if runner.opts.internalinterface: final_args.extend(['internalinterface', runner.opts.internalinterface]) if runner.opts.internalport: final_args.extend(['internalport', runner.opts.internalport]) if runner.opts.replicationport: final_args.extend(['replicationport', runner.opts.replicationport]) if runner.opts.zkport: final_args.extend(['zkport', runner.opts.zkport]) if runner.opts.externalinterface: final_args.extend(['externalinterface', runner.opts.externalinterface]) if runner.opts.publicinterface: final_args.extend(['publicinterface', runner.opts.publicinterface]) if self.subcommand in ('create'): if runner.opts.new: final_args.extend(['new']) if runner.args: final_args.extend(runner.args) kwargs = {} if self.supports_daemon and runner.opts.daemon: # Provide a default description if not specified. daemon_description = self.daemon_description if daemon_description is None: daemon_description = "VoltDB server" # Initialize all the daemon-related keyword arguments. runner.setup_daemon_kwargs(kwargs, name=self.daemon_name, description=daemon_description, output=self.daemon_output) else: # Replace the Python process. kwargs['exec'] = True self.run_java(verb, runner, *final_args, **kwargs)
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) if runner.opts.save and communityVersion: utility.warning( "Snapshots not supported in the community edition. The --save option is being ignored." ) 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.') if not communityVersion: 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 (not communityVersion) and 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: 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
def go(self, verb, runner): if self.check_environment_config: incompatible_options = checkconfig.test_hard_requirements() for k,v in list(incompatible_options.items()): state = v[0] if state == 'PASS' : pass elif state == "WARN": utility.warning(v[1]) elif state == 'FAIL' : if k in list(checkconfig.skippableRequirements.keys()) and runner.opts.skip_requirements and checkconfig.skippableRequirements[k] in runner.opts.skip_requirements: utility.warning(v[1]) else: utility.abort(v[1]) else: utility.error(v[1]) final_args = [self.subcommand] if self.safemode_available and runner.opts.safemode: final_args.extend(['safemode']) if runner.opts.placementgroup: final_args.extend(['placementgroup', runner.opts.placementgroup]) if runner.opts.clientport: final_args.extend(['port', runner.opts.clientport]) if runner.opts.adminport: final_args.extend(['adminport', runner.opts.adminport]) if runner.opts.httpport: final_args.extend(['httpport', runner.opts.httpport]) if runner.opts.statusport: final_args.extend(['statusport', runner.opts.statusport]) if runner.opts.license: final_args.extend(['license', runner.opts.license]) if runner.opts.internalinterface: final_args.extend(['internalinterface', runner.opts.internalinterface]) if runner.opts.internalport: final_args.extend(['internalport', runner.opts.internalport]) if runner.opts.replicationport: final_args.extend(['replicationport', runner.opts.replicationport]) if runner.opts.zkport: final_args.extend(['zkport', runner.opts.zkport]) if runner.opts.externalinterface: final_args.extend(['externalinterface', runner.opts.externalinterface]) if runner.opts.publicinterface: final_args.extend(['publicinterface', runner.opts.publicinterface]) if runner.opts.drpublic: final_args.extend(['drpublic', runner.opts.drpublic]) if runner.opts.topicsport: final_args.extend(('topicsHostPort', runner.opts.topicsport)) if runner.opts.topicspublic: final_args.extend(('topicspublic', runner.opts.topicspublic)) if self.supports_paused and runner.opts.paused: final_args.extend(['paused']) if runner.args: final_args.extend(runner.args) kwargs = {} if self.supports_daemon and runner.opts.daemon: # Provide a default description if not specified. daemon_description = self.daemon_description if daemon_description is None: daemon_description = "VoltDB server" # Initialize all the daemon-related keyword arguments. runner.setup_daemon_kwargs(kwargs, name=self.daemon_name, description=daemon_description, output=self.daemon_output) else: # Replace the Python process. kwargs['exec'] = True self.run_java(verb, runner, *final_args, **kwargs)
def go(self, verb, runner): if self.check_environment_config: incompatible_options = checkconfig.test_hard_requirements() for k, v in incompatible_options.items(): state = v[0] if state == 'PASS': pass elif state == "WARN": utility.warning(v[1]) elif state == 'FAIL': if k in checkconfig.skippableRequirements.keys( ) and runner.opts.skip_requirements and checkconfig.skippableRequirements[ k] in runner.opts.skip_requirements: utility.warning(v[1]) else: utility.abort(v[1]) else: utility.error(v[1]) final_args = None if self.subcommand in ('create', 'recover', 'probe'): if runner.opts.replica: final_args = [self.subcommand, 'replica'] if self.supports_live: if runner.opts.block: final_args = [self.subcommand] else: final_args = ['live', self.subcommand] elif final_args == None: final_args = [self.subcommand] if self.safemode_available: if runner.opts.safemode: final_args.extend(['safemode']) if self.needs_catalog: catalog = runner.opts.catalog if not catalog: catalog = runner.config.get('volt.catalog') if not catalog is None: final_args.extend(['catalog', catalog]) if self.is_legacy_verb and runner.opts.deployment: final_args.extend(['deployment', runner.opts.deployment]) if runner.opts.placementgroup: final_args.extend(['placementgroup', runner.opts.placementgroup]) if self.is_legacy_verb and runner.opts.host: final_args.extend(['host', runner.opts.host]) elif not self.subcommand in ('initialize', 'probe'): utility.abort('host is required.') if runner.opts.clientport: final_args.extend(['port', runner.opts.clientport]) if runner.opts.adminport: final_args.extend(['adminport', runner.opts.adminport]) if runner.opts.httpport: final_args.extend(['httpport', runner.opts.httpport]) if runner.opts.statusport: final_args.extend(['statusport', runner.opts.statusport]) if runner.opts.license: final_args.extend(['license', runner.opts.license]) if runner.opts.internalinterface: final_args.extend( ['internalinterface', runner.opts.internalinterface]) if runner.opts.internalport: final_args.extend(['internalport', runner.opts.internalport]) if runner.opts.replicationport: final_args.extend(['replicationport', runner.opts.replicationport]) if runner.opts.zkport: final_args.extend(['zkport', runner.opts.zkport]) if runner.opts.externalinterface: final_args.extend( ['externalinterface', runner.opts.externalinterface]) if runner.opts.publicinterface: final_args.extend(['publicinterface', runner.opts.publicinterface]) if runner.opts.drpublic: final_args.extend(['drpublic', runner.opts.drpublic]) if runner.opts.topicsport: final_args.extend(('topicsHostPort', runner.opts.topicsport)) if self.subcommand in ('create', 'initialize'): if runner.opts.force: final_args.extend(['force']) if self.subcommand in ('create', 'probe', 'recover'): if runner.opts.paused: final_args.extend(['paused']) if runner.args: final_args.extend(runner.args) kwargs = {} if self.supports_daemon and runner.opts.daemon: # Provide a default description if not specified. daemon_description = self.daemon_description if daemon_description is None: daemon_description = "VoltDB server" # Initialize all the daemon-related keyword arguments. runner.setup_daemon_kwargs(kwargs, name=self.daemon_name, description=daemon_description, output=self.daemon_output) else: # Replace the Python process. kwargs['exec'] = True self.run_java(verb, runner, *final_args, **kwargs)
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) if runner.opts.save and communityVersion: utility.warning("Snapshots not supported in the community edition. The --save option is being ignored.") 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.') if not communityVersion: 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 (not communityVersion) and 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: 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
def go(self, verb, runner): if self.check_environment_config: incompatible_options = checkconfig.test_hard_requirements() for k, v in incompatible_options.items(): state = v[0] if state == "PASS": pass elif state == "WARN": utility.warning(v[1]) elif state == "FAIL": if ( k in checkconfig.skippableRequirements.keys() and runner.opts.skip_requirements and checkconfig.skippableRequirements[k] in runner.opts.skip_requirements ): utility.warning(v[1]) else: utility.abort(v[1]) else: utility.error(v[1]) final_args = None if self.subcommand in ("create", "recover"): if runner.opts.replica: final_args = [self.subcommand, "replica"] if self.supports_live: if runner.opts.block: final_args = [self.subcommand] else: final_args = ["live", self.subcommand] elif final_args == None: final_args = [self.subcommand] if self.safemode_available: if runner.opts.safemode: final_args.extend(["safemode"]) if self.needs_catalog: catalog = runner.opts.catalog if not catalog: catalog = runner.config.get("volt.catalog") if not catalog is None: final_args.extend(["catalog", catalog]) if runner.opts.deployment: final_args.extend(["deployment", runner.opts.deployment]) if runner.opts.placementgroup: final_args.extend(["placementgroup", runner.opts.placementgroup]) if runner.opts.host: final_args.extend(["host", runner.opts.host]) else: utility.abort("host is required.") if runner.opts.clientport: final_args.extend(["port", runner.opts.clientport]) if runner.opts.adminport: final_args.extend(["adminport", runner.opts.adminport]) if runner.opts.httpport: final_args.extend(["httpport", runner.opts.httpport]) if runner.opts.license: final_args.extend(["license", runner.opts.license]) if runner.opts.internalinterface: final_args.extend(["internalinterface", runner.opts.internalinterface]) if runner.opts.internalport: final_args.extend(["internalport", runner.opts.internalport]) if runner.opts.replicationport: final_args.extend(["replicationport", runner.opts.replicationport]) if runner.opts.zkport: final_args.extend(["zkport", runner.opts.zkport]) if runner.opts.externalinterface: final_args.extend(["externalinterface", runner.opts.externalinterface]) if runner.opts.publicinterface: final_args.extend(["publicinterface", runner.opts.publicinterface]) if runner.args: final_args.extend(runner.args) kwargs = {} if self.supports_daemon and runner.opts.daemon: # Provide a default description if not specified. daemon_description = self.daemon_description if daemon_description is None: daemon_description = "VoltDB server" # Initialize all the daemon-related keyword arguments. runner.setup_daemon_kwargs( kwargs, name=self.daemon_name, description=daemon_description, output=self.daemon_output ) else: # Replace the Python process. kwargs["exec"] = True self.run_java(verb, runner, *final_args, **kwargs)