public static <K, C> void createColumnFamiliy(final Keyspace keyspace, final ColumnFamily<K, C> columnFamily, final Map<String, Object> options){ try{ if(keyspace.describeKeyspace().getColumnFamily(columnFamily.getName()) == null){ keyspace.createColumnFamily( columnFamily, new HashMap<String, Object>() ); } }catch(Exception e){ logger.error( "Error on creating column family, ignoring" , e); } } }
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; }
/** * 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() ); }
keyspace.createColumnFamily( cf, new HashMap<String, Object>() );
@Override public OperationResult<SchemaChangeResult> exec(Keyspace ks) throws ConnectionException { return ks.createColumnFamily(columnFamily, options); } });
@Override public OperationResult<SchemaChangeResult> exec(Keyspace ks) throws ConnectionException { return ks.createColumnFamily(props); } });
@Override public Void call() throws Exception { keyspace.createColumnFamily(queueColumnFamily, ImmutableMap.<String, Object>builder() .put("key_validation_class", "UTF8Type") .put("comparator_type", "CompositeType(BytesType, BytesType(reversed=true), TimeUUIDType, TimeUUIDType, BytesType)") .putAll(columnFamilySettings) .build()); return null; } });
keyspace.createColumnFamily( testCf, null );
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_COMPOSITE, ImmutableMap.<String, Object>builder() .put("comparator_type", "CompositeType(AsciiType, IntegerType, IntegerType, BytesType, UTF8Type)") .build()); CF_COMPOSITE.describe(keyspace); }
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_COUNTER1,ImmutableMap.<String, Object>builder() .put("default_validation_class", "CounterColumnType") .build()); CF_COUNTER1.describe(keyspace); }
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_COL_TIMESTAMP, null); keyspace.createColumnFamily(CF_TTL, null); CF_COL_TIMESTAMP.describe(keyspace); CF_TTL.describe(keyspace); }
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_ROW_COPY, null); keyspace.createColumnFamily(CF_ROW_COPY2, null); CF_ROW_COPY.describe(keyspace); CF_ROW_COPY2.describe(keyspace); }
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_CLICK_STREAM, null); CF_CLICK_STREAM.describe(keyspace); }
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_COLUMN_RANGE_TEST, null); CF_COLUMN_RANGE_TEST.describe(keyspace); }
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_CHUNK, null); CF_CHUNK.describe(keyspace); }
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_LONGCOLUMN, null); CF_LONGCOLUMN.describe(keyspace); }
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_COLUMN_RANGE_TEST, null); CF_COLUMN_RANGE_TEST.describe(keyspace); }
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_TIME_UUID, null); CF_TIME_UUID.describe(keyspace); }
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_UNIQUE_CONSTRAINT, null); CF_UNIQUE_CONSTRAINT.describe(keyspace); }
@BeforeClass public static void init() throws Exception { initContext(); keyspace.createColumnFamily(CF_UNIQUE_CONSTRAINT, null); CF_UNIQUE_CONSTRAINT.describe(keyspace); }