本文整理汇总了Java中com.netflix.astyanax.ddl.KeyspaceDefinition.getColumnFamily方法的典型用法代码示例。如果您正苦于以下问题:Java KeyspaceDefinition.getColumnFamily方法的具体用法?Java KeyspaceDefinition.getColumnFamily怎么用?Java KeyspaceDefinition.getColumnFamily使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.astyanax.ddl.KeyspaceDefinition
的用法示例。
在下文中一共展示了KeyspaceDefinition.getColumnFamily方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColumnFamily
import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入方法依赖的package包/类
protected <C> ColumnFamily<ByteBuffer, C> getColumnFamily(KeyspaceDefinition keyspaceDef,
String prefix, String suffix, String placement,
Serializer<C> columnSerializer) throws IllegalArgumentException {
// Create the column family object. It must be keyed by a ByteBuffer because that's what
// the AstyanaxTable.getRowKey() method returns.
ColumnFamily<ByteBuffer, C> cf = new ColumnFamily<>(prefix + "_" + suffix,
ByteBufferSerializer.get(), columnSerializer);
// Verify that the column family exists in the Cassandra schema.
ColumnFamilyDefinition cfDef = keyspaceDef.getColumnFamily(cf.getName());
if (cfDef == null) {
throw new UnknownPlacementException(format(
"Placement string '%s' refers to unknown Cassandra %s column family in keyspace '%s': %s",
placement, suffix, keyspaceDef.getName(), cf.getName()), placement);
}
return cf;
}
示例2: getCompressionOptions
import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入方法依赖的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);
}
}
示例3: testAndCreateColumnFamilyDef
import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入方法依赖的package包/类
/**
* Check if the column family exists. If it dosn't create it
*/
private void testAndCreateColumnFamilyDef( MultiTenantColumnFamilyDefinition columnFamily )
throws ConnectionException {
final KeyspaceDefinition keyspaceDefinition = keyspace.describeKeyspace();
final ColumnFamilyDefinition existing =
keyspaceDefinition.getColumnFamily( columnFamily.getColumnFamily().getName() );
if ( existing != null ) {
logger.info("Not creating columnfamily {}, it already exists.", columnFamily.getColumnFamily().getName());
return;
}
keyspace.createColumnFamily( columnFamily.getColumnFamily(), columnFamily.getOptions() );
// the CF def creation uses Asytanax, so manually check the schema agreement
astyanaxWaitForSchemaAgreement();
logger.info( "Created column family {}", columnFamily.getColumnFamily().getName() );
}
示例4: getLocksColumnFamily
import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入方法依赖的package包/类
private ColumnFamily getLocksColumnFamily() {
if ( columnFamily == null ) {
columnFamily = ColumnFamily.newColumnFamily(
CF_NAME, StringSerializer.get(), StringSerializer.get() );
if ( logger.isDebugEnabled() ) {
try {
final KeyspaceDefinition kd = keyspace.describeKeyspace();
final ColumnFamilyDefinition cfd = kd.getColumnFamily( columnFamily.getName() );
Map<String, Object> options = new HashMap<>( 1 );
options.put( "gc_grace_seconds", cfd.getGcGraceSeconds() );
options.put( "caching", cfd.getCaching() );
options.put( "compaction_strategy", cfd.getCompactionStrategy() );
options.put( "compaction_strategy_options", cfd.getCompactionStrategyOptions() );
logger.debug( "Locks column family {} exists with options: {}", cfd.getName(), options);
} catch ( ConnectionException ce ) {
logger.warn("Error connecting to Cassandra for debug column family info", ce);
}
}
}
return columnFamily;
}
示例5: createLocksColumnFamily
import com.netflix.astyanax.ddl.KeyspaceDefinition; //导入方法依赖的package包/类
private ColumnFamily createLocksColumnFamily() throws ConnectionException {
ColumnFamily<String, String> cflocks = ColumnFamily.newColumnFamily(
CF_NAME, StringSerializer.get(), StringSerializer.get() );
final KeyspaceDefinition kd = keyspace.describeKeyspace();
final ColumnFamilyDefinition cfdef = kd.getColumnFamily( cflocks.getName() );
if ( cfdef == null ) {
// create only if does not already exist
MultiTenantColumnFamilyDefinition mtcfd = new MultiTenantColumnFamilyDefinition(
cflocks,
BytesType.class.getSimpleName(),
UTF8Type.class.getSimpleName(),
BytesType.class.getSimpleName(),
MultiTenantColumnFamilyDefinition.CacheOption.ALL
);
Map<String, Object> cfOptions = mtcfd.getOptions();
// Additionally set the gc grace low
cfOptions.put( "gc_grace_seconds", 60 );
keyspace.createColumnFamily( mtcfd.getColumnFamily(), cfOptions );
logger.info( "Created column family {}", mtcfd.getOptions() );
cflocks = mtcfd.getColumnFamily();
} else {
return getLocksColumnFamily();
}
return cflocks;
}