From c44112a72dd42b4ac7d6c83a37351cc809eea16e Mon Sep 17 00:00:00 2001 From: Bobby Ullman Date: Wed, 30 Sep 2015 13:11:54 -0700 Subject: [PATCH] remove files that are no longer used --- .../CassandraExpiringKeyValueService.java | 134 ----------- .../transaction/impl/NullTransaction.java | 224 ------------------ .../impl/NullTransactionManager.java | 71 ------ 3 files changed, 429 deletions(-) delete mode 100644 atlasdb-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/CassandraExpiringKeyValueService.java delete mode 100644 atlasdb-client/src/main/java/com/palantir/atlasdb/transaction/impl/NullTransaction.java delete mode 100644 atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/transaction/impl/NullTransactionManager.java diff --git a/atlasdb-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/CassandraExpiringKeyValueService.java b/atlasdb-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/CassandraExpiringKeyValueService.java deleted file mode 100644 index 6f2cc09ac1a..00000000000 --- a/atlasdb-cassandra/src/main/java/com/palantir/atlasdb/keyvalue/cassandra/CassandraExpiringKeyValueService.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Copyright 2015 Palantir Technologies - * - * Licensed under the BSD-3 License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://opensource.org/licenses/BSD-3-Clause - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.palantir.atlasdb.keyvalue.cassandra; - -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.NavigableMap; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -import com.google.common.base.Function; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableSortedMap; -import com.google.common.collect.Lists; -import com.google.common.collect.Multimap; -import com.palantir.atlasdb.keyvalue.api.Cell; -import com.palantir.atlasdb.keyvalue.api.ExpiringKeyValueService; -import com.palantir.atlasdb.keyvalue.api.KeyAlreadyExistsException; -import com.palantir.atlasdb.keyvalue.api.Value; -import com.palantir.atlasdb.keyvalue.impl.Cells; -import com.palantir.atlasdb.keyvalue.impl.KeyValueServices; -import com.palantir.common.base.Throwables; -import com.palantir.common.collect.Maps2; - - -public class CassandraExpiringKeyValueService extends CassandraKeyValueService implements ExpiringKeyValueService{ - public CassandraExpiringKeyValueService(Set hosts, - int port, - int poolSize, - String keyspace, - boolean isSsl, - int replicationFactor, - int mutationBatchCount, - int mutationBatchSizeBytes, - int fetchBatchCount, - boolean safetyDisabled, - boolean autoRefreshNodes) { - super(hosts, port, poolSize, keyspace, isSsl, mutationBatchCount, mutationBatchSizeBytes, fetchBatchCount, safetyDisabled, autoRefreshNodes); - Preconditions.checkArgument(!hosts.isEmpty(), "hosts set was empty"); - - try { - initializeFromFreshInstance(containerPoolToUpdate.getCurrentHosts(), replicationFactor); - getPoolingManager().submitHostRefreshTask(); - } catch (Exception e) { - throw Throwables.throwUncheckedException(e); - } - } - - @Override - public void put(final String tableName, final Map values, final long timestamp, final long time, final TimeUnit unit) { - try { - putInternal(tableName, KeyValueServices.toConstantTimestampValues(values.entrySet(), timestamp), CassandraKeyValueServices.convertTtl(time, unit)); - } catch (Exception e) { - throw Throwables.throwUncheckedException(e); - } - } - - @Override - public void putWithTimestamps(String tableName, Multimap values, final long time, final TimeUnit unit) { - try { - putInternal(tableName, values.entries(), CassandraKeyValueServices.convertTtl(time, unit)); - } catch (Exception e) { - throw Throwables.throwUncheckedException(e); - } - } - - @Override - public void multiPut(Map> valuesByTable, final long timestamp, final long time, final TimeUnit unit) throws KeyAlreadyExistsException { - List> callables = Lists.newArrayList(); - for (Entry> e : valuesByTable.entrySet()) { - final String table = e.getKey(); - // We sort here because some key value stores are more efficient if you store adjacent keys together. - NavigableMap sortedMap = ImmutableSortedMap.copyOf(e.getValue()); - - - Iterable>> partitions = partitionByCountAndBytes(sortedMap.entrySet(), - getMultiPutBatchCount(), getMultiPutBatchSizeBytes(), table, new Function, Long>(){ - - @Override - public Long apply(Entry entry) { - long totalSize = 0; - totalSize += entry.getValue().length; - totalSize += Cells.getApproxSizeOfCell(entry.getKey()); - return totalSize; - }}); - - - for (final List> p : partitions) { - callables.add(new Callable() { - @Override - public Void call() { - Thread.currentThread().setName("AtlasDB expiry multiPut of " + p.size() + " cells into " + table); - put(table, Maps2.fromEntries(p), timestamp, time, unit); - return null; - } - }); - } - } - - List> futures; - try { - futures = executor.invokeAll(callables); - } catch (InterruptedException e) { - throw Throwables.throwUncheckedException(e); - } - for (Future future : futures) { - try { - future.get(); - } catch (InterruptedException e) { - throw Throwables.throwUncheckedException(e); - } catch (ExecutionException e) { - throw Throwables.rewrapAndThrowUncheckedException(e.getCause()); - } - } - } - -} diff --git a/atlasdb-client/src/main/java/com/palantir/atlasdb/transaction/impl/NullTransaction.java b/atlasdb-client/src/main/java/com/palantir/atlasdb/transaction/impl/NullTransaction.java deleted file mode 100644 index 01f832fecdc..00000000000 --- a/atlasdb-client/src/main/java/com/palantir/atlasdb/transaction/impl/NullTransaction.java +++ /dev/null @@ -1,224 +0,0 @@ -/** - * Copyright 2015 Palantir Technologies - * - * Licensed under the BSD-3 License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://opensource.org/licenses/BSD-3-Clause - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.palantir.atlasdb.transaction.impl; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.SortedMap; - -import org.apache.commons.lang.Validate; - -import com.google.common.base.Function; -import com.google.common.base.Functions; -import com.google.common.base.Predicates; -import com.google.common.collect.AbstractIterator; -import com.google.common.collect.ImmutableSortedMap; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.primitives.UnsignedBytes; -import com.palantir.atlasdb.keyvalue.api.Cell; -import com.palantir.atlasdb.keyvalue.api.ColumnSelection; -import com.palantir.atlasdb.keyvalue.api.KeyValueService; -import com.palantir.atlasdb.keyvalue.api.RangeRequest; -import com.palantir.atlasdb.keyvalue.api.RowResult; -import com.palantir.atlasdb.keyvalue.api.Value; -import com.palantir.atlasdb.keyvalue.impl.Cells; -import com.palantir.atlasdb.keyvalue.impl.RowResults; -import com.palantir.atlasdb.transaction.api.ConstraintCheckable; -import com.palantir.common.base.AbstractBatchingVisitable; -import com.palantir.common.base.BatchingVisitable; -import com.palantir.common.base.BatchingVisitableFromIterable; -import com.palantir.common.base.ClosableIterator; -import com.palantir.common.collect.IterableView; -import com.palantir.common.collect.MapEntries; -import com.palantir.util.paging.TokenBackedBasicResultsPage; - -/** - * Transaction implementation that directly delegates to the underlying - * key-value service (i.e., provides no transactionality or isolation - * guarantees). - *

