Package com.netflix.astyanax

Examples of com.netflix.astyanax.WriteAheadLog


    @Override
    public MutationBatch prepareMutationBatch() {
        return new AbstractThriftMutationBatchImpl(config.getClock(), config.getDefaultWriteConsistencyLevel(), config.getRetryPolicy().duplicate()) {
            @Override
            public OperationResult<Void> execute() throws ConnectionException {
                WriteAheadLog wal = getWriteAheadLog();
                WriteAheadEntry walEntry = null;
                if (wal != null) {
                    walEntry = wal.createEntry();
                    walEntry.writeMutation(this);
                }
                try {
                    OperationResult<Void> result = executeOperation(
                            new AbstractKeyspaceOperationImpl<Void>(
                                    tracerFactory.newTracer(useAtomicBatch() ? CassandraOperationType.ATOMIC_BATCH_MUTATE : CassandraOperationType.BATCH_MUTATE),
                                                            getPinnedHost(),
                                                            getKeyspaceName()) {
                                @Override
                                public Void internalExecute(Client client, ConnectionContext context) throws Exception {
                                    // Mutation can be atomic or non-atomic.
                                    // see http://www.datastax.com/dev/blog/atomic-batches-in-cassandra-1-2 for details on atomic batches
                                    if (useAtomicBatch()) {
                                        client.atomic_batch_mutate(getMutationMap(),
                                                ThriftConverter.ToThriftConsistencyLevel(getConsistencyLevel()));
                                    } else {
                                        client.batch_mutate(getMutationMap(),
                                                ThriftConverter.ToThriftConsistencyLevel(getConsistencyLevel()));
                                    }
                                    discardMutations();
                                    return null;
                                }

                                @Override
                                public ByteBuffer getRowKey() {
                                    if (getMutationMap().size() == 1)
                                        return getMutationMap().keySet().iterator().next();
                                    else
                                        return null;
                                }
                            }, getRetryPolicy());

                    if (walEntry != null) {
                        wal.removeEntry(walEntry);
                    }
                    return result;
                }
                catch (ConnectionException exception) {
                    throw exception;
View Full Code Here

TOP

Related Classes of com.netflix.astyanax.WriteAheadLog

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.