Search in sources :

Example 1 with Cells

use of com.palantir.atlasdb.keyvalue.impl.Cells in project atlasdb by palantir.

the class CassandraKeyValueServiceImpl method addGarbageCollectionSentinelValues.

/**
 * Adds a value with timestamp = Value.INVALID_VALUE_TIMESTAMP to each of the given cells. If
 * a value already exists at that time stamp, nothing is written for that cell.
 * <p>
 * Does not require all Cassandra nodes to be up and available, works as long as quorum is achieved.
 *
 * @param tableRef the name of the table to add the value to.
 * @param cells a set of cells to store the values in.
 */
@Override
public void addGarbageCollectionSentinelValues(TableReference tableRef, Iterable<Cell> cells) {
    try {
        final Value value = Value.create(PtBytes.EMPTY_BYTE_ARRAY, Value.INVALID_VALUE_TIMESTAMP);
        cellValuePutter.put("addGarbageCollectionSentinelValues", tableRef, Iterables.transform(cells, cell -> Maps.immutableEntry(cell, value)));
    } catch (Exception e) {
        throw QosAwareThrowables.unwrapAndThrowRateLimitExceededOrAtlasDbDependencyException(e);
    }
}
Also used : Arrays(java.util.Arrays) Throwables(com.palantir.common.base.Throwables) CheckAndSetRequest(com.palantir.atlasdb.keyvalue.api.CheckAndSetRequest) LeaderConfig(com.palantir.atlasdb.config.LeaderConfig) 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) ColumnGetter(com.palantir.atlasdb.keyvalue.cassandra.paging.ColumnGetter) AtlasDbConstants(com.palantir.atlasdb.AtlasDbConstants) ColumnOrSuperColumn(org.apache.cassandra.thrift.ColumnOrSuperColumn) AnnotationType(com.palantir.atlasdb.util.AnnotationType) Cell(com.palantir.atlasdb.keyvalue.api.Cell) Set(java.util.Set) InsufficientConsistencyException(com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException) Stream(java.util.stream.Stream) 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) Iterables(com.google.common.collect.Iterables) CassandraKeyValueServiceConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig) CassandraKeyValueServiceRuntimeConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceRuntimeConfig) Callable(java.util.concurrent.Callable) LockLeader(com.palantir.atlasdb.config.LockLeader) AsyncInitializer(com.palantir.async.initializer.AsyncInitializer) PtBytes(com.palantir.atlasdb.encoding.PtBytes) Builder(com.google.common.collect.ImmutableMap.Builder) Multimaps(com.google.common.collect.Multimaps) LinkedHashMap(java.util.LinkedHashMap) ClusterAvailabilityStatus(com.palantir.atlasdb.keyvalue.api.ClusterAvailabilityStatus) Lists(com.google.common.collect.Lists) LoggingArgs(com.palantir.atlasdb.logging.LoggingArgs) Predicates(com.google.common.base.Predicates) Functions(com.google.common.base.Functions) FunctionCheckedException(com.palantir.common.base.FunctionCheckedException) TException(org.apache.thrift.TException) QosClient(com.palantir.atlasdb.qos.QosClient) CandidateRowsForSweepingIterator(com.palantir.atlasdb.keyvalue.cassandra.sweep.CandidateRowsForSweepingIterator) AnnotatedCallable(com.palantir.atlasdb.util.AnnotatedCallable) RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) Preconditions(com.google.common.base.Preconditions) 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) LoggerFactory(org.slf4j.LoggerFactory) MutationMap(com.palantir.atlasdb.keyvalue.cassandra.thrift.MutationMap) Random(java.util.Random) RowColumnRangeIterator(com.palantir.atlasdb.keyvalue.api.RowColumnRangeIterator) ByteBuffer(java.nio.ByteBuffer) KeyValueServices(com.palantir.atlasdb.keyvalue.impl.KeyValueServices) HashMultimap(com.google.common.collect.HashMultimap) Mutation(org.apache.cassandra.thrift.Mutation) CassandraRangePagingIterable(com.palantir.atlasdb.keyvalue.cassandra.paging.CassandraRangePagingIterable) TableMetadata(com.palantir.atlasdb.table.description.TableMetadata) Function(com.google.common.base.Function) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) AbstractPagingIterable(com.palantir.util.paging.AbstractPagingIterable) Collection(java.util.Collection) QosAwareThrowables(com.palantir.atlasdb.qos.ratelimit.QosAwareThrowables) AutoDelegate(com.palantir.processors.AutoDelegate) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) ThriftColumnGetter(com.palantir.atlasdb.keyvalue.cassandra.paging.ThriftColumnGetter) Sets(com.google.common.collect.Sets) ColumnSelection(com.palantir.atlasdb.keyvalue.api.ColumnSelection) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) List(java.util.List) KsDef(org.apache.cassandra.thrift.KsDef) CandidateCellForSweepingRequest(com.palantir.atlasdb.keyvalue.api.CandidateCellForSweepingRequest) UnsafeArg(com.palantir.logsafe.UnsafeArg) Entry(java.util.Map.Entry) Range(com.palantir.atlasdb.keyvalue.cassandra.thrift.SlicePredicates.Range) Optional(java.util.Optional) Mutations(com.palantir.atlasdb.keyvalue.cassandra.thrift.Mutations) ConsistencyLevel(org.apache.cassandra.thrift.ConsistencyLevel) Limit(com.palantir.atlasdb.keyvalue.cassandra.thrift.SlicePredicates.Limit) AtlasDbMetrics(com.palantir.atlasdb.util.AtlasDbMetrics) Supplier(com.google.common.base.Supplier) Multimap(com.google.common.collect.Multimap) Iterators(com.google.common.collect.Iterators) FakeQosClient(com.palantir.atlasdb.qos.FakeQosClient) SafeArg(com.palantir.logsafe.SafeArg) ImmutableList(com.google.common.collect.ImmutableList) RowGetter(com.palantir.atlasdb.keyvalue.cassandra.paging.RowGetter) ClosableIterators(com.palantir.common.base.ClosableIterators) UnavailableException(org.apache.cassandra.thrift.UnavailableException) SlicePredicate(org.apache.cassandra.thrift.SlicePredicate) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Value(com.palantir.atlasdb.keyvalue.api.Value) IterablePartitioner(com.palantir.atlasdb.keyvalue.impl.IterablePartitioner) 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) SimpleTokenBackedResultsPage(com.palantir.util.paging.SimpleTokenBackedResultsPage) CandidateRowForSweeping(com.palantir.atlasdb.keyvalue.cassandra.sweep.CandidateRowForSweeping) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) Idempotent(com.palantir.common.annotation.Idempotent) Value(com.palantir.atlasdb.keyvalue.api.Value) InsufficientConsistencyException(com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException) CheckAndSetException(com.palantir.atlasdb.keyvalue.api.CheckAndSetException) KeyAlreadyExistsException(com.palantir.atlasdb.keyvalue.api.KeyAlreadyExistsException) FunctionCheckedException(com.palantir.common.base.FunctionCheckedException) TException(org.apache.thrift.TException) UnavailableException(org.apache.cassandra.thrift.UnavailableException) PalantirRuntimeException(com.palantir.common.exception.PalantirRuntimeException)

