Search in sources :

Example 76 with AtomicSupport

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

the class ConcourseServer method getKeysRecord.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<String, TObject> getKeysRecord(List<String> keys, long record, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AtomicSupport store = getStore(transaction, environment);
    return AtomicOperations.supplyWithRetry(store, atomic -> {
        Map<String, Set<TObject>> selected = Stores.select(atomic, keys, record);
        Map<String, TObject> data = new LinkedHashMap<>(selected.size());
        for (Entry<String, Set<TObject>> entry : selected.entrySet()) {
            Set<TObject> values = entry.getValue();
            if (!values.isEmpty()) {
                data.put(entry.getKey(), Iterables.getLast(values));
            }
        }
        return data;
    });
}
Also used : ComplexTObject(com.cinchapi.concourse.thrift.ComplexTObject) TObject(com.cinchapi.concourse.thrift.TObject) SortableSet(com.cinchapi.concourse.data.sort.SortableSet) Set(java.util.Set) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) LinkedHashMap(java.util.LinkedHashMap) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) VerifyReadPermission(com.cinchapi.concourse.server.aop.VerifyReadPermission) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 77 with AtomicSupport

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

the class ConcourseServer method selectKeysCclOrderPage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectKeysCclOrderPage(List<String> keys, 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<Set<TObject>>> supplier = () -> emptySortableResultDataset();
    return AtomicOperations.supplyWithRetry(store, atomic -> Operations.selectKeysAstAtomic(atomic, keys, 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) 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 78 with AtomicSupport

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

the class ConcourseServer method revertKeyRecordsTime.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public void revertKeyRecordsTime(String key, List<Long> records, long timestamp, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AtomicSupport store = getStore(transaction, environment);
    AtomicOperations.executeWithRetry(store, (atomic) -> {
        for (long record : records) {
            Operations.revertAtomic(key, record, timestamp, atomic);
        }
    });
}
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 79 with AtomicSupport

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

the class ConcourseServer method findOrInsertCclJson.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public long findOrInsertCclJson(String ccl, String json, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    List<Multimap<String, Object>> objects = Lists.newArrayList(Convert.jsonToJava(json));
    AtomicSupport store = getStore(transaction, environment);
    Set<Long> records = Sets.newLinkedHashSet();
    AtomicOperations.executeWithRetry(store, (atomic) -> {
        records.clear();
        AbstractSyntaxTree ast;
        if (objects.size() == 1) {
            // CON-321: Support local resolution when the data blob is a
            // single object
            ast = compiler.parse(ccl, objects.get(0));
        } else {
            ast = compiler.parse(ccl);
        }
        Operations.findOrInsertAtomic(records, objects, ast, atomic);
    });
    if (records.size() == 1) {
        return Iterables.getOnlyElement(records);
    } else {
        throw new DuplicateEntryException(AnyStrings.joinWithSpace("Found", records.size(), "records that match", ccl));
    }
}
Also used : Multimap(com.google.common.collect.Multimap) AbstractSyntaxTree(com.cinchapi.ccl.syntax.AbstractSyntaxTree) AtomicSupport(com.cinchapi.concourse.server.storage.AtomicSupport) DuplicateEntryException(com.cinchapi.concourse.thrift.DuplicateEntryException) VerifyWritePermission(com.cinchapi.concourse.server.aop.VerifyWritePermission) VerifyAccessToken(com.cinchapi.concourse.server.aop.VerifyAccessToken) TranslateClientExceptions(com.cinchapi.concourse.server.aop.TranslateClientExceptions)

Example 80 with AtomicSupport

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

the class ConcourseServer method getCriteriaOrderPage.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, TObject>> getCriteriaOrderPage(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.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)

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