Search in sources :

Example 11 with HazelcastInstanceImpl

use of com.hazelcast.instance.impl.HazelcastInstanceImpl in project hazelcast by hazelcast.

the class OperationServiceImpl_BasicTest method testPropagateSerializationErrorOnResponseToCallerGithubIssue2559.

@Test(expected = ExecutionException.class)
public void testPropagateSerializationErrorOnResponseToCallerGithubIssue2559() throws Exception {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance hz1 = factory.newHazelcastInstance();
    HazelcastInstance hz2 = factory.newHazelcastInstance();
    Field original = HazelcastInstanceProxy.class.getDeclaredField("original");
    original.setAccessible(true);
    HazelcastInstanceImpl impl = (HazelcastInstanceImpl) original.get(hz1);
    OperationService operationService = impl.node.nodeEngine.getOperationService();
    Address address = hz2.getCluster().getLocalMember().getAddress();
    Operation operation = new GithubIssue2559Operation();
    String serviceName = DistributedExecutorService.SERVICE_NAME;
    InvocationBuilder invocationBuilder = operationService.createInvocationBuilder(serviceName, operation, address);
    invocationBuilder.invoke().get();
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.impl.HazelcastInstanceImpl) Field(java.lang.reflect.Field) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.cluster.Address) Accessors.getAddress(com.hazelcast.test.Accessors.getAddress) Accessors.getOperationService(com.hazelcast.test.Accessors.getOperationService) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation) InvocationBuilder(com.hazelcast.spi.impl.operationservice.InvocationBuilder) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 12 with HazelcastInstanceImpl

use of com.hazelcast.instance.impl.HazelcastInstanceImpl in project hazelcast by hazelcast.

the class CacheSerializationTest method test_CacheReplicationOperation_serialization.

@Test
public void test_CacheReplicationOperation_serialization() throws Exception {
    TestHazelcastInstanceFactory factory = new TestHazelcastInstanceFactory(1);
    HazelcastInstance hazelcastInstance = factory.newHazelcastInstance();
    try {
        CachingProvider provider = createServerCachingProvider(hazelcastInstance);
        CacheManager manager = provider.getCacheManager();
        CompleteConfiguration configuration = new MutableConfiguration();
        Cache cache1 = manager.createCache("cache1", configuration);
        Cache cache2 = manager.createCache("cache2", configuration);
        Cache cache3 = manager.createCache("cache3", configuration);
        for (int i = 0; i < 1000; i++) {
            cache1.put("key" + i, i);
            cache2.put("key" + i, i);
            cache3.put("key" + i, i);
        }
        HazelcastInstanceProxy proxy = (HazelcastInstanceProxy) hazelcastInstance;
        Field original = HazelcastInstanceProxy.class.getDeclaredField("original");
        original.setAccessible(true);
        HazelcastInstanceImpl impl = (HazelcastInstanceImpl) original.get(proxy);
        NodeEngineImpl nodeEngine = impl.node.nodeEngine;
        CacheService cacheService = nodeEngine.getService(CacheService.SERVICE_NAME);
        int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
        for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
            CachePartitionSegment segment = cacheService.getSegment(partitionId);
            int replicaIndex = 1;
            Collection<ServiceNamespace> namespaces = segment.getAllNamespaces(replicaIndex);
            if (CollectionUtil.isEmpty(namespaces)) {
                continue;
            }
            CacheReplicationOperation operation = new CacheReplicationOperation();
            operation.prepare(segment, namespaces, replicaIndex);
            Data serialized = service.toData(operation);
            try {
                service.toObject(serialized);
            } catch (Exception e) {
                throw new Exception("Partition: " + partitionId, e);
            }
        }
    } finally {
        factory.shutdownAll();
    }
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.impl.HazelcastInstanceImpl) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) CachePartitionSegment(com.hazelcast.cache.impl.CachePartitionSegment) ServiceNamespace(com.hazelcast.internal.services.ServiceNamespace) CacheReplicationOperation(com.hazelcast.cache.impl.operation.CacheReplicationOperation) Data(com.hazelcast.internal.serialization.Data) CachePartitionEventData(com.hazelcast.cache.impl.CachePartitionEventData) HazelcastInstanceProxy(com.hazelcast.instance.impl.HazelcastInstanceProxy) MutableConfiguration(javax.cache.configuration.MutableConfiguration) UnknownHostException(java.net.UnknownHostException) Field(java.lang.reflect.Field) HazelcastInstance(com.hazelcast.core.HazelcastInstance) CompleteConfiguration(javax.cache.configuration.CompleteConfiguration) CacheManager(javax.cache.CacheManager) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) Cache(javax.cache.Cache) CacheService(com.hazelcast.cache.impl.CacheService) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 13 with HazelcastInstanceImpl

use of com.hazelcast.instance.impl.HazelcastInstanceImpl in project hazelcast by hazelcast.

the class CacheEntryProcessorTest method setUpInternal.

private static void setUpInternal() throws NoSuchFieldException, IllegalAccessException {
    factory = new TestHazelcastInstanceFactory(2);
    node1 = factory.newHazelcastInstance();
    node2 = factory.newHazelcastInstance();
    Field original = HazelcastInstanceProxy.class.getDeclaredField("original");
    original.setAccessible(true);
    HazelcastInstanceImpl impl1 = (HazelcastInstanceImpl) original.get(node1);
    HazelcastInstanceImpl impl2 = (HazelcastInstanceImpl) original.get(node2);
    cacheServiceOnNode1 = impl1.node.getNodeEngine().getService(CacheService.SERVICE_NAME);
    cacheServiceOnNode2 = impl2.node.getNodeEngine().getService(CacheService.SERVICE_NAME);
    serializationService = impl1.node.getNodeEngine().getSerializationService();
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.impl.HazelcastInstanceImpl) Field(java.lang.reflect.Field) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory)

Example 14 with HazelcastInstanceImpl

use of com.hazelcast.instance.impl.HazelcastInstanceImpl in project hazelcast by hazelcast.

the class CacheEventListenerSplitBrainTest method getCacheManager.

protected CacheManager getCacheManager(HazelcastInstance instance) {
    HazelcastInstanceImpl hazelcastInstanceImpl = TestUtil.getHazelcastInstanceImpl(instance);
    HazelcastServerCachingProvider cachingProvider = createServerCachingProvider(hazelcastInstanceImpl);
    return cachingProvider.getCacheManager();
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.impl.HazelcastInstanceImpl) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider)

Aggregations

HazelcastInstanceImpl (com.hazelcast.instance.impl.HazelcastInstanceImpl)14 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 Operation (com.hazelcast.spi.impl.operationservice.Operation)3 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)3 Field (java.lang.reflect.Field)3 CachingProvider (javax.cache.spi.CachingProvider)3 HazelcastCacheManager (com.hazelcast.cache.HazelcastCacheManager)2 CacheService (com.hazelcast.cache.impl.CacheService)2 HazelcastServerCacheManager (com.hazelcast.cache.impl.HazelcastServerCacheManager)2 Address (com.hazelcast.cluster.Address)2 Member (com.hazelcast.cluster.Member)2 HazelcastInstanceProxy (com.hazelcast.instance.impl.HazelcastInstanceProxy)2 Node (com.hazelcast.instance.impl.Node)2 ShutdownNodeOp (com.hazelcast.internal.cluster.impl.operations.ShutdownNodeOp)2 Accessors.getHazelcastInstanceImpl (com.hazelcast.test.Accessors.getHazelcastInstanceImpl)2