Search in sources :

Example 56 with TranslateClientExceptions

use of com.cinchapi.concourse.server.aop.TranslateClientExceptions in project concourse by cinchapi.

the class ConcourseServer method getKeysCriteriaOrderPage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, TObject>> getKeysCriteriaOrderPage(List<String> keys, TCriteria criteria, TOrder order, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AbstractSyntaxTree ast = compiler.parse(criteria);
    AtomicSupport store = getStore(transaction, environment);
    Supplier<SortableTable<TObject>> supplier = () -> SortableTable.singleValued(new LinkedHashMap<>());
    return AtomicOperations.supplyWithRetry(store, atomic -> Operations.getKeysAstAtomic(atomic, keys, ast, Orders.from(order), Pages.from(page), supplier));
}
Also used : AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) SortableTable(com.cinchapi.concourse.data.sort.SortableTable) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 57 with TranslateClientExceptions

use of com.cinchapi.concourse.server.aop.TranslateClientExceptions in project concourse by cinchapi.

the class ConcourseServer method maxKeyCcl.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public TObject maxKeyCcl(String key, String ccl, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AbstractSyntaxTree ast = compiler.parse(ccl);
    AtomicSupport store = getStore(transaction, environment);
    return AtomicOperations.supplyWithRetry(store, (atomic) -> {
        Set<Long> records = ast.accept(Finder.instance(), atomic);
        Number max = Operations.maxKeyRecordsAtomic(key, records, Time.NONE, atomic);
        return Convert.javaToThrift(max);
    });
}
Also used : AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 58 with TranslateClientExceptions

use of com.cinchapi.concourse.server.aop.TranslateClientExceptions in project concourse by cinchapi.

the class ConcourseServer method selectCclTimeOrderPage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectCclTimeOrderPage(String ccl, long timestamp, TOrder order, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AbstractSyntaxTree ast = compiler.parse(ccl);
    AtomicSupport store = getStore(transaction, environment);
    Supplier<SortableTable<Set<TObject>>> supplier = () -> emptySortableResultDataset();
    return AtomicOperations.supplyWithRetry(store, atomic -> Operations.selectAstOptionalAtomic(atomic, ast, timestamp, Orders.from(order), Pages.from(page), supplier));
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) SortableTable(com.cinchapi.concourse.data.sort.SortableTable) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 59 with TranslateClientExceptions

use of com.cinchapi.concourse.server.aop.TranslateClientExceptions in project concourse by cinchapi.

the class ConcourseServer method findOrAddKeyValue.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public long findOrAddKeyValue(String key, TObject value, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AtomicSupport store = getStore(transaction, environment);
    Set<Long> records = Sets.newLinkedHashSetWithExpectedSize(1);
    AtomicOperations.executeWithRetry(store, (atomic) -> {
        records.clear();
        records.addAll(atomic.find(key, Operator.EQUALS, value));
        if (records.isEmpty()) {
            long record = Time.now();
            Operations.addIfEmptyAtomic(key, value, record, atomic);
            records.add(record);
        }
    });
    if (records.size() == 1) {
        return Iterables.getOnlyElement(records);
    } else {
        throw new DuplicateEntryException(AnyStrings.joinWithSpace("Found", records.size(), "records that match", key, "=", value));
    }
}
Also used : AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) DuplicateEntryException(com.cinchapi.concourse.thrift.DuplicateEntryException) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 60 with TranslateClientExceptions

use of com.cinchapi.concourse.server.aop.TranslateClientExceptions in project concourse by cinchapi.

the class ConcourseServer method pingRecords.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Boolean> pingRecords(List<Long> records, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AtomicSupport store = getStore(transaction, environment);
    Map<Long, Boolean> result = Maps.newLinkedHashMap();
    AtomicOperations.executeWithRetry(store, (atomic) -> {
        for (long record : records) {
            result.put(record, Operations.ping(record, atomic));
        }
    });
    return result;
}
Also used : AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Aggregations

TranslateClientExceptions (com.cinchapi.concourse.server.aop.TranslateClientExceptions)180 VerifyAccessToken (com.cinchapi.concourse.server.aop.VerifyAccessToken)180 AtomicSupport (com.cinchapi.concourse.server.storage.AtomicSupport)179 VerifyReadPermission (com.cinchapi.concourse.server.aop.VerifyReadPermission)157 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)120 ComplexTObject (com.cinchapi.concourse.thrift.ComplexTObject)96 TObject (com.cinchapi.concourse.thrift.TObject)96 SortableTable (com.cinchapi.concourse.data.sort.SortableTable)87 VerifyWritePermission (com.cinchapi.concourse.server.aop.VerifyWritePermission)76 SortableSet (com.cinchapi.concourse.data.sort.SortableSet)73 Set (java.util.Set)73 SortableColumn (com.cinchapi.concourse.data.sort.SortableColumn)72 Map (java.util.Map)58 NonBlockingHashMap (org.cliffc.high_scale_lib.NonBlockingHashMap)58 AtomicStateException (com.cinchapi.concourse.server.storage.AtomicStateException)57 TransactionStateException (com.cinchapi.concourse.server.storage.TransactionStateException)57 Diff (com.cinchapi.concourse.thrift.Diff)57 TransactionException (com.cinchapi.concourse.thrift.TransactionException)57 AtomicReference (java.util.concurrent.atomic.AtomicReference)57 AtomicOperation (com.cinchapi.concourse.server.storage.AtomicOperation)56