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


Python Cluster.load方法代码示例

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


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

示例1: setUp

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import load [as 别名]
    def setUp(self):
        # cleaning up if a previous execution didn't trigger tearDown (which
        # can happen if it is interrupted by KeyboardInterrupt)
        # TODO: move that part to a generic fixture
        if os.path.exists(LAST_TEST_DIR):
            with open(LAST_TEST_DIR) as f:
                self.test_path = f.readline().strip("\n")
                name = f.readline()
                try:
                    self.cluster = Cluster.load(self.test_path, name)
                    # Avoid waiting too long for node to be marked down
                    self.__cleanup_cluster()
                except IOError:
                    # after a restart, /tmp will be emptied so we'll get an IOError when loading the old cluster here
                    pass

        self.cluster = self.__get_cluster()
        # the failure detector can be quite slow in such tests with quick start/stop
        self.cluster.set_configuration_options(values={"phi_convict_threshold": 5})
        self.cluster.set_configuration_options(values={"rpc_timeout_in_ms": 15000})
        with open(LAST_TEST_DIR, "w") as f:
            f.write(self.test_path + "\n")
            f.write(self.cluster.name)
        if DEBUG:
            self.cluster.set_log_level("DEBUG")
        self.connections = []
        self.runners = []
开发者ID:strategist922,项目名称:cassandra-dtest,代码行数:29,代码来源:dtest.py

示例2: clear_and_use_multidc

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import load [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: setup_package

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import load [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

示例4: setup_module

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import load [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: _load_current_cluster

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import load [as 别名]
 def _load_current_cluster(self):
     name = common.current_cluster_name(self.path)
     if name is None:
         print_('No currently active cluster (use ccm cluster switch)')
         exit(1)
     try:
         return Cluster.load(self.path, name)
     except common.LoadError as e:
         print_(str(e))
         exit(1)
开发者ID:EnigmaCurry,项目名称:ccm,代码行数:12,代码来源:command.py

示例6: setup_class

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import load [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

示例7: run

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import load [as 别名]
 def run(self):
     if self.other_cluster:
         # Remove the specified cluster:
         cluster = Cluster.load(self.path, self.other_cluster)
         cluster.remove()
         # Remove CURRENT flag if the specified cluster is the current cluster:
         if self.other_cluster == common.current_cluster_name(self.path):
             os.remove(os.path.join(self.path, 'CURRENT'))
     else:
         # Remove the current cluster:
         self.cluster.remove()
         os.remove(os.path.join(self.path, 'CURRENT'))
开发者ID:aeriksson,项目名称:ccm,代码行数:14,代码来源:cluster_cmds.py

示例8: teardown_package

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import load [as 别名]
def teardown_package():
    for cluster_name in [CLUSTER_NAME, MULTIDC_CLUSTER_NAME]:
        try:
            cluster = CCMCluster.load(path, cluster_name)

            try:
                cluster.clear()
                cluster.remove()
                log.info('Cleared cluster: %s' % cluster_name)
            except Exception:
                log.exception('Failed to clear cluster: %s' % cluster_name)

        except Exception:
            log.warn('Did not find cluster: %s' % cluster_name)
开发者ID:JeremyOT,项目名称:python-driver,代码行数:16,代码来源:__init__.py

示例9: setUp

# 需要导入模块: from ccmlib.cluster import Cluster [as 别名]
# 或者: from ccmlib.cluster.Cluster import load [as 别名]
    def setUp(self):
        global CURRENT_TEST
        CURRENT_TEST = self.id() + self._testMethodName
        # cleaning up if a previous execution didn't trigger tearDown (which
        # can happen if it is interrupted by KeyboardInterrupt)
        # TODO: move that part to a generic fixture
        if os.path.exists(LAST_TEST_DIR):
            with open(LAST_TEST_DIR) as f:
                self.test_path = f.readline().strip('\n')
                name = f.readline()
                try:
                    self.cluster = Cluster.load(self.test_path, name)
                    # Avoid waiting too long for node to be marked down
                    self.__cleanup_cluster()
                except IOError:
                    # after a restart, /tmp will be emptied so we'll get an IOError when loading the old cluster here
                    pass

        self.cluster = self._get_cluster()
        self.__setup_cobertura()
        # the failure detector can be quite slow in such tests with quick start/stop
        self.cluster.set_configuration_options(values={'phi_convict_threshold': 5})

        timeout = 10000
        if self.cluster_options is not None:
            self.cluster.set_configuration_options(values=self.cluster_options)
        elif self.cluster.version() < "1.2":
            self.cluster.set_configuration_options(values={'rpc_timeout_in_ms': timeout})
        else:
            self.cluster.set_configuration_options(values={
                'read_request_timeout_in_ms' : timeout,
                'range_request_timeout_in_ms' : timeout,
                'write_request_timeout_in_ms' : timeout,
                'truncate_request_timeout_in_ms' : timeout,
                'request_timeout_in_ms' : timeout
            })

        with open(LAST_TEST_DIR, 'w') as f:
            f.write(self.test_path + '\n')
            f.write(self.cluster.name)
        if DEBUG:
            self.cluster.set_log_level("DEBUG")
        if TRACE:
            self.cluster.set_log_level("TRACE")
        self.connections = []
        self.runners = []
开发者ID:AlfredChenxf,项目名称:cassandra-dtest,代码行数:48,代码来源:dtest.py

示例10: setup_package

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

示例11: setup_package

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


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