Search in sources :

Example 6 with ConsistencyLevel

use of org.apache.cassandra.thrift.ConsistencyLevel in project cassandra-indexing by hmsonline.

the class CassandraIndexAspect method process.

@Around("execution(* org.apache.cassandra.thrift.CassandraServer.doInsert(..))")
public void process(ProceedingJoinPoint joinPoint) throws Throwable {
    ConsistencyLevel consistency = (ConsistencyLevel) joinPoint.getArgs()[0];
    @SuppressWarnings("unchecked") List<IMutation> mutations = (List<IMutation>) joinPoint.getArgs()[1];
    Handler handler = new Handler(cluster, indexDao, configurationDao, mutations, consistency);
    Future<?> future = executors.submit(handler);
    future.get();
    joinPoint.proceed(joinPoint.getArgs());
}
Also used : ConsistencyLevel(org.apache.cassandra.thrift.ConsistencyLevel) IMutation(org.apache.cassandra.db.IMutation) List(java.util.List) Around(org.aspectj.lang.annotation.Around)

Example 7 with ConsistencyLevel

use of org.apache.cassandra.thrift.ConsistencyLevel in project eiger by wlloyd.

the class CounterColumn method sendToOtherReplica.

private static void sendToOtherReplica(DecoratedKey key, ColumnFamily cf) throws UnavailableException, TimeoutException, IOException {
    RowMutation rm = new RowMutation(cf.metadata().ksName, key.key);
    rm.add(cf);
    final InetAddress local = FBUtilities.getBroadcastAddress();
    String localDataCenter = DatabaseDescriptor.getEndpointSnitch().getDatacenter(local);
    StorageProxy.performWrite(rm, ConsistencyLevel.ANY, localDataCenter, new StorageProxy.WritePerformer() {

        @Override
        public void apply(IMutation mutation, Collection<InetAddress> targets, IWriteResponseHandler responseHandler, String localDataCenter, ConsistencyLevel consistency_level) throws IOException, TimeoutException {
            // We should only send to the remote replica, not the local one
            targets.remove(local);
            // Fake local response to be a good lad but we won't wait on the responseHandler
            responseHandler.response(null);
            StorageProxy.sendToHintedEndpoints((RowMutation) mutation, targets, responseHandler, localDataCenter, consistency_level);
        }
    });
// we don't wait for answers
}
Also used : ConsistencyLevel(org.apache.cassandra.thrift.ConsistencyLevel) StorageProxy(org.apache.cassandra.service.StorageProxy) IWriteResponseHandler(org.apache.cassandra.service.IWriteResponseHandler) IOException(java.io.IOException) InetAddress(java.net.InetAddress) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

ConsistencyLevel (org.apache.cassandra.thrift.ConsistencyLevel)7 TException (org.apache.thrift.TException)4 PermanentStorageException (com.thinkaurelius.titan.diskstorage.PermanentStorageException)3 StorageException (com.thinkaurelius.titan.diskstorage.StorageException)3 TemporaryStorageException (com.thinkaurelius.titan.diskstorage.TemporaryStorageException)3 CTConnection (com.thinkaurelius.titan.diskstorage.cassandra.thrift.thriftpool.CTConnection)3 ByteBuffer (java.nio.ByteBuffer)3 List (java.util.List)3 Cassandra (org.apache.cassandra.thrift.Cassandra)3 InvalidRequestException (org.apache.cassandra.thrift.InvalidRequestException)3 SlicePredicate (org.apache.cassandra.thrift.SlicePredicate)3 UnavailableException (org.apache.cassandra.thrift.UnavailableException)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 StaticBuffer (com.thinkaurelius.titan.diskstorage.StaticBuffer)2 Entry (com.thinkaurelius.titan.diskstorage.keycolumnvalue.Entry)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 NoSuchElementException (java.util.NoSuchElementException)2 Column (org.apache.cassandra.thrift.Column)2 ColumnOrSuperColumn (org.apache.cassandra.thrift.ColumnOrSuperColumn)2