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; }
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; }
public ReverseIndexQuery(Keyspace ks, ColumnFamily<K, C> cfData, String indexCf, Serializer<V> valSerializer) { this.ks = ks; this.cfData = cfData; this.valSerializer = valSerializer; this.startValue = null; this.endValue = null; this.cfIndex = ColumnFamily.newColumnFamily(indexCf, ByteBufferSerializer.get(), ByteBufferSerializer.get()); }
public ReverseIndexQuery(Keyspace ks, ColumnFamily<K, C> cfData, String indexCf, Serializer<V> valSerializer) { this.ks = ks; this.cfData = cfData; this.valSerializer = valSerializer; this.startValue = null; this.endValue = null; this.cfIndex = ColumnFamily.newColumnFamily(indexCf, ByteBufferSerializer.get(), ByteBufferSerializer.get()); }
public AstyanaxCheckpointManager(Keyspace keyspace, String columnFamily, ByteBuffer bbKey) { this.keyspace = keyspace; this.bbKey = bbKey; this.columnFamily = ColumnFamily.newColumnFamily(columnFamily, ByteBufferSerializer.get(), StringSerializer.get()); }
public CassandraChunkedStorageProvider(Keyspace keyspace, String cfName) { this.keyspace = keyspace; this.cf = ColumnFamily.newColumnFamily(cfName, StringSerializer.get(), StringSerializer.get()); }
public CassandraChunkedStorageProvider(Keyspace keyspace, String cfName) { this.keyspace = keyspace; this.cf = ColumnFamily.newColumnFamily(cfName, StringSerializer.get(), StringSerializer.get()); }
private ShardedDistributedMessageQueue(Builder builder) throws MessageQueueException { this.queueColumnFamily = ColumnFamily.newColumnFamily(builder.columnFamilyName + DEFAULT_QUEUE_SUFFIX, StringSerializer.get(), entrySerializer); this.keyIndexColumnFamily = ColumnFamily.newColumnFamily(builder.columnFamilyName + DEFAULT_METADATA_SUFFIX, StringSerializer.get(), metadataSerializer); this.historyColumnFamily = ColumnFamily.newColumnFamily(builder.columnFamilyName + DEFAULT_HISTORY_SUFFIX, StringSerializer.get(), TimeUUIDSerializer.get());
public Set<AppsInstance> getAllInstancesFromCassandra(String app) { Set<AppsInstance> set = new HashSet<AppsInstance>(); try { final String selectClause = String.format( "SELECT * FROM %s USING CONSISTENCY LOCAL_QUORUM WHERE %s = '%s' ", CF_NAME_TOKENS, CN_APPID, app); logger.debug(selectClause); final ColumnFamily<String, String> CF_TOKENS_NEW = ColumnFamily.newColumnFamily(KS_NAME, StringSerializer.get(), StringSerializer.get()); OperationResult<CqlResult<String, String>> result = bootKeyspace.prepareQuery(CF_TOKENS_NEW) .withCql(selectClause).execute(); for (Row<String, String> row : result.getResult().getRows()) set.add(transform(row.getColumns())); } catch (Exception e) { logger.warn("Caught an Unknown Exception during reading msgs ... -> " + e.getMessage()); throw new RuntimeException(e); } return set; }
final ColumnFamily<String, String> CF_INSTANCES_NEW = ColumnFamily.newColumnFamily(KS_NAME, StringSerializer.get(), StringSerializer.get());
public String findKey(String app, String id, String location, String datacenter) { try { final String selectClause = String.format( "SELECT * FROM %s USING CONSISTENCY LOCAL_QUORUM WHERE %s = '%s' and %s = '%s' and %s = '%s' and %s = '%s' ", "tokens", CN_APPID, app, CN_ID, id, CN_LOCATION, location, CN_DC, datacenter); logger.info(selectClause); final ColumnFamily<String, String> CF_INSTANCES_NEW = ColumnFamily.newColumnFamily(KS_NAME, StringSerializer.get(), StringSerializer.get()); OperationResult<CqlResult<String, String>> result = bootKeyspace.prepareQuery(CF_INSTANCES_NEW) .withCql(selectClause).execute(); if (result == null || result.getResult().getRows().size() == 0) return null; Row<String, String> row = result.getResult().getRows().getRowByIndex(0); return row.getKey(); } catch (Exception e) { logger.warn("Caught an Unknown Exception during find a row matching cluster[" + app + "], id[" + id + "], and region[" + datacenter + "] ... -> " + e.getMessage()); throw new RuntimeException(e); } }
public String findKey(String cluster, String instanceId, String dc) { try { final String selectClause = String.format( "SELECT * FROM %s WHERE %s = '%s' and %s = '%s' and %s = '%s' ", CF_NAME_INSTANCES, CN_CLUSTER, cluster, CN_INSTANCEID, instanceId, CN_LOCATION, dc); logger.info(selectClause); final ColumnFamily<String, String> CF_INSTANCES_NEW = ColumnFamily.newColumnFamily(KS_NAME, StringSerializer.get(), StringSerializer.get()); OperationResult<CqlResult<String, String>> result = bootKeyspace.prepareQuery(CF_INSTANCES_NEW) .withCql(selectClause).execute(); if (result == null || result.getResult().getRows().size() == 0) return null; Row<String, String> row = result.getResult().getRows().getRowByIndex(0); return row.getKey(); } catch (Exception e) { logger.warn("Caught an Unknown Exception during find a row matching cluster[" + cluster + "], id[" + instanceId + "], and region[" + dc + "] ... -> " + e.getMessage()); throw new RuntimeException(e); } }
private void addToBatch(MutationBatch batch, WriteMetadata failedWrite) { // TODO: must deal with failed operations like createCF etc if (failedWrite.getCFName() == null || failedWrite.getRowKey() == null) { return; } String cfName = failedWrite.getPrimaryCluster() + "-" + failedWrite.getPrimaryKeyspace(); ColumnFamily<String, Long> CF_FAILED_WRITES = ColumnFamily.newColumnFamily(cfName, StringSerializer.get(), LongSerializer.get(), StringSerializer.get()); String rowKey = failedWrite.getCFName() + "_" + counter.getNext(); Long column = failedWrite.getUuid(); String value = failedWrite.getRowKey(); batch.withRow(CF_FAILED_WRITES, rowKey).putColumn(column, value); }
EMP_CF = ColumnFamily.newColumnFamily( EMP_CF_NAME, IntegerSerializer.get(),
EMP_CF = ColumnFamily.newColumnFamily( EMP_CF_NAME, IntegerSerializer.get(),