本文整理汇总了Python中ccmlib.cluster.Cluster.set_configuration_options方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.set_configuration_options方法的具体用法?Python Cluster.set_configuration_options怎么用?Python Cluster.set_configuration_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ccmlib.cluster.Cluster
的用法示例。
在下文中一共展示了Cluster.set_configuration_options方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def run(self):
try:
cluster = Cluster(self.path, self.name, cassandra_dir=self.options.cassandra_dir, cassandra_version=self.options.cassandra_version, verbose=True)
except OSError as e:
cluster_dir = os.path.join(self.path, self.name)
print >> sys.stderr, 'Cannot create cluster: %s' % str(e)
exit(1)
if self.options.partitioner:
cluster.set_partitioner(self.options.partitioner)
if cluster.version() >= "1.2" and self.options.binary_protocol:
cluster.set_configuration_options({ 'start_native_transport' : True })
if not self.options.no_switch:
common.switch_cluster(self.path, self.name)
print 'Current cluster is now: %s' % self.name
if self.nodes is not None:
try:
cluster.set_log_level("DEBUG")
cluster.populate(self.nodes)
if self.options.start_nodes:
cluster.start(verbose=self.options.debug)
except common.ArgumentError as e:
print >> sys.stderr, str(e)
exit(1)
示例2: clear_and_use_multidc
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def clear_and_use_multidc(dc_list):
teardown_package()
try:
try:
cluster = CCMCluster.load(path, MULTIDC_CLUSTER_NAME)
log.debug("Found existing ccm test multi-dc cluster, clearing")
cluster.clear()
except Exception:
log.debug("Creating new ccm test multi-dc cluster")
if CASSANDRA_DIR:
cluster = CCMCluster(path, MULTIDC_CLUSTER_NAME, cassandra_dir=CASSANDRA_DIR)
else:
cluster = CCMCluster(path, MULTIDC_CLUSTER_NAME, cassandra_version=CASSANDRA_VERSION)
cluster.set_configuration_options({'start_native_transport': True})
common.switch_cluster(path, MULTIDC_CLUSTER_NAME)
cluster.populate(dc_list)
log.debug("Starting ccm test cluster")
cluster.start(wait_for_binary_proto=True, wait_other_notice=True)
except Exception:
log.exception("Failed to start ccm cluster:")
raise
global CCM_CLUSTER
CCM_CLUSTER = cluster
setup_test_keyspace()
log.debug("Switched to multidc cluster")
示例3: use_cluster
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def use_cluster(cluster_name, nodes, ipformat=None, start=True):
if is_current_cluster(cluster_name, nodes):
log.debug("Using existing cluster %s", cluster_name)
return
global CCM_CLUSTER
if CCM_CLUSTER:
log.debug("Stopping cluster %s", CCM_CLUSTER.name)
CCM_CLUSTER.stop()
try:
try:
cluster = CCMClusterFactory.load(path, cluster_name)
log.debug("Found existing ccm %s cluster; clearing", cluster_name)
cluster.clear()
cluster.set_install_dir(**CCM_KWARGS)
except Exception:
log.debug("Creating new ccm %s cluster with %s", cluster_name, CCM_KWARGS)
cluster = CCMCluster(path, cluster_name, **CCM_KWARGS)
cluster.set_configuration_options({'start_native_transport': True})
common.switch_cluster(path, cluster_name)
cluster.populate(nodes, ipformat=ipformat)
if start:
log.debug("Starting ccm %s cluster", cluster_name)
cluster.start(wait_for_binary_proto=True, wait_other_notice=True)
setup_test_keyspace()
CCM_CLUSTER = cluster
except Exception:
log.exception("Failed to start ccm cluster:")
raise
示例4: setup_module
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def setup_module(cls):
validate_ccm_viable()
validate_host_viable()
cls.ccm_cluster = object()
teardown_package()
try:
try:
ccm_cluster = CCMCluster.load(path, IPV6_CLUSTER_NAME)
log.debug("Found existing ccm test ipv6 cluster, clearing")
ccm_cluster.clear()
except Exception:
log.debug("Creating new ccm test ipv6 cluster")
if CASSANDRA_DIR:
ccm_cluster = CCMCluster(path, IPV6_CLUSTER_NAME, cassandra_dir=CASSANDRA_DIR)
else:
ccm_cluster = CCMCluster(path, IPV6_CLUSTER_NAME, cassandra_version=CASSANDRA_VERSION)
ccm_cluster.set_configuration_options({'start_native_transport': True})
common.switch_cluster(path, IPV6_CLUSTER_NAME)
ccm_cluster.populate(1, ipformat='::%d')
log.debug("Starting ccm test cluster")
ccm_cluster.start(wait_for_binary_proto=True)
except Exception:
log.exception("Failed to start ccm cluster:")
raise
log.debug("Switched to ipv6 cluster")
cls.ccm_cluster = ccm_cluster
示例5: run
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def run(self):
try:
cluster = Cluster(self.path, self.name, cassandra_dir=self.options.cassandra_dir, cassandra_version=self.options.cassandra_version, verbose=True)
except OSError as e:
cluster_dir = os.path.join(self.path, self.name)
import traceback
print >> sys.stderr, 'Cannot create cluster: %s\n%s' % (str(e), traceback.format_exc())
exit(1)
if self.options.partitioner:
cluster.set_partitioner(self.options.partitioner)
if cluster.version() >= "1.2" and self.options.binary_protocol:
cluster.set_configuration_options({ 'start_native_transport' : True })
if cluster.version() >= "1.2" and self.options.vnodes:
cluster.set_configuration_options({ 'num_tokens' : 256 })
if not self.options.no_switch:
common.switch_cluster(self.path, self.name)
print 'Current cluster is now: %s' % self.name
if self.nodes is not None:
try:
if self.options.debug_log:
cluster.set_log_level("DEBUG")
if self.options.trace_log:
cluster.set_log_level("TRACE")
cluster.populate(self.nodes, use_vnodes=self.options.vnodes, ipprefix=self.options.ipprefix)
if self.options.start_nodes:
cluster.start(verbose=self.options.debug, wait_for_binary_proto=self.options.binary_protocol)
except common.ArgumentError as e:
print >> sys.stderr, str(e)
exit(1)
示例6: setup_package
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def setup_package():
print_('Using Cassandra version: %s' % CASSANDRA_VERSION)
try:
try:
cluster = CCMCluster.load(path, CLUSTER_NAME)
log.debug("Found existing ccm test cluster, clearing")
cluster.clear()
if CASSANDRA_DIR:
cluster.set_cassandra_dir(cassandra_dir=CASSANDRA_DIR)
else:
cluster.set_cassandra_dir(cassandra_version=CASSANDRA_VERSION)
except Exception:
if CASSANDRA_DIR:
log.debug("Creating new ccm test cluster with cassandra dir %s", CASSANDRA_DIR)
cluster = CCMCluster(path, CLUSTER_NAME, cassandra_dir=CASSANDRA_DIR)
else:
log.debug("Creating new ccm test cluster with version %s", CASSANDRA_VERSION)
cluster = CCMCluster(path, CLUSTER_NAME, cassandra_version=CASSANDRA_VERSION)
cluster.set_configuration_options({'start_native_transport': True})
common.switch_cluster(path, CLUSTER_NAME)
cluster.populate(3)
log.debug("Starting ccm test cluster")
cluster.start(wait_for_binary_proto=True, wait_other_notice=True)
except Exception:
log.exception("Failed to start ccm cluster:")
raise
global CCM_CLUSTER
CCM_CLUSTER = cluster
setup_test_keyspace()
示例7: use_cluster
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def use_cluster(cluster_name, nodes, ipformat=None, start=True):
global CCM_CLUSTER
if USE_CASS_EXTERNAL:
if CCM_CLUSTER:
log.debug("Using external CCM cluster {0}".format(CCM_CLUSTER.name))
else:
log.debug("Using unnamed external cluster")
return
if is_current_cluster(cluster_name, nodes):
log.debug("Using existing cluster, matching topology: {0}".format(cluster_name))
else:
if CCM_CLUSTER:
log.debug("Stopping existing cluster, topology mismatch: {0}".format(CCM_CLUSTER.name))
CCM_CLUSTER.stop()
try:
CCM_CLUSTER = CCMClusterFactory.load(path, cluster_name)
log.debug("Found existing CCM cluster, {0}; clearing.".format(cluster_name))
CCM_CLUSTER.clear()
CCM_CLUSTER.set_install_dir(**CCM_KWARGS)
except Exception:
ex_type, ex, tb = sys.exc_info()
log.warn("{0}: {1} Backtrace: {2}".format(ex_type.__name__, ex, traceback.extract_tb(tb)))
del tb
log.debug("Creating new CCM cluster, {0}, with args {1}".format(cluster_name, CCM_KWARGS))
CCM_CLUSTER = CCMCluster(path, cluster_name, **CCM_KWARGS)
CCM_CLUSTER.set_configuration_options({'start_native_transport': True})
if CASSANDRA_VERSION >= '2.2':
CCM_CLUSTER.set_configuration_options({'enable_user_defined_functions': True})
common.switch_cluster(path, cluster_name)
CCM_CLUSTER.populate(nodes, ipformat=ipformat)
try:
jvm_args = []
# This will enable the Mirroring query handler which will echo our custom payload k,v pairs back
if PROTOCOL_VERSION >= 4:
jvm_args = [" -Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler"]
if start:
log.debug("Starting CCM cluster: {0}".format(cluster_name))
CCM_CLUSTER.start(wait_for_binary_proto=True, wait_other_notice=True, jvm_args=jvm_args)
setup_keyspace(ipformat=ipformat)
except Exception:
log.exception("Failed to start CCM cluster; removing cluster.")
if os.name == "nt":
if CCM_CLUSTER:
for node in CCM_CLUSTER.nodes.itervalues():
os.system("taskkill /F /PID " + str(node.pid))
else:
call(["pkill", "-9", "-f", ".ccm"])
remove_cluster()
raise
示例8: __get_cluster
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def __get_cluster(self, name='test'):
self.test_path = tempfile.mkdtemp(prefix='dtest-')
try:
version = os.environ['CASSANDRA_VERSION']
cluster = Cluster(self.test_path, name, cassandra_version=version)
except KeyError:
try:
cdir = os.environ['CASSANDRA_DIR']
except KeyError:
cdir = DEFAULT_DIR
cluster = Cluster(self.test_path, name, cassandra_dir=cdir)
if ENABLE_VNODES:
cluster.set_configuration_options(values={'initial_token': None, 'num_tokens': 256})
return cluster
示例9: run
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def run(self):
try:
cluster = Cluster(self.path, self.name, cassandra_dir=self.options.cassandra_dir, cassandra_version=self.options.cassandra_version, verbose=True)
except OSError as e:
cluster_dir = os.path.join(self.path, self.name)
import traceback
print_('Cannot create cluster: %s\n%s' % (str(e), traceback.format_exc()), file=sys.stderr)
exit(1)
if self.options.partitioner:
cluster.set_partitioner(self.options.partitioner)
if cluster.version() >= "1.2.5":
self.options.binary_protocol = True
if self.options.binary_protocol:
cluster.set_configuration_options({ 'start_native_transport' : True })
if cluster.version() >= "1.2" and self.options.vnodes:
cluster.set_configuration_options({ 'num_tokens' : 256 })
if not self.options.no_switch:
common.switch_cluster(self.path, self.name)
print_('Current cluster is now: %s' % self.name)
if not (self.options.ipprefix or self.options.ipformat):
self.options.ipformat = '127.0.0.%d'
if self.nodes is not None:
try:
if self.options.debug_log:
cluster.set_log_level("DEBUG")
if self.options.trace_log:
cluster.set_log_level("TRACE")
cluster.populate(self.nodes, use_vnodes=self.options.vnodes, ipprefix=self.options.ipprefix, ipformat=self.options.ipformat)
if self.options.start_nodes:
profile_options = None
if self.options.profile:
profile_options = {}
if self.options.profile_options:
profile_options['options'] = self.options.profile_options
if cluster.start(verbose=self.options.debug, wait_for_binary_proto=self.options.binary_protocol, jvm_args=self.options.jvm_args, profile_options=profile_options) is None:
details = ""
if not self.options.debug:
details = " (you can use --debug for more information)"
print_("Error starting nodes, see above for details%s" % details, file=sys.stderr)
except common.ArgumentError as e:
print_(str(e), file=sys.stderr)
exit(1)
示例10: use_cluster
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def use_cluster(cluster_name, nodes, ipformat=None, start=True):
global CCM_CLUSTER
if USE_CASS_EXTERNAL:
if CCM_CLUSTER:
log.debug("Using external ccm cluster %s", CCM_CLUSTER.name)
else:
log.debug("Using unnamed external cluster")
return
if is_current_cluster(cluster_name, nodes):
log.debug("Using existing cluster %s", cluster_name)
return
if CCM_CLUSTER:
log.debug("Stopping cluster %s", CCM_CLUSTER.name)
CCM_CLUSTER.stop()
try:
try:
cluster = CCMClusterFactory.load(path, cluster_name)
log.debug("Found existing ccm %s cluster; clearing", cluster_name)
cluster.clear()
cluster.set_install_dir(**CCM_KWARGS)
except Exception:
log.debug("Creating new ccm %s cluster with %s", cluster_name, CCM_KWARGS)
cluster = CCMCluster(path, cluster_name, **CCM_KWARGS)
cluster.set_configuration_options({'start_native_transport': True})
if CASSANDRA_VERSION >= '2.2':
cluster.set_configuration_options({'enable_user_defined_functions': True})
common.switch_cluster(path, cluster_name)
cluster.populate(nodes, ipformat=ipformat)
jvm_args = []
# This will enable the Mirroring query handler which will echo our custom payload k,v pairs back
if PROTOCOL_VERSION >= 4:
jvm_args = [" -Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler"]
if start:
log.debug("Starting ccm %s cluster", cluster_name)
cluster.start(wait_for_binary_proto=True, wait_other_notice=True, jvm_args=jvm_args)
setup_keyspace(ipformat=ipformat)
CCM_CLUSTER = cluster
except Exception:
log.exception("Failed to start ccm cluster. Removing cluster.")
remove_cluster()
call(["pkill", "-9", "-f", ".ccm"])
raise
示例11: use_cluster
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def use_cluster(cluster_name, nodes, ipformat=None, start=True):
global CCM_CLUSTER
if USE_CASS_EXTERNAL:
if CCM_CLUSTER:
log.debug("Using external ccm cluster %s", CCM_CLUSTER.name)
else:
log.debug("Using unnamed external cluster")
return
if is_current_cluster(cluster_name, nodes):
log.debug("Using existing cluster %s", cluster_name)
return
if CCM_CLUSTER:
log.debug("Stopping cluster %s", CCM_CLUSTER.name)
CCM_CLUSTER.stop()
try:
try:
cluster = CCMClusterFactory.load(path, cluster_name)
log.debug("Found existing ccm %s cluster; clearing", cluster_name)
cluster.clear()
cluster.set_install_dir(**CCM_KWARGS)
except Exception:
log.debug("Creating new ccm %s cluster with %s", cluster_name, CCM_KWARGS)
cluster = CCMCluster(path, cluster_name, **CCM_KWARGS)
cluster.set_configuration_options({'start_native_transport': True})
if CASSANDRA_VERSION >= '2.2':
cluster.set_configuration_options({'enable_user_defined_functions': True})
common.switch_cluster(path, cluster_name)
cluster.populate(nodes, ipformat=ipformat)
if start:
log.debug("Starting ccm %s cluster", cluster_name)
cluster.start(wait_for_binary_proto=True, wait_other_notice=True)
setup_keyspace(ipformat=ipformat)
CCM_CLUSTER = cluster
except Exception:
log.exception("Failed to start ccm cluster. Removing cluster.")
remove_cluster()
call(["pkill", "-9", "-f", ".ccm"])
raise
示例12: setup_package
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def setup_package():
try:
try:
cluster = CCMCluster.load(path, CLUSTER_NAME)
log.debug("Found existing ccm test cluster, clearing")
cluster.clear()
except Exception:
log.debug("Creating new ccm test cluster")
cluster = CCMCluster(path, CLUSTER_NAME, cassandra_version='1.2.6')
cluster.set_configuration_options({'start_native_transport': True})
common.switch_cluster(path, CLUSTER_NAME)
cluster.populate(3)
log.debug("Starting ccm test cluster")
cluster.start(wait_for_binary_proto=True)
except Exception:
log.exception("Failed to start ccm cluster:")
raise
global CCM_CLUSTER
CCM_CLUSTER = cluster
示例13: _get_cluster
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def _get_cluster(self, name='test'):
if self._preserve_cluster and hasattr(self, 'cluster'):
return self.cluster
self.test_path = tempfile.mkdtemp(prefix='dtest-')
# ccm on cygwin needs absolute path to directory - it crosses from cygwin space into
# regular Windows space on wmic calls which will otherwise break pathing
if sys.platform == "cygwin":
self.test_path = subprocess.Popen(["cygpath", "-m", self.test_path], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0].rstrip()
debug("cluster ccm directory: " + self.test_path)
version = os.environ.get('CASSANDRA_VERSION')
cdir = CASSANDRA_DIR
if version:
cluster = Cluster(self.test_path, name, cassandra_version=version)
else:
cluster = Cluster(self.test_path, name, cassandra_dir=cdir)
if DISABLE_VNODES:
cluster.set_configuration_options(values={'num_tokens': None})
else:
cluster.set_configuration_options(values={'initial_token': None, 'num_tokens': NUM_TOKENS})
if OFFHEAP_MEMTABLES:
cluster.set_configuration_options(values={'memtable_allocation_type': 'offheap_objects'})
cluster.set_datadir_count(DATADIR_COUNT)
return cluster
示例14: _get_cluster
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def _get_cluster(self, name='test'):
self.test_path = tempfile.mkdtemp(prefix='dtest-')
# ccm on cygwin needs absolute path to directory - it crosses from cygwin space into
# regular Windows space on wmic calls which will otherwise break pathing
if sys.platform == "cygwin":
self.test_path = subprocess.Popen(["cygpath", "-m", self.test_path], stdout = subprocess.PIPE, stderr = subprocess.STDOUT).communicate()[0].rstrip()
debug("cluster ccm directory: "+self.test_path)
try:
version = os.environ['CASSANDRA_VERSION']
cluster = Cluster(self.test_path, name, cassandra_version=version)
except KeyError:
try:
cdir = os.environ['CASSANDRA_DIR']
except KeyError:
cdir = DEFAULT_DIR
cluster = Cluster(self.test_path, name, cassandra_dir=cdir)
if cluster.version() >= "1.2":
if DISABLE_VNODES:
cluster.set_configuration_options(values={'num_tokens': None})
else:
cluster.set_configuration_options(values={'initial_token': None, 'num_tokens': 256})
return cluster
示例15: setup_package
# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import set_configuration_options [as 别名]
def setup_package():
version = os.getenv("CASSANDRA_VERSION", DEFAULT_CASSANDRA_VERSION)
try:
try:
cluster = CCMCluster.load(path, CLUSTER_NAME)
log.debug("Found existing ccm test cluster, clearing")
cluster.clear()
cluster.set_cassandra_dir(cassandra_version=version)
except Exception:
log.debug("Creating new ccm test cluster with version %s", version)
cluster = CCMCluster(path, CLUSTER_NAME, cassandra_version=version)
cluster.set_configuration_options({'start_native_transport': True})
common.switch_cluster(path, CLUSTER_NAME)
cluster.populate(3)
log.debug("Starting ccm test cluster")
cluster.start(wait_for_binary_proto=True)
except Exception:
log.exception("Failed to start ccm cluster:")
raise
global CCM_CLUSTER
CCM_CLUSTER = cluster
setup_test_keyspace()