use of com.hazelcast.internal.services.ClientAwareService in project hazelcast by hazelcast.
the class AbstractMapServiceFactory method createMapService.
/**
* Returns a {@link MapService} object by populating it with required
* auxiliary services.
*
* @return {@link MapService} object
*/
@Override
public MapService createMapService() {
NodeEngine nodeEngine = getNodeEngine();
MapServiceContext mapServiceContext = getMapServiceContext();
ManagedService managedService = createManagedService();
CountingMigrationAwareService migrationAwareService = createMigrationAwareService();
TransactionalService transactionalService = createTransactionalService();
RemoteService remoteService = createRemoteService();
EventPublishingService eventPublishingService = createEventPublishingService();
PostJoinAwareService postJoinAwareService = createPostJoinAwareService();
SplitBrainHandlerService splitBrainHandlerService = createSplitBrainHandlerService();
WanSupportingService wanSupportingService = createReplicationSupportingService();
StatisticsAwareService statisticsAwareService = createStatisticsAwareService();
PartitionAwareService partitionAwareService = createPartitionAwareService();
MapSplitBrainProtectionAwareService splitBrainProtectionAwareService = createSplitBrainProtectionAwareService();
ClientAwareService clientAwareService = createClientAwareService();
checkNotNull(nodeEngine, "nodeEngine should not be null");
checkNotNull(mapServiceContext, "mapServiceContext should not be null");
checkNotNull(managedService, "managedService should not be null");
checkNotNull(migrationAwareService, "migrationAwareService should not be null");
checkNotNull(transactionalService, "transactionalService should not be null");
checkNotNull(remoteService, "remoteService should not be null");
checkNotNull(eventPublishingService, "eventPublishingService should not be null");
checkNotNull(postJoinAwareService, "postJoinAwareService should not be null");
checkNotNull(splitBrainHandlerService, "splitBrainHandlerService should not be null");
checkNotNull(wanSupportingService, "replicationSupportingService should not be null");
checkNotNull(statisticsAwareService, "statisticsAwareService should not be null");
checkNotNull(partitionAwareService, "partitionAwareService should not be null");
checkNotNull(splitBrainProtectionAwareService, "splitBrainProtectionAwareService should not be null");
checkNotNull(clientAwareService, "clientAwareService should not be null");
MapService mapService = new MapService();
mapService.managedService = managedService;
mapService.migrationAwareService = migrationAwareService;
mapService.transactionalService = transactionalService;
mapService.remoteService = remoteService;
mapService.eventPublishingService = eventPublishingService;
mapService.postJoinAwareService = postJoinAwareService;
mapService.splitBrainHandlerService = splitBrainHandlerService;
mapService.wanSupportingService = wanSupportingService;
mapService.statisticsAwareService = statisticsAwareService;
mapService.mapServiceContext = mapServiceContext;
mapService.partitionAwareService = partitionAwareService;
mapService.splitBrainProtectionAwareService = splitBrainProtectionAwareService;
mapService.clientAwareService = clientAwareService;
mapServiceContext.setService(mapService);
return mapService;
}
use of com.hazelcast.internal.services.ClientAwareService in project hazelcast by hazelcast.
the class ClientLifecycleMonitor method run.
@Override
public void run() {
Set<UUID> allClients = null;
Set<UUID> localClients = clientEndpointManager.getLocalClientUuids();
for (Map.Entry<UUID, Long> entry : lastLiveTime.entrySet()) {
UUID clientUuid = entry.getKey();
if (localClients.contains(clientUuid)) {
// This member has a connection to client, update the time and continue
lastLiveTime.put(clientUuid, System.currentTimeMillis());
continue;
}
long millisSinceLastLive = System.currentTimeMillis() - entry.getValue();
if (millisSinceLastLive > timeoutMillis) {
if (allClients == null) {
allClients = clientEngine.getClientsInCluster().keySet();
}
// A member has connection to client, update the time and continue
if (allClients.contains(clientUuid)) {
lastLiveTime.put(clientUuid, System.currentTimeMillis());
continue;
}
// No one have connection left to this client, clean the resources
logger.warning("No connection left to client cluster wide " + entry.getKey() + " for " + millisSinceLastLive + " millis," + " cleaning resources of the client");
lastLiveTime.remove(entry.getKey(), entry.getValue());
// This part cleans up locks conditions semaphore etc..
Collection<ClientAwareService> services = nodeEngine.getServices(ClientAwareService.class);
for (ClientAwareService service : services) {
service.clientDisconnected(clientUuid);
}
}
}
}
Aggregations