Java Code Examples for com.netflix.astyanax.serializers.StringSerializer#get()

The following examples show how to use com.netflix.astyanax.serializers.StringSerializer#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityCollectionManagerImpl.java    From usergrid with Apache License 2.0 6 votes vote down vote up
@Override
public Health getHealth() {

    try {
        ColumnFamily<String, String> CF_SYSTEM_LOCAL =
            new ColumnFamily<String, String>( "system.local", StringSerializer.get(), StringSerializer.get(),
                StringSerializer.get() );

        OperationResult<CqlResult<String, String>> result =
            keyspace.prepareQuery( CF_SYSTEM_LOCAL )
                .setConsistencyLevel(ConsistencyLevel.CL_ONE)
                .withCql( "SELECT now() FROM system.local;" )
                .execute();

        if ( result.getResult().getRows().size() > 0 ) {
            return Health.GREEN;
        }
    }
    catch ( ConnectionException ex ) {
        logger.error( "Error connecting to Cassandra", ex );
    }

    return Health.RED;
}
 
Example 2
Source File: AstyanaxSupport.java    From brooklyn-library with Apache License 2.0 5 votes vote down vote up
protected AstyanaxSample(Builder builder) {
    super(builder.clusterName, builder.hostname, builder.thriftPort);
    columnFamilyName = checkNotNull(builder.columnFamilyName, "columnFamilyName");
    sampleColumnFamily = new ColumnFamily<String, String>(
            columnFamilyName, // Column Family Name
            StringSerializer.get(), // Key Serializer
            StringSerializer.get()); // Column Serializer
}
 
Example 3
Source File: AstyanaxDao.java    From staash with Apache License 2.0 5 votes vote down vote up
public AstyanaxDao(Keyspace keyspace, Class<T> entityType) {
    this.keyspace     = keyspace;
    this.entityName   = entityNameFromClass(entityType);
    this.columnFamily = new ColumnFamily<String, String>(this.entityName, StringSerializer.get(), StringSerializer.get());
    this.prefix       = "";
    
    manager = new DefaultEntityManager.Builder<T, String>()
            .withKeyspace(keyspace)
            .withColumnFamily(columnFamily)
            .withEntityType(entityType)
            .build();
}
 
Example 4
Source File: AstyanaxDao.java    From staash with Apache License 2.0 5 votes vote down vote up
public AstyanaxDao(Keyspace keyspace, Class<T> entityType, String columnFamilyName) {
    this.keyspace     = keyspace;
    this.entityName   = entityNameFromClass(entityType);
    this.columnFamily = new ColumnFamily<String, String>(columnFamilyName, StringSerializer.get(), StringSerializer.get());
    this.prefix       = this.entityName + ":";
    
    manager = new DefaultEntityManager.Builder<T, String>()
            .withKeyspace(keyspace)
            .withColumnFamily(columnFamily)
            .withEntityType(entityType)
            .build();
}
 
Example 5
Source File: AbstractCassandraHystrixCommand.java    From Nicobar with Apache License 2.0 5 votes vote down vote up
/**
 * returns a ColumnFamily given a columnFamilyName
 * @param columnFamilyName
 * @param rowKeyClass
 * @return a constructed ColumnFamily
 */
@SuppressWarnings({"unchecked", "rawtypes"})
protected ColumnFamily getColumnFamilyViaColumnName(String columnFamilyName, Class rowKeyClass) {
    if (rowKeyClass == String.class) {
        return new ColumnFamily(columnFamilyName, StringSerializer.get(), StringSerializer.get());
    } else if (rowKeyClass == Integer.class) {
        return new ColumnFamily(columnFamilyName, IntegerSerializer.get(), StringSerializer.get());
    } else if (rowKeyClass == Long.class) {
        return new ColumnFamily(columnFamilyName, LongSerializer.get(), StringSerializer.get());
    } else {
        throw new IllegalArgumentException("RowKeyType is not supported: " + rowKeyClass.getSimpleName() + ". String/Integer/Long are supported, or you can define the ColumnFamily yourself and use the other constructor.");
    }
}
 
Example 6
Source File: SimpleReverseIndexer.java    From staash with Apache License 2.0 4 votes vote down vote up
private SimpleReverseIndexer(Builder builder) {
    indexCf = new ColumnFamily<String, IndexEntry>(builder.columnFamily + "_idx",  StringSerializer.get(), EntrySerializer);
    dataCf  = new ColumnFamily<String, String>    (builder.columnFamily + "_data", StringSerializer.get(), StringSerializer.get());
    keyspace     = builder.keyspace;
}