Search in sources :

Example 1 with HazelcastInstanceProxy

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

the class CacheClearTest method registerInvalidationListener.

private void registerInvalidationListener(CacheEventListener cacheEventListener, String name) {
    HazelcastInstanceProxy hzInstance = (HazelcastInstanceProxy) this.hazelcastInstance;
    hzInstance.getOriginal().node.getNodeEngine().getEventService().registerListener(ICacheService.SERVICE_NAME, name, cacheEventListener);
}
Also used : HazelcastInstanceProxy(com.hazelcast.instance.impl.HazelcastInstanceProxy)

Example 2 with HazelcastInstanceProxy

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

the class TestProcessorMetaSupplierContext method setHazelcastInstance.

/**
 * Sets the Hazelcast instance.
 */
@Nonnull
public TestProcessorMetaSupplierContext setHazelcastInstance(@Nonnull HazelcastInstance instance) {
    this.instance = instance;
    if (this.instance instanceof HazelcastInstanceProxy || this.instance instanceof HazelcastInstanceImpl) {
        NodeEngineImpl nodeEngine = Util.getNodeEngine(this.instance);
        this.partitionAssignment = ExecutionPlanBuilder.getPartitionAssignment(nodeEngine, Util.getMembersView(nodeEngine).getMembers()).entrySet().stream().collect(toMap(en -> en.getKey().getAddress(), Entry::getValue));
    }
    return this;
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.impl.HazelcastInstanceImpl) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Entry(java.util.Map.Entry) HazelcastInstanceProxy(com.hazelcast.instance.impl.HazelcastInstanceProxy) Nonnull(javax.annotation.Nonnull)

Example 3 with HazelcastInstanceProxy

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

the class MCMessageTasksTest method testChangeClusterVersionMessageTask.

@Test
public void testChangeClusterVersionMessageTask() throws Exception {
    ClientMessage clientMessage = MCChangeClusterVersionCodec.encodeRequest((byte) 8, (byte) 10);
    String expectedExceptionMsg = "Node's codebase version " + ((HazelcastInstanceProxy) member).getOriginal().node.getVersion() + " is incompatible with the requested cluster version 8.10";
    assertFailure(clientMessage, VersionMismatchException.class, expectedExceptionMsg);
}
Also used : ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) HazelcastInstanceProxy(com.hazelcast.instance.impl.HazelcastInstanceProxy) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with HazelcastInstanceProxy

use of com.hazelcast.instance.impl.HazelcastInstanceProxy 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 5 with HazelcastInstanceProxy

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

the class CacheDestroyTest method registerInvalidationListener.

private void registerInvalidationListener(CacheEventListener cacheEventListener, String name) {
    HazelcastInstanceProxy hzInstance = (HazelcastInstanceProxy) this.hazelcastInstance;
    hzInstance.getOriginal().node.getNodeEngine().getEventService().registerListener(ICacheService.SERVICE_NAME, name, cacheEventListener);
}
Also used : HazelcastInstanceProxy(com.hazelcast.instance.impl.HazelcastInstanceProxy)

Aggregations

HazelcastInstanceProxy (com.hazelcast.instance.impl.HazelcastInstanceProxy)6 HazelcastInstanceImpl (com.hazelcast.instance.impl.HazelcastInstanceImpl)2 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)1 CachePartitionEventData (com.hazelcast.cache.impl.CachePartitionEventData)1 CachePartitionSegment (com.hazelcast.cache.impl.CachePartitionSegment)1 CacheService (com.hazelcast.cache.impl.CacheService)1 CacheReplicationOperation (com.hazelcast.cache.impl.operation.CacheReplicationOperation)1 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 IndexConfig (com.hazelcast.config.IndexConfig)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 Data (com.hazelcast.internal.serialization.Data)1 ServiceNamespace (com.hazelcast.internal.services.ServiceNamespace)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 Indexes (com.hazelcast.query.impl.Indexes)1