use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.
the class ConcourseServer method findCcl.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findCcl(String ccl, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AbstractSyntaxTree ast = compiler.parse(ccl);
AtomicSupport store = getStore(transaction, environment);
Function<Store, Set<Long>> function = $store -> ast.accept(Finder.instance(), $store);
try {
return function.apply(store);
} catch (InsufficientAtomicityException e) {
return AtomicOperations.supplyWithRetry(store, atomic -> function.apply(atomic));
}
}
use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.
the class ConcourseServer method findKeyOperatorValuesPage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findKeyOperatorValuesPage(String key, Operator operator, List<TObject> values, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
TObject[] tValues = values.toArray(Array.containing());
AtomicSupport store = getStore(transaction, environment);
Function<Store, Set<Long>> function = $store -> Stores.find($store, key, operator, tValues);
Set<Long> records;
try {
records = function.apply(store);
} catch (InsufficientAtomicityException e) {
records = AtomicOperations.supplyWithRetry(store, atomic -> function.apply(atomic));
}
return Paging.page(records, Pages.from(page));
}
use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.
the class ConcourseServer method getKeyRecord.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public TObject getKeyRecord(String key, long record, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AtomicSupport store = getStore(transaction, environment);
Function<Store, TObject> function = $store -> Iterables.getLast(Stores.select($store, key, record), TObject.NULL);
try {
return function.apply(store);
} catch (InsufficientAtomicityException e) {
return AtomicOperations.supplyWithRetry(store, atomic -> function.apply(atomic));
}
}
use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.
the class ConcourseServer method findKeyOperatorValuesTimePage.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Set<Long> findKeyOperatorValuesTimePage(String key, Operator operator, List<TObject> values, long timestamp, TPage page, AccessToken creds, TransactionToken transaction, String environment) throws TException {
TObject[] tValues = values.toArray(Array.containing());
AtomicSupport store = getStore(transaction, environment);
Function<Store, Set<Long>> function = $store -> Stores.find($store, timestamp, key, operator, tValues);
Set<Long> records;
try {
records = function.apply(store);
} catch (InsufficientAtomicityException e) {
records = AtomicOperations.supplyWithRetry(store, atomic -> function.apply(atomic));
}
return Paging.page(records, Pages.from(page));
}
use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.
the class PluginSerializerTest method randomRemoteMessage.
/**
* Generate a random {@link RemoteMessage} for testing.
*
* @return a RemoteMessage
*/
private RemoteMessage randomRemoteMessage() {
int seed = Random.getInt();
RemoteMessage message;
if (seed % 3 == 0) {
message = Reflection.newInstance("com.cinchapi.concourse.server.plugin.RemoteAttributeExchange", Random.getString(), Random.getString());
} else if (seed % 2 == 0) {
AccessToken creds = new AccessToken(ByteBuffer.wrap(Random.getString().getBytes(StandardCharsets.UTF_8)));
TransactionToken transaction = new TransactionToken(creds, Time.now());
String method = Random.getSimpleString();
String environment = Random.getSimpleString();
int argsCount = Math.abs(Random.getInt()) % 8;
ComplexTObject[] args = new ComplexTObject[argsCount];
for (int i = 0; i < argsCount; ++i) {
args[i] = ComplexTObject.fromJavaObject(Random.getObject());
}
message = Reflection.newInstance("com.cinchapi.concourse.server.plugin.RemoteMethodRequest", method, creds, transaction, environment, args);
} else {
AccessToken creds = new AccessToken(ByteBuffer.wrap(Random.getString().getBytes(StandardCharsets.UTF_8)));
ComplexTObject response = ComplexTObject.fromJavaObject(Random.getObject());
message = Reflection.newInstance("com.cinchapi.concourse.server.plugin.RemoteMethodResponse", creds, response);
}
return message;
}
Aggregations