use of com.hazelcast.spi.impl.operationexecutor.impl.PartitionOperationThread in project hazelcast by hazelcast.
the class InterceptorRegistryTest method testDeregister_fromPartitionOperationThread.
@Test
@RequireAssertEnabled
public void testDeregister_fromPartitionOperationThread() throws Exception {
OperationQueue queue = new DefaultOperationQueue();
PartitionOperationThread thread = getPartitionOperationThread(queue);
thread.start();
registry.register(interceptor.id, interceptor);
final CountDownLatch latch = new CountDownLatch(1);
Object task = new Runnable() {
@Override
public void run() {
try {
registry.deregister(interceptor.id);
} catch (AssertionError e) {
e.printStackTrace();
latch.countDown();
}
}
};
queue.add(task, false);
latch.await();
thread.shutdown();
thread.join();
assertInterceptorRegistryContainsInterceptor();
}
use of com.hazelcast.spi.impl.operationexecutor.impl.PartitionOperationThread in project hazelcast by hazelcast.
the class InterceptorRegistryTest method getPartitionOperationThread.
private PartitionOperationThread getPartitionOperationThread(OperationQueue queue) {
HazelcastThreadGroup threadGroup = new HazelcastThreadGroup("instanceName", LOGGER, getClass().getClassLoader());
NodeExtension nodeExtension = mock(NodeExtension.class);
OperationRunner operationRunner = mock(OperationRunner.class);
OperationRunner[] operationRunners = new OperationRunner[] { operationRunner };
return new PartitionOperationThread("threadName", 0, queue, LOGGER, threadGroup, nodeExtension, operationRunners);
}
use of com.hazelcast.spi.impl.operationexecutor.impl.PartitionOperationThread in project hazelcast by hazelcast.
the class InterceptorRegistry method deregister.
/**
* De-registers {@link MapInterceptor} for the supplied `id`, if there is any.
*
* This method is called by {@link com.hazelcast.spi.impl.operationexecutor.impl.GenericOperationThread}
* when de-registering via {@link com.hazelcast.map.impl.operation.RemoveInterceptorOperation}
*
* @param id id of the interceptor
*/
public synchronized void deregister(String id) {
assert !(Thread.currentThread() instanceof PartitionOperationThread);
if (!id2InterceptorMap.containsKey(id)) {
return;
}
Map<String, MapInterceptor> tmpMap = new HashMap<String, MapInterceptor>(id2InterceptorMap);
MapInterceptor removedInterceptor = tmpMap.remove(id);
id2InterceptorMap = unmodifiableMap(tmpMap);
List<MapInterceptor> tmpInterceptors = new ArrayList<MapInterceptor>(interceptors);
tmpInterceptors.remove(removedInterceptor);
interceptors = unmodifiableList(tmpInterceptors);
}
use of com.hazelcast.spi.impl.operationexecutor.impl.PartitionOperationThread in project hazelcast by hazelcast.
the class InterceptorRegistryTest method testRegister_fromPartitionOperationThread.
@Test
@RequireAssertEnabled
public void testRegister_fromPartitionOperationThread() throws Exception {
OperationQueue queue = new DefaultOperationQueue();
PartitionOperationThread thread = getPartitionOperationThread(queue);
thread.start();
final CountDownLatch latch = new CountDownLatch(1);
Object task = new Runnable() {
@Override
public void run() {
try {
registry.register(interceptor.id, interceptor);
} catch (AssertionError e) {
e.printStackTrace();
latch.countDown();
}
}
};
queue.add(task, false);
latch.await();
thread.shutdown();
thread.join();
assertInterceptorRegistryContainsNotInterceptor();
}
Aggregations