use of com.hazelcast.internal.partition.PartitionLostEventImpl in project hazelcast by hazelcast.
the class PartitionDataSerializerHook method createFactory.
@Override
public DataSerializableFactory createFactory() {
ConstructorFunction<Integer, IdentifiedDataSerializable>[] constructors = new ConstructorFunction[LEN];
constructors[PARTITION_RUNTIME_STATE] = arg -> new PartitionRuntimeState();
constructors[ASSIGN_PARTITIONS] = arg -> new AssignPartitions();
constructors[PARTITION_BACKUP_REPLICA_ANTI_ENTROPY] = arg -> new PartitionBackupReplicaAntiEntropyOperation();
constructors[FETCH_PARTITION_STATE] = arg -> new FetchPartitionStateOperation();
constructors[HAS_ONGOING_MIGRATION] = arg -> new HasOngoingMigration();
constructors[MIGRATION_COMMIT] = arg -> new MigrationCommitOperation();
constructors[PARTITION_STATE_OP] = arg -> new PartitionStateOperation();
constructors[PROMOTION_COMMIT] = arg -> new PromotionCommitOperation();
constructors[REPLICA_SYNC_REQUEST] = arg -> new PartitionReplicaSyncRequest();
constructors[REPLICA_SYNC_RESPONSE] = arg -> new PartitionReplicaSyncResponse();
constructors[REPLICA_SYNC_RETRY_RESPONSE] = arg -> new PartitionReplicaSyncRetryResponse();
constructors[SAFE_STATE_CHECK] = arg -> new SafeStateCheckOperation();
constructors[SHUTDOWN_REQUEST] = arg -> new ShutdownRequestOperation();
constructors[SHUTDOWN_RESPONSE] = arg -> new ShutdownResponseOperation();
constructors[REPLICA_FRAGMENT_MIGRATION_STATE] = arg -> new ReplicaFragmentMigrationState();
constructors[MIGRATION] = arg -> new MigrationOperation();
constructors[MIGRATION_REQUEST] = arg -> new MigrationRequestOperation();
constructors[NON_FRAGMENTED_SERVICE_NAMESPACE] = arg -> NonFragmentedServiceNamespace.INSTANCE;
constructors[PARTITION_REPLICA] = arg -> new PartitionReplica();
constructors[PUBLISH_COMPLETED_MIGRATIONS] = arg -> new PublishCompletedMigrationsOperation();
constructors[PARTITION_STATE_CHECK_OP] = arg -> new PartitionStateCheckOperation();
constructors[REPLICA_MIGRATION_EVENT] = arg -> new ReplicaMigrationEventImpl();
constructors[MIGRATION_EVENT] = arg -> new MigrationStateImpl();
constructors[PARTITION_LOST_EVENT] = arg -> new PartitionLostEventImpl();
constructors[REPLICA_SYNC_REQUEST_OFFLOADABLE] = arg -> new PartitionReplicaSyncRequestOffloadable();
return new ArrayDataSerializableFactory(constructors);
}
use of com.hazelcast.internal.partition.PartitionLostEventImpl in project hazelcast by hazelcast.
the class ClientCachePartitionLostListenerTest method test_cachePartitionLostListener_invoked_fromOtherNode.
@Test
public void test_cachePartitionLostListener_invoked_fromOtherNode() {
final String cacheName = randomName();
HazelcastInstance instance1 = hazelcastFactory.newHazelcastInstance();
HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance();
final HazelcastInstance client = hazelcastFactory.newHazelcastClient();
final HazelcastServerCachingProvider cachingProvider = createServerCachingProvider(instance1);
final CacheManager cacheManager = cachingProvider.getCacheManager();
final CacheConfig<Integer, String> config = new CacheConfig<Integer, String>();
config.setBackupCount(0);
cacheManager.createCache(cacheName, config);
final CachingProvider clientCachingProvider = createClientCachingProvider(client);
final CacheManager clientCacheManager = clientCachingProvider.getCacheManager();
final Cache<Integer, String> cache = clientCacheManager.getCache(cacheName);
final ICache iCache = cache.unwrap(ICache.class);
final EventCollectingCachePartitionLostListener listener = new EventCollectingCachePartitionLostListener();
iCache.addPartitionLostListener(listener);
assertRegistrationsSizeEventually(instance1, cacheName, 1);
assertRegistrationsSizeEventually(instance2, cacheName, 1);
final CacheService cacheService1 = getNode(instance1).getNodeEngine().getService(CacheService.SERVICE_NAME);
final CacheService cacheService2 = getNode(instance2).getNodeEngine().getService(CacheService.SERVICE_NAME);
final int partitionId = 5;
cacheService1.onPartitionLost(new PartitionLostEventImpl(partitionId, 0, null));
cacheService2.onPartitionLost(new PartitionLostEventImpl(partitionId, 0, null));
assertCachePartitionLostEventEventually(listener, partitionId);
}
use of com.hazelcast.internal.partition.PartitionLostEventImpl in project hazelcast by hazelcast.
the class CachePartitionLostListenerTest method test_partitionLostListenerInvoked.
@Test
public void test_partitionLostListenerInvoked() {
List<HazelcastInstance> instances = getCreatedInstancesShuffledAfterWarmedUp(1);
final HazelcastInstance instance = instances.get(0);
HazelcastServerCachingProvider cachingProvider = createServerCachingProvider(instance);
CacheManager cacheManager = cachingProvider.getCacheManager();
CacheConfig<Integer, String> config = new CacheConfig<Integer, String>();
Cache<Integer, String> cache = cacheManager.createCache(getIthCacheName(0), config);
ICache iCache = cache.unwrap(ICache.class);
final EventCollectingCachePartitionLostListener listener = new EventCollectingCachePartitionLostListener(0);
iCache.addPartitionLostListener(listener);
final IPartitionLostEvent internalEvent = new PartitionLostEventImpl(1, 1, null);
CacheService cacheService = getNode(instance).getNodeEngine().getService(CacheService.SERVICE_NAME);
cacheService.onPartitionLost(internalEvent);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
List<CachePartitionLostEvent> events = listener.getEvents();
assertEquals(1, events.size());
CachePartitionLostEvent event = events.get(0);
assertEquals(internalEvent.getPartitionId(), event.getPartitionId());
assertEquals(getIthCacheName(0), event.getSource());
assertEquals(getIthCacheName(0), event.getName());
assertEquals(instance.getCluster().getLocalMember(), event.getMember());
assertEquals(CacheEventType.PARTITION_LOST, event.getEventType());
}
});
cacheManager.destroyCache(getIthCacheName(0));
cacheManager.close();
cachingProvider.close();
}
use of com.hazelcast.internal.partition.PartitionLostEventImpl in project hazelcast by hazelcast.
the class MapPartitionLostListenerTest method test_partitionLostListenerInvoked.
@Test
public void test_partitionLostListenerInvoked() {
List<HazelcastInstance> instances = getCreatedInstancesShuffledAfterWarmedUp(1);
HazelcastInstance instance = instances.get(0);
final TestEventCollectingMapPartitionLostListener listener = new TestEventCollectingMapPartitionLostListener(0);
instance.getMap(getIthMapName(0)).addPartitionLostListener(listener);
final IPartitionLostEvent internalEvent = new PartitionLostEventImpl(1, 0, null);
MapService mapService = getNode(instance).getNodeEngine().getService(MapService.SERVICE_NAME);
mapService.onPartitionLost(internalEvent);
assertEventEventually(listener, internalEvent);
}
use of com.hazelcast.internal.partition.PartitionLostEventImpl in project hazelcast by hazelcast.
the class MapPartitionLostListenerTest method test_partitionLostListenerInvoked_whenEntryListenerIsAlsoRegistered.
@Test
public void test_partitionLostListenerInvoked_whenEntryListenerIsAlsoRegistered() {
List<HazelcastInstance> instances = getCreatedInstancesShuffledAfterWarmedUp(1);
HazelcastInstance instance = instances.get(0);
final TestEventCollectingMapPartitionLostListener listener = new TestEventCollectingMapPartitionLostListener(0);
instance.getMap(getIthMapName(0)).addPartitionLostListener(listener);
instance.getMap(getIthMapName(0)).addEntryListener(mock(EntryAddedListener.class), true);
final IPartitionLostEvent internalEvent = new PartitionLostEventImpl(1, 0, null);
MapService mapService = getNode(instance).getNodeEngine().getService(MapService.SERVICE_NAME);
mapService.onPartitionLost(internalEvent);
assertEventEventually(listener, internalEvent);
}
Aggregations