- * Intended to be used for benchmarking. - */ -public class NullTransaction extends AbstractTransaction { - private static final int BATCH_SIZE_GET_FIRST_PAGE = 1000; - - private final KeyValueService service; - private final long timeStamp; - private final boolean isReadOnly; - - public NullTransaction(KeyValueService service, long timestamp, boolean isReadOnly) { - this.service = service; - this.timeStamp = timestamp; - this.isReadOnly = isReadOnly; - } - - @Override - public SortedMap> getRows(String tableName, Iterable rows, - ColumnSelection columnSelection) { - Map ret = unwrap(service.getRows(tableName, rows, columnSelection, - timeStamp+1)); - return RowResults.viewOfSortedMap(Cells.breakCellsUpByRow(ret)); - } - - @Override - public Map get(String tableName, Set cells) { - return unwrap(service.get(tableName, Cells.constantValueMap(cells, timeStamp+1))); - } - - @Override - public void put(String tableName, Map values) { - Validate.isTrue(!isReadOnly); - service.put(tableName, values, timeStamp); - } - - private Iterator> transformResults(final Iterator> it) { - return new AbstractIterator>() { - @Override - protected RowResult computeNext() { - while (true) { - if (!it.hasNext()) { - return endOfData(); - } - RowResult result = it.next(); - Function, byte[]> compose = Functions.compose(Value.GET_VALUE, MapEntries.getValueFunction()); - IterableView.of(result.getColumns().entrySet()) - .transform(compose); - - Map columns = Maps.filterValues( - Maps.transformValues(result.getColumns(), Value.GET_VALUE), - Predicates.not(Value.IS_EMPTY)); - - ImmutableSortedMap sortedColumns = ImmutableSortedMap.copyOf(columns, UnsignedBytes.lexicographicalComparator()); - if (sortedColumns.isEmpty()) { - continue; - } - return RowResult.create(result.getRowName(), sortedColumns); - } - } - }; - } - - @Override - public Iterable>> getRanges(final String tableName, - Iterable rangeRequests) { - return Iterables.concat(Iterables.transform( - Iterables.partition(rangeRequests, BATCH_SIZE_GET_FIRST_PAGE), - new Function, List>>>() { - @Override - public List>> apply(final List input) { - final Map, byte[]>> firstBatchForRanges = - service.getFirstBatchForRanges( - tableName, - input, - timeStamp + 1); - List>> ret = Lists.newArrayListWithCapacity(input.size()); - for (final RangeRequest range : input) { - ret.add(new AbstractBatchingVisitable>() { - @Override - protected void batchAcceptSizeHint(int batchSizeHint, - ConsistentVisitor, K> v) - throws K { - TokenBackedBasicResultsPage, byte[]> page = firstBatchForRanges.get(range); - List> firstPage = page.getResults(); - Iterator> rowResults = transformResults(firstPage.iterator()); - while (rowResults.hasNext()) { - if (!v.visitOne(rowResults.next())) { - return; - } - } - if (!page.moreResultsAvailable()) { - return; - } - RangeRequest newRange = range.getBuilder().startRowInclusive( - page.getTokenForNextPage()).build(); - getRange(tableName, newRange).batchAccept(batchSizeHint, v); - } - }); - } - return ret; - } - })); - } - - @Override - public BatchingVisitable> getRange(final String tableName, - final RangeRequest request) { - return new AbstractBatchingVisitable>() { - @Override - public void batchAcceptSizeHint(int batchSizeHint, - ConsistentVisitor, K> v) throws K { - if (request.getBatchHint() != null) { - batchSizeHint = request.getBatchHint(); - } - ClosableIterator> range = service.getRange(tableName, request.withBatchHint(batchSizeHint), timeStamp+1); - try { - Iterator> transform = transformResults(range); - BatchingVisitableFromIterable.create(transform).batchAccept(1, v); - } finally { - range.close(); - } - } - }; - } - - @Override - public void commit() { - dropTempTables(); - } - - @Override - public void abort() { - dropTempTables(); - } - - @Override - public long getTimestamp() { - return timeStamp; - } - - @Override - public boolean isAborted() { - return false; - } - - @Override - public boolean isUncommitted() { - return false; - } - - private Map unwrap(Map kvs) { - Map r = Maps.newHashMap(); - for (Map.Entry e : kvs.entrySet()) { - r.put(e.getKey(), e.getValue().getContents()); - } - return r; - } - - @Override - public void useTable(String tableName, ConstraintCheckable table) { - /**/ - } - - @Override - protected KeyValueService getKeyValueService() { - return service; - } -} diff --git a/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/transaction/impl/NullTransactionManager.java b/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/transaction/impl/NullTransactionManager.java deleted file mode 100644 index 255027b94f2..00000000000 --- a/atlasdb-impl-shared/src/main/java/com/palantir/atlasdb/transaction/impl/NullTransactionManager.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright 2015 Palantir Technologies - * - * Licensed under the BSD-3 License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://opensource.org/licenses/BSD-3-Clause - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.palantir.atlasdb.transaction.impl; - -import com.palantir.atlasdb.keyvalue.api.KeyValueService; -import com.palantir.atlasdb.transaction.api.AtlasDbConstraintCheckingMode; -import com.palantir.atlasdb.transaction.api.LockAwareTransactionTask; -import com.palantir.atlasdb.transaction.api.LockAwareTransactionTasks; -import com.palantir.atlasdb.transaction.api.Transaction; -import com.palantir.atlasdb.transaction.api.TransactionFailedRetriableException; -import com.palantir.atlasdb.transaction.api.TransactionTask; -import com.palantir.lock.LockRefreshToken; -import com.palantir.lock.LockService; -import com.palantir.timestamp.TimestampService; - -public class NullTransactionManager extends AbstractLockAwareTransactionManager { - final KeyValueService service; - final TimestampService timeService; - final AtlasDbConstraintCheckingMode constraintCheckingMode; - - public NullTransactionManager(KeyValueService service, TimestampService time, AtlasDbConstraintCheckingMode constraintCheckingMode) { - this.service = service; - this.timeService = time; - this.constraintCheckingMode = constraintCheckingMode; - } - - @Override - public T runTaskReadOnly(TransactionTask task) throws E { - Transaction t = new NullTransaction(service, timeService.getFreshTimestamp(), false); - return runTaskThrowOnConflict(task, new UnmodifiableTransaction(t) { - @Override public void abort() {/* do nothing */} - @Override public void commit() {/* do nothing */} - }); - } - - @Override - public long getImmutableTimestamp() { - return timeService.getFreshTimestamp(); - } - - @Override - public long getUnreadableTimestamp() { - return timeService.getFreshTimestamp(); - } - - @Override - public LockService getLockService() { - return null; - } - - @Override - public T runTaskWithLocksThrowOnConflict(Iterable lockTokens, - LockAwareTransactionTask task) - throws E, TransactionFailedRetriableException { - Transaction t = new NullTransaction(service, timeService.getFreshTimestamp(), false); - return runTaskThrowOnConflict(LockAwareTransactionTasks.asLockUnaware(task), t); - } -}