use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class OperationExecutorImpl_GetOperationRunnerTest method test_whenCallerIsNormalThread_andGenericOperation_thenReturnAdHocRunner.
@Test
public void test_whenCallerIsNormalThread_andGenericOperation_thenReturnAdHocRunner() {
initExecutor();
Operation op = new DummyOperation(-1);
OperationRunner operationRunner = executor.getOperationRunner(op);
DummyOperationRunnerFactory f = (DummyOperationRunnerFactory) handlerFactory;
assertSame(f.adhocHandler, operationRunner);
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class OperationExecutorImpl_IsInvocationAllowedTest method test_whenPartitionOperation_andCallingFromOperationHostileThread_andAsync.
@Test
public void test_whenPartitionOperation_andCallingFromOperationHostileThread_andAsync() {
initExecutor();
final Operation operation = new DummyOperation(1);
FutureTask<Boolean> futureTask = new FutureTask<Boolean>(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return executor.isInvocationAllowed(operation, true);
}
});
DummyOperationHostileThread thread = new DummyOperationHostileThread(futureTask);
thread.start();
assertEqualsEventually(futureTask, FALSE);
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class OperationExecutorImpl_IsInvocationAllowedTest method test_whenPartitionOperation_andCallingFromOperationHostileThread.
@Test
public void test_whenPartitionOperation_andCallingFromOperationHostileThread() {
initExecutor();
final Operation operation = new DummyOperation(1);
FutureTask<Boolean> futureTask = new FutureTask<Boolean>(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return executor.isInvocationAllowed(operation, false);
}
});
DummyOperationHostileThread thread = new DummyOperationHostileThread(futureTask);
thread.start();
assertEqualsEventually(futureTask, FALSE);
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class OperationExecutorImpl_RunOrExecuteTest method whenPartitionOperation_andCallingFromOperationHostileThread.
@Test
public void whenPartitionOperation_andCallingFromOperationHostileThread() {
initExecutor();
final AtomicReference<Thread> executingThread = new AtomicReference<Thread>();
final Operation operation = new ThreadCapturingOperation(executingThread).setPartitionId(0);
DummyOperationHostileThread thread = new DummyOperationHostileThread(new Runnable() {
@Override
public void run() {
executor.runOrExecute(operation);
}
});
thread.start();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertInstanceOf(PartitionOperationThread.class, executingThread.get());
}
});
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class OperationExecutorImpl_RunOrExecuteTest method whenPartitionOperation_andCallingFromGenericThread.
@Test
public void whenPartitionOperation_andCallingFromGenericThread() {
initExecutor();
final AtomicReference<Thread> executingThread = new AtomicReference<Thread>();
final Operation operation = new ThreadCapturingOperation(executingThread).setPartitionId(0);
executor.execute(new PartitionSpecificRunnable() {
@Override
public int getPartitionId() {
return -1;
}
@Override
public void run() {
executor.runOrExecute(operation);
}
});
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertInstanceOf(PartitionOperationThread.class, executingThread.get());
}
});
}
Aggregations