use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.
the class BackgroundThreadTest method testBackgroundExecutorSetsEnvironmentCorrectly.
@Test
public void testBackgroundExecutorSetsEnvironmentCorrectly() throws InterruptedException {
InterProcessCommunication outgoing = new MessageQueue();
ConcurrentMap<AccessToken, RemoteMethodResponse> responses = Maps.newConcurrentMap();
String environment1 = Random.getSimpleString();
String environment2 = Random.getSimpleString();
MockConcourseRuntime runtime = new MockConcourseRuntime();
BackgroundExecutor executor = PluginExecutors.newCachedBackgroundExecutor(outgoing, responses);
CountDownLatch latch = new CountDownLatch(2);
final AtomicBoolean passed = new AtomicBoolean(true);
executor.execute(environment1, () -> {
try {
Assert.assertEquals(environment1, runtime.environment());
latch.countDown();
} catch (AssertionError e) {
passed.set(false);
e.printStackTrace();
}
});
executor.execute(environment2, () -> {
try {
Assert.assertEquals(environment2, runtime.environment());
latch.countDown();
} catch (AssertionError e) {
passed.set(false);
e.printStackTrace();
}
});
latch.await();
Assert.assertTrue(passed.get());
}
use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.
the class ConcourseIntegrationTest method createUser.
/**
* Create a user account identified by {@code username} and {@code password}
* with the specified {@code role}.
*
* @param username
* @param password
* @param role
*/
protected final void createUser(String username, String password, String role) {
try {
AccessToken token = server.login(ByteBuffers.fromUtf8String("admin"), ByteBuffers.fromUtf8String("admin"));
server.createUser(ByteBuffers.fromUtf8String(username), ByteBuffers.fromUtf8String(password), role, token);
} catch (TException e) {
throw CheckedExceptions.wrapAsRuntimeException(e);
}
}
use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.
the class ConcourseIntegrationTest method deleteUser.
/**
* Delete the user account identified by {@code username}.
*
* @param username the username of the account to delete
*/
protected final void deleteUser(String username) {
try {
AccessToken token = server.login(ByteBuffers.fromUtf8String("admin"), ByteBuffers.fromUtf8String("admin"));
server.deleteUser(ByteBuffers.fromUtf8String(username), token);
} catch (TException e) {
throw CheckedExceptions.wrapAsRuntimeException(e);
}
}
use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.
the class RemoteMethodResponse method deserialize.
@Override
public void deserialize(Buffer buffer) {
boolean isError = buffer.readBoolean();
int credsLength = buffer.readInt();
byte[] creds = new byte[credsLength];
buffer.read(creds);
this.creds = new AccessToken(ByteBuffer.wrap(creds));
if (isError) {
this.error = new RuntimeException(buffer.readUTF8());
} else {
byte[] response = new byte[(int) buffer.remaining()];
buffer.read(response);
this.response = ComplexTObject.fromByteBuffer(ByteBuffer.wrap(response));
}
}
use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.
the class ConcourseServer method selectKeysCriteriaTimeOrder.
@Override
@TranslateClientExceptions
@VerifyAccessToken
@VerifyReadPermission
public Map<Long, Map<String, Set<TObject>>> selectKeysCriteriaTimeOrder(List<String> keys, TCriteria criteria, long timestamp, TOrder order, AccessToken creds, TransactionToken transaction, String environment) throws TException {
AbstractSyntaxTree ast = compiler.parse(criteria);
AtomicSupport store = getStore(transaction, environment);
SortableTable<Set<TObject>> result = emptySortableResultDataset();
AtomicOperations.executeWithRetry(store, atomic -> Operations.selectKeysAstAtomic(keys, ast, timestamp, result, null, $result -> $result.sort(Sorting.byValues(Orders.from(order), atomic), timestamp), atomic));
return result;
}
Aggregations