Search in sources :

Example 1 with DefaultOperationQueue

use of com.hazelcast.spi.impl.operationexecutor.impl.DefaultOperationQueue 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();
}
Also used : DefaultOperationQueue(com.hazelcast.spi.impl.operationexecutor.impl.DefaultOperationQueue) OperationQueue(com.hazelcast.spi.impl.operationexecutor.impl.OperationQueue) PartitionOperationThread(com.hazelcast.spi.impl.operationexecutor.impl.PartitionOperationThread) CountDownLatch(java.util.concurrent.CountDownLatch) DefaultOperationQueue(com.hazelcast.spi.impl.operationexecutor.impl.DefaultOperationQueue) RequireAssertEnabled(com.hazelcast.test.RequireAssertEnabled) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with DefaultOperationQueue

use of com.hazelcast.spi.impl.operationexecutor.impl.DefaultOperationQueue 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();
}
Also used : DefaultOperationQueue(com.hazelcast.spi.impl.operationexecutor.impl.DefaultOperationQueue) OperationQueue(com.hazelcast.spi.impl.operationexecutor.impl.OperationQueue) PartitionOperationThread(com.hazelcast.spi.impl.operationexecutor.impl.PartitionOperationThread) CountDownLatch(java.util.concurrent.CountDownLatch) DefaultOperationQueue(com.hazelcast.spi.impl.operationexecutor.impl.DefaultOperationQueue) RequireAssertEnabled(com.hazelcast.test.RequireAssertEnabled) QuickTest(com.hazelcast.test.annotation.QuickTest) NightlyTest(com.hazelcast.test.annotation.NightlyTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

DefaultOperationQueue (com.hazelcast.spi.impl.operationexecutor.impl.DefaultOperationQueue)2 OperationQueue (com.hazelcast.spi.impl.operationexecutor.impl.OperationQueue)2 PartitionOperationThread (com.hazelcast.spi.impl.operationexecutor.impl.PartitionOperationThread)2 RequireAssertEnabled (com.hazelcast.test.RequireAssertEnabled)2 NightlyTest (com.hazelcast.test.annotation.NightlyTest)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Test (org.junit.Test)2