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


Java Cluster.describeKeyspace方法代码示例

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


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

示例1: getOrCreateKeyspace

import me.prettyprint.hector.api.Cluster; //导入方法依赖的package包/类
@Override public Keyspace getOrCreateKeyspace(String keyspaceName, int replicationFactor, Cluster cluster) {
    KeyspaceDefinition keyspaceDef = cluster.describeKeyspace(keyspaceName);
    List<ColumnFamilyDefinition> cfDefs = new LinkedList<ColumnFamilyDefinition>();
    // If keyspace does not exist create it without CFs.
    if (keyspaceDef == null) {
        keyspaceDef = HFactory.createKeyspaceDefinition(keyspaceName, ThriftKsDef.DEF_STRATEGY_CLASS, replicationFactor, cfDefs);
        cluster.addKeyspace(keyspaceDef);
    }

    Keyspace keyspace = HFactory.createKeyspace(keyspaceName, cluster);

    ConfigurableConsistencyLevel consistencyLevel = new ConfigurableConsistencyLevel();
    consistencyLevel.setDefaultReadConsistencyLevel(HConsistencyLevel.QUORUM);
    consistencyLevel.setDefaultWriteConsistencyLevel(HConsistencyLevel.QUORUM);
    keyspace.setConsistencyLevelPolicy(consistencyLevel);

    return keyspace;
}
 
开发者ID:appmetr,项目名称:hercules,代码行数:19,代码来源:ThriftDataDriver.java

示例2: CassandraStorageSystem

import me.prettyprint.hector.api.Cluster; //导入方法依赖的package包/类
/** Constructor. */
public CassandraStorageSystem(int port) throws StorageException {
	try {
		Cluster cluster = createCluster(port);
		if (cluster.describeKeyspace(KEYSPACE_NAME) == null) {
			createKeyspace(cluster);
		}
		keyspace = HFactory.createKeyspace(KEYSPACE_NAME, cluster);
		template = new ThriftColumnFamilyTemplate<byte[], String>(keyspace,
				COLUMN_FAMILY_NAME, BytesArraySerializer.get(),
				StringSerializer.get());
	} catch (HectorException e) {
		throw new StorageException(e);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:16,代码来源:CassandraStorageSystem.java

示例3: createCluster

import me.prettyprint.hector.api.Cluster; //导入方法依赖的package包/类
/** Removes all data. This is used for testing. */
/* package */static void clearAllData() {
	// As this method is only used from tests, we can use the default port
	// here.
	Cluster cluster = createCluster(DEFAULT_PORT);
	if (cluster.describeKeyspace(KEYSPACE_NAME) != null) {
		cluster.dropKeyspace(KEYSPACE_NAME);
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:10,代码来源:CassandraStorageSystem.java

示例4: createKeyspace

import me.prettyprint.hector.api.Cluster; //导入方法依赖的package包/类
private void createKeyspace() {

            Cluster cluster = newCluster();

            KeyspaceDefinition keyspaceDefinition = cluster.describeKeyspace(KEYSPACE_NAME);

            if (keyspaceDefinition == null) {
                keyspaceDefinition = HFactory.createKeyspaceDefinition(KEYSPACE_NAME);
                String keyspaceId = cluster.addKeyspace(keyspaceDefinition, true);
                System.out.println("Result of addKeyspace: " + keyspaceId);
            } else {
                System.out.println("Keyspace already exists with name: " + keyspaceDefinition.getName());
            }

        }
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:16,代码来源:CassandraStresser.java

示例5: test

import me.prettyprint.hector.api.Cluster; //导入方法依赖的package包/类
@Test
public void test() {
    Cluster cluster = HFactory.getOrCreateCluster("test-cluster","localhost:9160");

    KeyspaceDefinition keyspaceDef = cluster.describeKeyspace(KEYSPACE);

    if (keyspaceDef == null)
        createSchema(cluster, KEYSPACE);

    Keyspace ksp = HFactory.createKeyspace(KEYSPACE, cluster);

    ColumnFamilyTemplate<String, String> template =
            new ThriftColumnFamilyTemplate<String, String>(ksp,
                    COLUMN_FAMILY_NAME,
                    StringSerializer.get(),
                    StringSerializer.get());

    update(template);

    query(ksp);

    //delete(template);

}
 
开发者ID:ChaosXu,项目名称:rrd4j-cassandra,代码行数:25,代码来源:HectorTest.java

示例6: CassandraBackendFactory

import me.prettyprint.hector.api.Cluster; //导入方法依赖的package包/类
public CassandraBackendFactory(String hostIp) {
    Cluster cluster = HFactory.getOrCreateCluster("rrd4j-cluster", hostIp);

    KeyspaceDefinition keyspaceDef = cluster.describeKeyspace(KEYSPACE);

    if (keyspaceDef == null)
        createSchema(cluster, KEYSPACE);

    ksp = HFactory.createKeyspace(KEYSPACE, cluster);
}
 
开发者ID:ChaosXu,项目名称:rrd4j-cassandra,代码行数:11,代码来源:CassandraBackendFactory.java


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