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);
}
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;
}
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);
}
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();
}
}
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);
}
Aggregations