Example 2 with Cells

use of com.palantir.atlasdb.keyvalue.impl.Cells in project atlasdb by palantir.

the class CqlKeyValueService method addGarbageCollectionSentinelValues.

@Override
public void addGarbageCollectionSentinelValues(TableReference tableRef, Iterable<Cell> cells) {
    try {
        final Value value = Value.create(new byte[0], Value.INVALID_VALUE_TIMESTAMP);
        putInternal(tableRef, Iterables.transform(cells, cell -> Maps.immutableEntry(cell, value)), TransactionType.NONE);
    } catch (Throwable t) {
        throw Throwables.throwUncheckedException(t);
    }
}
Also used : PoolingOptions(com.datastax.driver.core.PoolingOptions) Arrays(java.util.Arrays) SSLContext(javax.net.ssl.SSLContext) Throwables(com.palantir.common.base.Throwables) ResultSetFuture(com.datastax.driver.core.ResultSetFuture) CheckAndSetRequest(com.palantir.atlasdb.keyvalue.api.CheckAndSetRequest) ConsistencyLevel(com.datastax.driver.core.ConsistencyLevel) Future(java.util.concurrent.Future) QueryOptions(com.datastax.driver.core.QueryOptions) Map(java.util.Map) TableReference(com.palantir.atlasdb.keyvalue.api.TableReference) CandidateCellForSweeping(com.palantir.atlasdb.keyvalue.api.CandidateCellForSweeping) AtlasDbConstants(com.palantir.atlasdb.AtlasDbConstants) AnnotationType(com.palantir.atlasdb.util.AnnotationType) Cell(com.palantir.atlasdb.keyvalue.api.Cell) Local(com.palantir.atlasdb.keyvalue.cassandra.CqlKeyValueServices.Local) TransactionType(com.palantir.atlasdb.keyvalue.cassandra.CqlKeyValueServices.TransactionType) Set(java.util.Set) Compression(com.datastax.driver.core.ProtocolOptions.Compression) NoHostAvailableException(com.datastax.driver.core.exceptions.NoHostAvailableException) InsufficientConsistencyException(com.palantir.atlasdb.keyvalue.api.InsufficientConsistencyException) Cluster(com.datastax.driver.core.Cluster) KeyAlreadyExistsException(com.palantir.atlasdb.keyvalue.api.KeyAlreadyExistsException) Cells(com.palantir.atlasdb.keyvalue.impl.Cells) Joiner(com.google.common.base.Joiner) AbstractKeyValueService(com.palantir.atlasdb.keyvalue.impl.AbstractKeyValueService) LoadBalancingPolicy(com.datastax.driver.core.policies.LoadBalancingPolicy) Iterables(com.google.common.collect.Iterables) CassandraKeyValueServiceConfig(com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig) Row(com.datastax.driver.core.Row) PtBytes(com.palantir.atlasdb.encoding.PtBytes) Builder(com.google.common.collect.ImmutableMap.Builder) Multimaps(com.google.common.collect.Multimaps) PreparedStatement(com.datastax.driver.core.PreparedStatement) ClusterAvailabilityStatus(com.palantir.atlasdb.keyvalue.api.ClusterAvailabilityStatus) Lists(com.google.common.collect.Lists) SslSocketFactories(com.palantir.remoting3.config.ssl.SslSocketFactories) Predicates(com.google.common.base.Predicates) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) Functions(com.google.common.base.Functions) UnsignedBytes(com.google.common.primitives.UnsignedBytes) AnnotatedCallable(com.palantir.atlasdb.util.AnnotatedCallable) ExecutionException(java.util.concurrent.ExecutionException) RowResult(com.palantir.atlasdb.keyvalue.api.RowResult) SSLOptions(com.datastax.driver.core.SSLOptions) GetCandidateCellsForSweepingShim(com.palantir.atlasdb.keyvalue.impl.GetCandidateCellsForSweepingShim) SortedSet(java.util.SortedSet) RoundRobinPolicy(com.datastax.driver.core.policies.RoundRobinPolicy) ClosableIterator(com.palantir.common.base.ClosableIterator) LoggerFactory(org.slf4j.LoggerFactory) ByteBuffer(java.nio.ByteBuffer) KeyValueServices(com.palantir.atlasdb.keyvalue.impl.KeyValueServices) HashMultimap(com.google.common.collect.HashMultimap) TreeMultimap(com.google.common.collect.TreeMultimap) Session(com.datastax.driver.core.Session) TokenAwarePolicy(com.datastax.driver.core.policies.TokenAwarePolicy) BatchStatement(com.datastax.driver.core.BatchStatement) ImmutableSet(com.google.common.collect.ImmutableSet) SortedSetMultimap(com.google.common.collect.SortedSetMultimap) ImmutableMap(com.google.common.collect.ImmutableMap) AbstractPagingIterable(com.palantir.util.paging.AbstractPagingIterable) Collection(java.util.Collection) NavigableMap(java.util.NavigableMap) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) AllTimestampsCollector(com.palantir.atlasdb.keyvalue.cassandra.CqlKeyValueServices.AllTimestampsCollector) ColumnSelection(com.palantir.atlasdb.keyvalue.api.ColumnSelection) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) List(java.util.List) Metadata(com.datastax.driver.core.Metadata) CandidateCellForSweepingRequest(com.palantir.atlasdb.keyvalue.api.CandidateCellForSweepingRequest) Host(com.datastax.driver.core.Host) InvalidQueryException(com.datastax.driver.core.exceptions.InvalidQueryException) Entry(java.util.Map.Entry) HostDistance(com.datastax.driver.core.HostDistance) Peer(com.palantir.atlasdb.keyvalue.cassandra.CqlKeyValueServices.Peer) SortedMap(java.util.SortedMap) Supplier(com.google.common.base.Supplier) Multimap(com.google.common.collect.Multimap) ResultSet(com.datastax.driver.core.ResultSet) BoundStatement(com.datastax.driver.core.BoundStatement) ImmutableList(com.google.common.collect.ImmutableList) ClosableIterators(com.palantir.common.base.ClosableIterators) SocketOptions(com.datastax.driver.core.SocketOptions) UnavailableException(com.datastax.driver.core.exceptions.UnavailableException) Logger(org.slf4j.Logger) Value(com.palantir.atlasdb.keyvalue.api.Value) StartTsResultsCollector(com.palantir.atlasdb.keyvalue.cassandra.CqlKeyValueServices.StartTsResultsCollector) IterablePartitioner(com.palantir.atlasdb.keyvalue.impl.IterablePartitioner) Visitor(com.palantir.common.visitor.Visitor) TokenBackedBasicResultsPage(com.palantir.util.paging.TokenBackedBasicResultsPage) Maps(com.google.common.collect.Maps) SetMultimap(com.google.common.collect.SetMultimap) Ordering(com.google.common.collect.Ordering) SimpleTokenBackedResultsPage(com.palantir.util.paging.SimpleTokenBackedResultsPage) WhiteListPolicy(com.datastax.driver.core.policies.WhiteListPolicy) Idempotent(com.palantir.common.annotation.Idempotent) LatencyAwarePolicy(com.datastax.driver.core.policies.LatencyAwarePolicy) Value(com.palantir.atlasdb.keyvalue.api.Value)

Aggregations

Functions (com.google.common.base.Functions)2 Predicates (com.google.common.base.Predicates)2 Supplier (com.google.common.base.Supplier)2 HashMultimap (com.google.common.collect.HashMultimap)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Builder (com.google.common.collect.ImmutableMap.Builder)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Iterables (com.google.common.collect.Iterables)2 Lists (com.google.common.collect.Lists)2 Maps (com.google.common.collect.Maps)2 Multimap (com.google.common.collect.Multimap)2 Multimaps (com.google.common.collect.Multimaps)2 SetMultimap (com.google.common.collect.SetMultimap)2 Sets (com.google.common.collect.Sets)2 AtlasDbConstants (com.palantir.atlasdb.AtlasDbConstants)2 CassandraKeyValueServiceConfig (com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig)2 PtBytes (com.palantir.atlasdb.encoding.PtBytes)2 CandidateCellForSweeping (com.palantir.atlasdb.keyvalue.api.CandidateCellForSweeping)2 CandidateCellForSweepingRequest (com.palantir.atlasdb.keyvalue.api.CandidateCellForSweepingRequest)2