Search in sources :

Example 16 with RowMutationEntry

use of com.google.cloud.bigtable.data.v2.models.RowMutationEntry in project java-bigtable by googleapis.

the class MutateRowsBatchingDescriptor method splitException.

/**
 * Marks the entry future with received {@link Throwable}.
 *
 * <p>In case throwable is {@link MutateRowsException}, then it only sets throwable for the
 * entries whose index is mentioned {@link MutateRowsException#getFailedMutations()}.
 */
@Override
public void splitException(Throwable throwable, List<BatchEntry<RowMutationEntry, Void>> entries) {
    if (!(throwable instanceof MutateRowsException)) {
        for (BatchEntry<RowMutationEntry, Void> entry : entries) {
            entry.getResultFuture().setException(throwable);
        }
        return;
    }
    List<FailedMutation> failedMutations = ((MutateRowsException) throwable).getFailedMutations();
    Map<Integer, Throwable> entryErrors = Maps.newHashMap();
    for (FailedMutation failure : failedMutations) {
        entryErrors.put(failure.getIndex(), failure.getError());
    }
    int i = 0;
    for (BatchEntry<RowMutationEntry, Void> entry : entries) {
        Throwable entryError = entryErrors.get(i++);
        if (entryError == null) {
            entry.getResultFuture().set(null);
        } else {
            entry.getResultFuture().setException(entryError);
        }
    }
}
Also used : MutateRowsException(com.google.cloud.bigtable.data.v2.models.MutateRowsException) RowMutationEntry(com.google.cloud.bigtable.data.v2.models.RowMutationEntry) FailedMutation(com.google.cloud.bigtable.data.v2.models.MutateRowsException.FailedMutation)

Aggregations

RowMutationEntry (com.google.cloud.bigtable.data.v2.models.RowMutationEntry)16 Test (org.junit.Test)11 ByteString (com.google.protobuf.ByteString)3 BatcherImpl (com.google.api.gax.batching.BatcherImpl)2 BigtableDataClient (com.google.cloud.bigtable.data.v2.BigtableDataClient)2 BulkMutation (com.google.cloud.bigtable.data.v2.models.BulkMutation)2 MutateRowsException (com.google.cloud.bigtable.data.v2.models.MutateRowsException)2 Row (com.google.cloud.bigtable.data.v2.models.Row)2 BulkMutationWrapper (com.google.cloud.bigtable.hbase.wrappers.BulkMutationWrapper)2 ExecutionException (java.util.concurrent.ExecutionException)2 Put (org.apache.hadoop.hbase.client.Put)2 BatchingDescriptor (com.google.api.gax.batching.BatchingDescriptor)1 BatchingSettings (com.google.api.gax.batching.BatchingSettings)1 FlowControlEventStats (com.google.api.gax.batching.FlowControlEventStats)1 FlowControlSettings (com.google.api.gax.batching.FlowControlSettings)1 GrpcCallContext (com.google.api.gax.grpc.GrpcCallContext)1 DeadlineExceededException (com.google.api.gax.rpc.DeadlineExceededException)1 UnaryCallable (com.google.api.gax.rpc.UnaryCallable)1 UnavailableException (com.google.api.gax.rpc.UnavailableException)1 Table (com.google.cloud.bigtable.admin.v2.models.Table)1