本文整理汇总了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;
}
示例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);
}
}
示例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);
}
}
示例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());
}
}
示例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);
}
示例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);
}