@@ -0,0 +1,3290 @@
+/**%0A * Copyright 2015 Palantir Technologies%0A *%0A * Licensed under the BSD-3 License (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://opensource.org/licenses/BSD-3-Clause%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.palantir.atlasdb.transaction.impl;%0A%0Aimport java.util.Map;%0Aimport java.util.Set;%0Aimport java.util.SortedMap;%0A%0Aimport com.palantir.atlasdb.keyvalue.api.Cell;%0Aimport com.palantir.atlasdb.keyvalue.api.ColumnSelection;%0Aimport com.palantir.atlasdb.keyvalue.api.RangeRequest;%0Aimport com.palantir.atlasdb.keyvalue.api.RowResult;%0Aimport com.palantir.atlasdb.protos.generated.TableMetadataPersistence.SweepStrategy;%0Aimport com.palantir.atlasdb.transaction.api.Transaction;%0Aimport com.palantir.common.base.BatchingVisitable;%0A%0Apublic class ReadTransaction extends ForwardingTransaction %7B%0A%0A    private final AbstractTransaction delegate;%0A    private final SweepStrategyManager sweepStrategies;%0A%0A    public ReadTransaction(AbstractTransaction delegate, SweepStrategyManager sweepStrategies) %7B%0A        this.delegate = delegate;%0A        this.sweepStrategies = sweepStrategies;%0A    %7D%0A%0A    @Override%0A    public Transaction delegate() %7B%0A        return delegate;%0A    %7D%0A%0A    @Override%0A    public SortedMap%3Cbyte%5B%5D, RowResult%3Cbyte%5B%5D%3E%3E getRows(String tableName,%0A                                                        Iterable%3Cbyte%5B%5D%3E rows,%0A                                                        ColumnSelection columnSelection) %7B%0A        checkTableName(tableName);%0A        return delegate().getRows(tableName, rows, columnSelection);%0A    %7D%0A%0A    @Override%0A    public Map%3CCell, byte%5B%5D%3E get(String tableName, Set%3CCell%3E cells) %7B%0A        checkTableName(tableName);%0A        return delegate().get(tableName, cells);%0A    %7D%0A%0A    @Override%0A    public BatchingVisitable%3CRowResult%3Cbyte%5B%5D%3E%3E getRange(String tableName, RangeRequest rangeRequest) %7B%0A        checkTableName(tableName);%0A        return delegate().getRange(tableName, rangeRequest);%0A    %7D%0A%0A    @Override%0A    public Iterable%3CBatchingVisitable%3CRowResult%3Cbyte%5B%5D%3E%3E%3E getRanges(String tableName,%0A                                                                    Iterable%3CRangeRequest%3E rangeRequests) %7B%0A        checkTableName(tableName);%0A        return delegate().getRanges(tableName, rangeRequests);%0A    %7D%0A%0A    private void checkTableName(String tableName) %7B%0A        SweepStrategy sweepStrategy = sweepStrategies.get().get(tableName);%0A        if (sweepStrategy == SweepStrategy.THOROUGH) %7B%0A            throw new IllegalStateException(%22Cannot read from a table with a thorough sweep strategy in a read only transaction.%22);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void put(String tableName, Map%3CCell, byte%5B%5D%3E values) %7B%0A        throw new IllegalArgumentException(%22This is a read only transaction.%22);%0A    %7D%0A%0A    @Override%0A    public void delete(String tableName, Set%3CCell%3E keys) %7B%0A        throw new IllegalArgumentException(%22This is a read only transaction.%22);%0A    %7D%0A%0A%7D%0A

add ReadTransaction