Search in sources :

Example 1 with RetryLimitReachedException

use of com.palantir.atlasdb.keyvalue.api.RetryLimitReachedException in project atlasdb by palantir.

the class CassandraKeyValueServiceImpl method deleteRows.

@Override
public void deleteRows(TableReference tableRef, Iterable<byte[]> rows) {
    Set<ByteBuffer> actualKeys = StreamSupport.stream(rows.spliterator(), false).map(ByteBuffer::wrap).collect(Collectors.toSet());
    if (actualKeys.isEmpty()) {
        return;
    }
    long timestamp = mutationTimestampProvider.getRemoveTimestamp();
    Map<ByteBuffer, Map<String, List<Mutation>>> mutationMap = KeyedStream.of(actualKeys).map(row -> new Deletion().setTimestamp(timestamp)).map(deletion -> new Mutation().setDeletion(deletion)).map(mutation -> keyMutationMapByColumnFamily(tableRef, mutation)).collectToMap();
    try {
        clientPool.runWithRetry(client -> {
            client.batch_mutate("deleteRows", mutationMap, DELETE_CONSISTENCY);
            return null;
        });
    } catch (RetryLimitReachedException e) {
        throw CassandraUtils.wrapInIceForDeleteOrRethrow(e);
    } catch (TException e) {
        throw Throwables.unwrapAndThrowAtlasDbDependencyException(e);
    }
}
Also used : Arrays(java.util.Arrays) AtlasDbDependencyException(com.palantir.common.exception.AtlasDbDependencyException) ListMultimap(com.google.common.collect.ListMultimap) Throwables(com.palantir.common.base.Throwables) CheckAndSetRequest(com.palantir.atlasdb.keyvalue.api.CheckAndSetRequest) Column(org.apache.cassandra.thrift.Column) Map(java.util.Map) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) CandidateCellForSweeping(com.palantir.atlasdb.keyvalue.api.CandidateCellForSweeping) ImmutableCandidateCellForSweepingRequest(com.palantir.atlasdb.keyvalue.api.ImmutableCandidateCellForSweepingRequest) AtlasDbConstants(com.palantir.atlasdb.AtlasDbConstants) Refreshable(com.palantir.refreshable.Refreshable) CassandraVerifierConfig(com.palantir.atlasdb.keyvalue.cassandra.CassandraVerifier.CassandraVerifierConfig) AnnotationType(com.palantir.atlasdb.util.AnnotationType) ColumnOrSuperColumn(org.apache.cassandra.thrift.ColumnOrSuperColumn) Cell(com.palantir.atlasdb.keyvalue.api.Cell) Set(java.util.Set) CloseableTracer(com.palantir.tracing.CloseableTracer) StandardCharsets(java.nio.charset.StandardCharsets) InsufficientConsistencyException(com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException) MetricsManagers(com.palantir.atlasdb.util.MetricsManagers) DriverInternalError(com.datastax.driver.core.exceptions.DriverInternalError) CASResult(org.apache.cassandra.thrift.CASResult) StartTsResultsCollector(com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueServices.StartTsResultsCollector) CheckAndSetException(com.palantir.atlasdb.keyvalue.api.CheckAndSetException) KeyAlreadyExistsException(com.palantir.atlasdb.keyvalue.api.KeyAlreadyExistsException) Cells(com.palantir.atlasdb.keyvalue.impl.Cells) AbstractKeyValueService(com.palantir.atlasdb.keyvalue.impl.AbstractKeyValueService) CheckAndSetResult(com.palantir.atlasdb.keyvalue.impl.CheckAndSetResult) Iterables(com.google.common.collect.Iterables) CassandraKeyValueServiceConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig) CassandraKeyValueServiceRuntimeConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceRuntimeConfig) KeyPredicate(org.apache.cassandra.thrift.KeyPredicate) Callable(java.util.concurrent.Callable) AsyncInitializer(com.palantir.async.initializer.AsyncInitializer) Supplier(java.util.function.Supplier) PtBytes(com.palantir.atlasdb.encoding.PtBytes) Multimaps(com.google.common.collect.Multimaps) ArrayList(java.util.ArrayList) ClusterAvailabilityStatus(com.palantir.atlasdb.keyvalue.api.ClusterAvailabilityStatus) StartupChecks(com.palantir.atlasdb.keyvalue.cassandra.CassandraClientPoolImpl.StartupChecks) Lists(com.google.common.collect.Lists) CassandraMutationTimestampProvider(com.palantir.atlasdb.cassandra.CassandraMutationTimestampProvider) CassandraMutationTimestampProviders(com.palantir.atlasdb.cassandra.CassandraMutationTimestampProviders) LoggingArgs(com.palantir.atlasdb.logging.LoggingArgs) Predicates(com.google.common.base.Predicates) StreamSupport(java.util.stream.StreamSupport) Nullable(javax.annotation.Nullable) Functions(com.google.common.base.Functions) FunctionCheckedException(com.palantir.common.base.FunctionCheckedException) RetryLimitReachedException(com.palantir.atlasdb.keyvalue.api.RetryLimitReachedException) TException(org.apache.thrift.TException) CandidateRowsForSweepingIterator(com.palantir.atlasdb.keyvalue.cassandra.sweep.CandidateRowsForSweepingIterator) TaggedMetricRegistry(com.palantir.tritium.metrics.registry.TaggedMetricRegistry) AnnotatedCallable(com.palantir.atlasdb.util.AnnotatedCallable) Pair(com.palantir.util.Pair) RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) Futures(com.google.common.util.concurrent.Futures) LocalRowColumnRangeIterator(com.palantir.atlasdb.keyvalue.impl.LocalRowColumnRangeIterator) RangeRequests(com.palantir.atlasdb.keyvalue.api.RangeRequests) SlicePredicates(com.palantir.atlasdb.keyvalue.cassandra.thrift.SlicePredicates) BatchColumnRangeSelection(com.palantir.atlasdb.keyvalue.api.BatchColumnRangeSelection) ClosableIterator(com.palantir.common.base.ClosableIterator) MutationMap(com.palantir.atlasdb.keyvalue.cassandra.thrift.MutationMap) LoggerFactory(org.slf4j.LoggerFactory) RowColumnRangeIterator(com.palantir.atlasdb.keyvalue.api.RowColumnRangeIterator) ByteBuffer(java.nio.ByteBuffer) TimestampRangeDelete(com.palantir.atlasdb.keyvalue.api.TimestampRangeDelete) KeyValueServices(com.palantir.atlasdb.keyvalue.impl.KeyValueServices) CheckAndSetCompatibility(com.palantir.atlasdb.keyvalue.api.CheckAndSetCompatibility) HashMultimap(com.google.common.collect.HashMultimap) MetricsManager(com.palantir.atlasdb.util.MetricsManager) CheckAndSetRunner(com.palantir.atlasdb.keyvalue.cassandra.cas.CheckAndSetRunner) Tracers(com.palantir.tracing.Tracers) Mutation(org.apache.cassandra.thrift.Mutation) CassandraServersConfig(com.palantir.atlasdb.cassandra.CassandraServersConfigs.CassandraServersConfig) LinkedListMultimap(com.google.common.collect.LinkedListMultimap) TableMetadata(com.palantir.atlasdb.table.description.TableMetadata) ImmutableSet(com.google.common.collect.ImmutableSet) IdentityHashMap(java.util.IdentityHashMap) CassandraServer(com.palantir.atlasdb.keyvalue.cassandra.pool.CassandraServer) ImmutableMap(com.google.common.collect.ImmutableMap) AbstractPagingIterable(com.palantir.util.paging.AbstractPagingIterable) KeyedStream(com.palantir.common.streams.KeyedStream) Collection(java.util.Collection) MetricRegistries(com.palantir.tritium.metrics.MetricRegistries) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ColumnSelection(com.palantir.atlasdb.keyvalue.api.ColumnSelection) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) ByteString(com.google.protobuf.ByteString) List(java.util.List) KsDef(org.apache.cassandra.thrift.KsDef) CandidateCellForSweepingRequest(com.palantir.atlasdb.keyvalue.api.CandidateCellForSweepingRequest) Range(com.palantir.atlasdb.keyvalue.cassandra.thrift.SlicePredicates.Range) Optional(java.util.Optional) Deletion(org.apache.cassandra.thrift.Deletion) AsyncKeyValueService(com.palantir.atlasdb.keyvalue.api.AsyncKeyValueService) ConsistencyLevel(org.apache.cassandra.thrift.ConsistencyLevel) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Limit(com.palantir.atlasdb.keyvalue.cassandra.thrift.SlicePredicates.Limit) AtlasDbMetrics(com.palantir.atlasdb.util.AtlasDbMetrics) HashMap(java.util.HashMap) Multimap(com.google.common.collect.Multimap) Iterators(com.google.common.collect.Iterators) HashSet(java.util.HashSet) SafeArg(com.palantir.logsafe.SafeArg) ImmutableList(com.google.common.collect.ImmutableList) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) RowGetter(com.palantir.atlasdb.keyvalue.cassandra.paging.RowGetter) ClosableIterators(com.palantir.common.base.ClosableIterators) ExecutorService(java.util.concurrent.ExecutorService) SlicePredicate(org.apache.cassandra.thrift.SlicePredicate) Logger(org.slf4j.Logger) Value(com.palantir.atlasdb.keyvalue.api.Value) Iterator(java.util.Iterator) IterablePartitioner(com.palantir.atlasdb.keyvalue.impl.IterablePartitioner) CassandraClusterConfig(com.palantir.atlasdb.keyvalue.cassandra.async.client.creation.ClusterFactory.CassandraClusterConfig) CfDef(org.apache.cassandra.thrift.CfDef) TokenBackedBasicResultsPage(com.palantir.util.paging.TokenBackedBasicResultsPage) Maps(com.google.common.collect.Maps) SetMultimap(com.google.common.collect.SetMultimap) PalantirRuntimeException(com.palantir.common.exception.PalantirRuntimeException) KeyValueService(com.palantir.atlasdb.keyvalue.api.KeyValueService) SimpleTokenBackedResultsPage(com.palantir.util.paging.SimpleTokenBackedResultsPage) CandidateRowForSweeping(com.palantir.atlasdb.keyvalue.cassandra.sweep.CandidateRowForSweeping) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Idempotent(com.palantir.common.annotation.Idempotent) Collections(java.util.Collections) Preconditions(com.palantir.logsafe.Preconditions) TException(org.apache.thrift.TException) RetryLimitReachedException(com.palantir.atlasdb.keyvalue.api.RetryLimitReachedException) Deletion(org.apache.cassandra.thrift.Deletion) Mutation(org.apache.cassandra.thrift.Mutation) ByteBuffer(java.nio.ByteBuffer) Map(java.util.Map) MutationMap(com.palantir.atlasdb.keyvalue.cassandra.thrift.MutationMap) IdentityHashMap(java.util.IdentityHashMap) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap)

Aggregations

DriverInternalError (com.datastax.driver.core.exceptions.DriverInternalError)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Functions (com.google.common.base.Functions)1 Predicates (com.google.common.base.Predicates)1 HashMultimap (com.google.common.collect.HashMultimap)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 Iterators (com.google.common.collect.Iterators)1 LinkedListMultimap (com.google.common.collect.LinkedListMultimap)1 ListMultimap (com.google.common.collect.ListMultimap)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Multimap (com.google.common.collect.Multimap)1 Multimaps (com.google.common.collect.Multimaps)1 SetMultimap (com.google.common.collect.SetMultimap)1 Sets (com.google.common.collect.Sets)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1