本文整理汇总了Python中ccmlib.dse_cluster.DseCluster.set_dse_configuration_options方法的典型用法代码示例。如果您正苦于以下问题:Python DseCluster.set_dse_configuration_options方法的具体用法?Python DseCluster.set_dse_configuration_options怎么用?Python DseCluster.set_dse_configuration_options使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ccmlib.dse_cluster.DseCluster
的用法示例。
在下文中一共展示了DseCluster.set_dse_configuration_options方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: use_cluster
# 需要导入模块: from ccmlib.dse_cluster import DseCluster [as 别名]
# 或者: from ccmlib.dse_cluster.DseCluster import set_dse_configuration_options [as 别名]
def use_cluster(cluster_name, nodes, ipformat=None, start=True, workloads=[]):
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))
if DSE_VERSION:
log.error("creating dse cluster")
CCM_CLUSTER = DseCluster(path, cluster_name, **CCM_KWARGS)
else:
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})
if CASSANDRA_VERSION >= '3.0':
CCM_CLUSTER.set_configuration_options({'enable_scripted_user_defined_functions': True})
if 'spark' in workloads:
config_options = {"initial_spark_worker_resources": 0.1}
CCM_CLUSTER.set_dse_configuration_options(config_options)
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(len(workloads) > 0):
for node in CCM_CLUSTER.nodes.values():
node.set_workloads(workloads)
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)
# Added to wait for slow nodes to start up
for node in CCM_CLUSTER.nodes.values():
wait_for_node_socket(node, 120)
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
示例2: use_cluster
# 需要导入模块: from ccmlib.dse_cluster import DseCluster [as 别名]
# 或者: from ccmlib.dse_cluster.DseCluster import set_dse_configuration_options [as 别名]
def use_cluster(cluster_name, nodes, ipformat=None, start=True, workloads=[], set_keyspace=True, ccm_options=None,
configuration_options={}, dse_cluster=False, dse_options={},
dse_version=None):
if (dse_version and not dse_cluster):
raise ValueError('specified dse_version {} but not dse_cluster'.format(dse_version))
set_default_cass_ip()
if ccm_options is None and dse_cluster:
ccm_options = {"version": dse_version or DSE_VERSION}
elif ccm_options is None:
ccm_options = CCM_KWARGS.copy()
cassandra_version = ccm_options.get('version', CCM_VERSION)
dse_version = ccm_options.get('version', DSE_VERSION)
if 'version' in ccm_options:
ccm_options['version'] = ccm_options['version'].base_version
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")
if set_keyspace and start:
setup_keyspace(ipformat=ipformat, wait=False)
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_options)
CCM_CLUSTER.set_configuration_options(configuration_options)
except Exception:
ex_type, ex, tb = sys.exc_info()
log.warning("{0}: {1} Backtrace: {2}".format(ex_type.__name__, ex, traceback.extract_tb(tb)))
del tb
ccm_options.update(cmd_line_args_to_dict('CCM_ARGS'))
log.debug("Creating new CCM cluster, {0}, with args {1}".format(cluster_name, ccm_options))
# Make sure we cleanup old cluster dir if it exists
cluster_path = os.path.join(path, cluster_name)
if os.path.exists(cluster_path):
shutil.rmtree(cluster_path)
if dse_cluster:
CCM_CLUSTER = DseCluster(path, cluster_name, **ccm_options)
CCM_CLUSTER.set_configuration_options({'start_native_transport': True})
CCM_CLUSTER.set_configuration_options({'batch_size_warn_threshold_in_kb': 5})
if dse_version >= Version('5.0'):
CCM_CLUSTER.set_configuration_options({'enable_user_defined_functions': True})
CCM_CLUSTER.set_configuration_options({'enable_scripted_user_defined_functions': True})
if 'spark' in workloads:
config_options = {"initial_spark_worker_resources": 0.1}
CCM_CLUSTER.set_dse_configuration_options(config_options)
common.switch_cluster(path, cluster_name)
CCM_CLUSTER.set_configuration_options(configuration_options)
CCM_CLUSTER.populate(nodes, ipformat=ipformat)
CCM_CLUSTER.set_dse_configuration_options(dse_options)
else:
CCM_CLUSTER = CCMCluster(path, cluster_name, **ccm_options)
CCM_CLUSTER.set_configuration_options({'start_native_transport': True})
if cassandra_version >= Version('2.2'):
CCM_CLUSTER.set_configuration_options({'enable_user_defined_functions': True})
if cassandra_version >= Version('3.0'):
CCM_CLUSTER.set_configuration_options({'enable_scripted_user_defined_functions': True})
common.switch_cluster(path, cluster_name)
CCM_CLUSTER.set_configuration_options(configuration_options)
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 'graph' not in workloads:
if PROTOCOL_VERSION >= 4:
jvm_args = [" -Dcassandra.custom_query_handler_class=org.apache.cassandra.cql3.CustomPayloadMirroringQueryHandler"]
if(len(workloads) > 0):
for node in CCM_CLUSTER.nodes.values():
node.set_workloads(workloads)
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)
# Added to wait for slow nodes to start up
for node in CCM_CLUSTER.nodes.values():
wait_for_node_socket(node, 120)
if set_keyspace:
setup_keyspace(ipformat=ipformat)
except Exception:
#.........这里部分代码省略.........