Search in sources :

Example 36 with AtomicSupport

use of com.cinchapi.concourse.server.storage.AtomicSupport in project concourse by cinchapi.

the class ConcourseServer method countKeyCclTime.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public long countKeyCclTime(String key, String ccl, long timestamp, 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);
        return Operations.countKeyRecordsAtomic(key, records, timestamp, atomic);
    });
}
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 37 with AtomicSupport

use of com.cinchapi.concourse.server.storage.AtomicSupport in project concourse by cinchapi.

the class ConcourseServer method addKeyValue.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public long addKeyValue(String key, TObject value, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AtomicSupport store = getStore(transaction, environment);
    return AtomicOperations.supplyWithRetry(store, (atomic) -> {
        long record = Time.now();
        Operations.addIfEmptyAtomic(key, value, record, atomic);
        return record;
    });
}
Also used : AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) VerifyWritePermission(com.cinchapi.concourse.server.aop.VerifyWritePermission) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 38 with AtomicSupport

use of com.cinchapi.concourse.server.storage.AtomicSupport in project concourse by cinchapi.

the class ConcourseServer method getCclOrderPage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, TObject>> getCclOrderPage(String ccl, TOrder order, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AbstractSyntaxTree ast = compiler.parse(ccl);
    AtomicSupport store = getStore(transaction, environment);
    Supplier<SortableTable<TObject>> supplier = () -> SortableTable.singleValued(new LinkedHashMap<>());
    return AtomicOperations.supplyWithRetry(store, atomic -> Operations.getAstAtomic(atomic, 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 39 with AtomicSupport

use of com.cinchapi.concourse.server.storage.AtomicSupport in project concourse by cinchapi.

the class ConcourseServer method insertJsonRecord.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public boolean insertJsonRecord(String json, long record, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AtomicSupport store = getStore(transaction, environment);
    try {
        Multimap<String, Object> data = Convert.jsonToJava(json);
        AtomicOperation atomic = store.startAtomicOperation();
        List<DeferredWrite> deferred = Lists.newArrayList();
        return Operations.insertAtomic(data, record, atomic, deferred) && Operations.insertDeferredAtomic(deferred, atomic) && atomic.commit(CommitVersions.next());
    } catch (TransactionStateException e) {
        throw new TransactionException();
    } catch (AtomicStateException e) {
        return false;
    }
}
Also used : TransactionException(com.cinchapi.concourse.thrift.TransactionException) AtomicOperation(com.cinchapi.concourse.server.storage.AtomicOperation) TransactionStateException(com.cinchapi.concourse.server.storage.TransactionStateException) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) AtomicStateException(com.cinchapi.concourse.server.storage.AtomicStateException) ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) VerifyWritePermission(com.cinchapi.concourse.server.aop.VerifyWritePermission) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 40 with AtomicSupport

use of com.cinchapi.concourse.server.storage.AtomicSupport in project concourse by cinchapi.

the class ConcourseServer method selectKeyCriteriaOrderPage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Set<TObject>> selectKeyCriteriaOrderPage(String key, 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<SortableColumn<Set<TObject>>> supplier = () -> SortableColumn.multiValued(key, new LinkedHashMap<>());
    return AtomicOperations.supplyWithRetry(store, atomic -> Operations.selectKeyAstAtomic(atomic, key, ast, 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) SortableColumn(com.cinchapi.concourse.data.sort.SortableColumn) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Aggregations

AtomicSupport (com.cinchapi.concourse.server.storage.AtomicSupport)192 TranslateClientExceptions (com.cinchapi.concourse.server.aop.TranslateClientExceptions)179 VerifyAccessToken (com.cinchapi.concourse.server.aop.VerifyAccessToken)179 VerifyReadPermission (com.cinchapi.concourse.server.aop.VerifyReadPermission)157 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)120 TObject (com.cinchapi.concourse.thrift.TObject)101 ComplexTObject (com.cinchapi.concourse.thrift.ComplexTObject)96 SortableTable (com.cinchapi.concourse.data.sort.SortableTable)87 Set (java.util.Set)78 VerifyWritePermission (com.cinchapi.concourse.server.aop.VerifyWritePermission)76 SortableSet (com.cinchapi.concourse.data.sort.SortableSet)73 SortableColumn (com.cinchapi.concourse.data.sort.SortableColumn)72 Map (java.util.Map)62 AtomicOperation (com.cinchapi.concourse.server.storage.AtomicOperation)60 AtomicReference (java.util.concurrent.atomic.AtomicReference)59 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