本文整理汇总了Java中com.netflix.astyanax.Keyspace.describeKeyspace方法的典型用法代码示例。如果您正苦于以下问题:Java Keyspace.describeKeyspace方法的具体用法?Java Keyspace.describeKeyspace怎么用?Java Keyspace.describeKeyspace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.astyanax.Keyspace
的用法示例。
在下文中一共展示了Keyspace.describeKeyspace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCompressionOptions
import com.netflix.astyanax.Keyspace; //导入方法依赖的package包/类
@Override
public Map<String, String> getCompressionOptions(String cf) throws BackendException {
try {
Keyspace k = keyspaceContext.getClient();
KeyspaceDefinition kdef = k.describeKeyspace();
if (null == kdef) {
throw new PermanentBackendException("Keyspace " + k.getKeyspaceName() + " is undefined");
}
ColumnFamilyDefinition cfdef = kdef.getColumnFamily(cf);
if (null == cfdef) {
throw new PermanentBackendException("Column family " + cf + " is undefined");
}
return cfdef.getCompressionOptions();
} catch (ConnectionException e) {
throw new PermanentBackendException(e);
}
}
示例2: autotest
import com.netflix.astyanax.Keyspace; //导入方法依赖的package包/类
/**
* Test if database is ok, else create keyspace and CF as needed
*/
public static void autotest() throws Exception {
if (initcount > 1) {
/**
* If you have already initialized the class
*/
resetinit();
}
Keyspace keyspace = getkeyspace();
try {
keyspace.describeKeyspace();
} catch (ConnectionException e) {
if (e.getMessage().endsWith("InvalidRequestException(why:Keyspace '" + default_keyspacename + "' does not exist)")) {
Loggers.Cassandra.info("Create keyspace " + default_keyspacename);
createKeyspace(default_keyspacename);
} else {
throw e;
}
}
}
示例3: initKeyspace
import com.netflix.astyanax.Keyspace; //导入方法依赖的package包/类
@Override
public void initKeyspace(Keyspace keyspace) throws ConnectionException {
try {
keyspace.describeKeyspace();
} catch (ConnectionException e) {
Map<String, Object> options = ImmutableMap.<String, Object>builder()
.put("name", keyspace.getKeyspaceName())
.put("strategy_class", "SimpleStrategy")
.put("strategy_options", ImmutableMap.of("replication_factor", "1"))
.build();
keyspace.createKeyspace(options);
}
}
示例4: AstyanaxMetaDaoImpl
import com.netflix.astyanax.Keyspace; //导入方法依赖的package包/类
@Inject
public AstyanaxMetaDaoImpl(@Named("astmetaks") Keyspace keyspace) {
this.keyspace = keyspace;
try {
keyspace.describeKeyspace();
logger.info("keyspaces for staash exists already");
StaashRequestContext.addContext("Meta_Init",
"keyspace already existed");
} catch (ConnectionException ex) {
StaashRequestContext.addContext("Meta_Init",
"Keyspace did not exist , creating keyspace "+MetaConstants.META_KEY_SPACE
);
maybecreateschema();
}
}