Search in sources :

Example 1 with VerifyWritePermission

use of com.cinchapi.concourse.server.aop.VerifyWritePermission 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 2 with VerifyWritePermission

use of com.cinchapi.concourse.server.aop.VerifyWritePermission 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 3 with VerifyWritePermission

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

the class ConcourseServer method revertKeyRecordTime.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public void revertKeyRecordTime(String key, long record, long timestamp, AccessToken creds, TransactionToken transaction, String environment) throws TException {
    AtomicSupport store = getStore(transaction, environment);
    AtomicOperations.executeWithRetry(store, (atomic) -> {
        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 4 with VerifyWritePermission

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

the class ConcourseServer method addKeyValueRecords.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public Map<Long, Boolean> addKeyValueRecords(String key, TObject value, 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, atomic.add(key, value, record));
        }
    });
    return result;
}
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 5 with VerifyWritePermission

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

the class ConcourseServer method revertKeysRecordsTime.

@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyWritePermission
public void revertKeysRecordsTime(List<String> keys, 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) {
            for (String key : keys) {
                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)

Aggregations

TranslateClientExceptions (com.cinchapi.concourse.server.aop.TranslateClientExceptions)22 VerifyAccessToken (com.cinchapi.concourse.server.aop.VerifyAccessToken)22 VerifyWritePermission (com.cinchapi.concourse.server.aop.VerifyWritePermission)22 AtomicSupport (com.cinchapi.concourse.server.storage.AtomicSupport)22 ComplexTObject (com.cinchapi.concourse.thrift.ComplexTObject)6 TObject (com.cinchapi.concourse.thrift.TObject)6 Multimap (com.google.common.collect.Multimap)3 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)2 AtomicOperation (com.cinchapi.concourse.server.storage.AtomicOperation)2 AtomicStateException (com.cinchapi.concourse.server.storage.AtomicStateException)2 TransactionStateException (com.cinchapi.concourse.server.storage.TransactionStateException)2 DuplicateEntryException (com.cinchapi.concourse.thrift.DuplicateEntryException)2 TransactionException (com.cinchapi.concourse.thrift.TransactionException)2 SortableSet (com.cinchapi.concourse.data.sort.SortableSet)1 Set (java.util.Set)1