当前位置: 首页>>代码示例>>Python>>正文


Python Cluster.start方法代码示例

本文整理汇总了Python中ccmlib.cluster.Cluster.start方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.start方法的具体用法?Python Cluster.start怎么用?Python Cluster.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ccmlib.cluster.Cluster的用法示例。


在下文中一共展示了Cluster.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: use_cluster

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [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
开发者ID:IChocolateKapa,项目名称:python-driver,代码行数:34,代码来源:__init__.py

示例2: clear_and_use_multidc

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [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")
开发者ID:EnigmaCurry,项目名称:python-driver,代码行数:29,代码来源:__init__.py

示例3: TestCCMLib

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [as 别名]
class TestCCMLib(ccmtest.Tester):
    def test2(self):
        self.cluster = Cluster(CLUSTER_PATH, "test2", cassandra_version='2.0.3')
        self.cluster.populate(2)
        self.cluster.start()

        self.cluster.set_log_level("ERROR")

        class FakeNode:
            name = "non-existing node"

        self.cluster.remove(FakeNode())
        [node1, node2] = self.cluster.nodelist()
        self.cluster.remove(node1)
        self.cluster.show(True)
        self.cluster.show(False)

        #self.cluster.stress([])
        self.cluster.compact()
        self.cluster.drain()
        self.cluster.stop()

    def test3(self):
        self.cluster = Cluster(CLUSTER_PATH, "test3", cassandra_version='2.0.3')
        self.cluster.populate(2)
        self.cluster.start()
        self.cluster.cleanup()

        self.cluster.clear()
        self.cluster.stop()
开发者ID:jasobrown,项目名称:ccm,代码行数:32,代码来源:test_lib.py

示例4: setup_module

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [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
开发者ID:JeremiahDJordan,项目名称:python-driver,代码行数:30,代码来源:test_ipv6.py

示例5: run

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [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)
开发者ID:alanristic,项目名称:ccm,代码行数:36,代码来源:cluster_cmds.py

示例6: setup_package

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [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()
开发者ID:rubenk,项目名称:python-driver,代码行数:33,代码来源:__init__.py

示例7: run

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [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)
开发者ID:eevans,项目名称:ccm,代码行数:29,代码来源:cluster_cmds.py

示例8: test3

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [as 别名]
def test3():
    cluster = Cluster(CLUSTER_PATH, "test3", cassandra_version='2.0.3')
    cluster.populate(2)
    cluster.start()
    cluster.cleanup()

    cluster.clear()
    cluster.stop()
开发者ID:EnigmaCurry,项目名称:ccm,代码行数:10,代码来源:test_lib.py

示例9: use_cluster

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [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})
                if CASSANDRA_VERSION >= "3.0":
                    CCM_CLUSTER.set_configuration_options({"enable_scripted_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
开发者ID:heqing90,项目名称:python-driver,代码行数:60,代码来源:__init__.py

示例10: setup_class

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [as 别名]
    def setup_class(cls):
        """
        Class-level fixture. Called once for all tests.
        We create a cluster object here and save it in the provided class instance
        Create 2 regular users and a new superuser.
        Enable authentication by setting 'authenticator': 'PasswordAuthenticator'.
        If invoked from authorization class enable authorization by setting 'authorizer': 'CassandraAuthorizer'.
        """
        try:
            ccm_cluster = CCMCluster.load(tests.integration.path, AUTH_CLUSTER_NAME)
            log.debug("Found existing ccm test authentication cluster, removing")
            ccm_cluster.remove()
        except Exception:
            log.debug("Can not load cluster %s ....." % AUTH_CLUSTER_NAME)

        log.debug("Creating new ccm test authentication cluster")
        if tests.integration.CASSANDRA_DIR:
            ccm_cluster = CCMCluster(tests.integration.path, AUTH_CLUSTER_NAME, cassandra_dir=tests.integration.CASSANDRA_DIR)
        else:
            ccm_cluster = CCMCluster(tests.integration.path, AUTH_CLUSTER_NAME, cassandra_version=tests.integration.CASSANDRA_VERSION)

        ccm_cluster.set_configuration_options({'start_native_transport': True})
        ccm_cluster.set_configuration_options({'authenticator': 'PasswordAuthenticator'})

        #
        # This method is called either with AuthenticationTests class or with AuthorizedAuthenticationTests class.
        # In the second case we enable CassandraAuthorizer
        #
        if cls.__name__ == 'AuthorizedAuthenticationTests':
            print "Running tests with Cassandra Authorizer Enabled"
            log.info("Running tests with Cassandra Authorizer Enabled")
            ccm_cluster.set_configuration_options({'authorizer': 'CassandraAuthorizer'})
        else:
            print "Running tests with Cassandra Authorizer Disabled"
            log.info("Running tests with Cassandra Authorizer Disabled")

        common.switch_cluster(tests.integration.path, AUTH_CLUSTER_NAME)
        ccm_cluster.populate(1)

        log.debug("Starting ccm test authentication cluster")
        ccm_cluster.start(wait_for_binary_proto=True)

        if not wait_for_cassandra() or not try_connecting('cassandra', 'cassandra'):
            log.exception("Can not talk to cassandra")
            raise Exception('Can not talk to cassandra')

        log.debug("Switched to AUTH_CLUSTER_NAME cluster")
        cls.ccm_cluster = ccm_cluster

        cls.root_cluster = cls.cluster_as('cassandra', 'cassandra')
        cls.root_session = cls.root_cluster.connect()
        cls.create_user(cls.root_cluster, cls.test_user, cls.password)
        cls.create_user(cls.root_cluster, cls.test_other_user, cls.password)
        cls.create_user(cls.root_cluster, cls.suser, cls.password, su=True)
开发者ID:JeremiahDJordan,项目名称:python-driver,代码行数:56,代码来源:test_authentication.py

示例11: test1

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [as 别名]
def test1():
    cluster = Cluster(CLUSTER_PATH, "test1", cassandra_version='2.0.3')
    cluster.show(False)
    cluster.populate(2)
    cluster.set_partitioner("Murmur3")
    cluster.start()
    cluster.set_configuration_options(None, None)
    cluster.set_configuration_options({}, True)
    cluster.set_configuration_options({"a": "b"}, False)

    [node1, node2] = cluster.nodelist()
    node2.compact()
    cluster.flush()
    cluster.remove()
    cluster.stop()
开发者ID:EnigmaCurry,项目名称:ccm,代码行数:17,代码来源:test_lib.py

示例12: use_cluster

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [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
开发者ID:dokai,项目名称:python-driver,代码行数:50,代码来源:__init__.py

示例13: TestCCMIssues

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [as 别名]
class TestCCMIssues(Tester):

    def issue_150_test(self):
        self.cluster = Cluster(CLUSTER_PATH, "150", cassandra_version='2.0.9')
        self.cluster.populate([1, 2], use_vnodes=True)
        self.cluster.start()
        dcs = [node.data_center for node in self.cluster.nodelist()]
        dcs.append('dc2')

        node4 = Node('node4', self.cluster, True, ('127.0.0.4', 9160), ('127.0.0.4', 7000),
            '7400', '2000', None)
        self.cluster.add(node4, False, 'dc2')
        node4.start()

        dcs_2 = [node.data_center for node in self.cluster.nodelist()]
        self.assertItemsEqual(dcs, dcs_2)
        node4.nodetool('status')
开发者ID:PseudoCorps,项目名称:ccm,代码行数:19,代码来源:test_issues.py

示例14: use_cluster

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [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
开发者ID:aaronbenz,项目名称:python-driver,代码行数:45,代码来源:__init__.py

示例15: test2

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import start [as 别名]
def test2():
    cluster = Cluster(CLUSTER_PATH, "test2", cassandra_version='2.0.3')
    cluster.populate(2)
    cluster.start()

    cluster.set_log_level("ERROR")

    class FakeNode:
        name = "non-existing node"

    cluster.remove(FakeNode())
    [node1, node2] = cluster.nodelist()
    cluster.remove(node1)
    cluster.show(True)
    cluster.show(False)

    #cluster.stress([])
    cluster.compact()
    cluster.drain()
    cluster.stop()
开发者ID:EnigmaCurry,项目名称:ccm,代码行数:22,代码来源:test_lib.py


注:本文中的ccmlib.cluster.Cluster.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。