use of com.hazelcast.spi.impl.servicemanager.ServiceInfo in project hazelcast by hazelcast.
the class ServiceManagerImplTest method getServiceInfos.
// ===================== getServiceInfos ================================
@Test
public void getServiceInfos() {
List<ServiceInfo> result = serviceManager.getServiceInfos(MapService.class);
assertNotNull(result);
assertEquals(1, result.size());
ServiceInfo serviceInfo = result.get(0);
assertEquals(MapService.SERVICE_NAME, serviceInfo.getName());
assertInstanceOf(MapService.class, serviceInfo.getService());
}
use of com.hazelcast.spi.impl.servicemanager.ServiceInfo in project hazelcast by hazelcast.
the class ServiceManagerImpl method registerService.
public synchronized void registerService(String serviceName, Object service) {
if (logger.isFinestEnabled()) {
logger.finest("Registering service: '" + serviceName + "'");
}
final ServiceInfo serviceInfo = new ServiceInfo(serviceName, service);
final ServiceInfo currentServiceInfo = services.putIfAbsent(serviceName, serviceInfo);
if (currentServiceInfo != null) {
logger.warning("Replacing " + currentServiceInfo + " with " + serviceInfo);
if (currentServiceInfo.isCoreService()) {
throw new HazelcastException("Can not replace a CoreService! Name: " + serviceName + ", Service: " + currentServiceInfo.getService());
}
if (currentServiceInfo.isManagedService()) {
shutdownService(currentServiceInfo.getService(), false);
}
services.put(serviceName, serviceInfo);
}
}
use of com.hazelcast.spi.impl.servicemanager.ServiceInfo in project hazelcast by hazelcast.
the class NodeEngineRaftIntegration method takeSnapshot.
@Override
public Object takeSnapshot(long commitIndex) {
try {
List<RestoreSnapshotOp> snapshotOps = new ArrayList<>();
for (ServiceInfo serviceInfo : nodeEngine.getServiceInfos(SnapshotAwareService.class)) {
SnapshotAwareService service = serviceInfo.getService();
Object snapshot = service.takeSnapshot(groupId, commitIndex);
if (snapshot != null) {
snapshotOps.add(new RestoreSnapshotOp(serviceInfo.getName(), snapshot));
}
}
return snapshotOps;
} catch (Throwable t) {
return t;
}
}
use of com.hazelcast.spi.impl.servicemanager.ServiceInfo in project hazelcast by hazelcast.
the class AbstractPartitionOperation method createReplicationOperations.
private Collection<Operation> createReplicationOperations(PartitionReplicationEvent event, boolean nonFragmentedOnly) {
Collection<Operation> operations = new ArrayList<>();
NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
Collection<ServiceInfo> services = nodeEngine.getServiceInfos(MigrationAwareService.class);
for (ServiceInfo serviceInfo : services) {
MigrationAwareService service = serviceInfo.getService();
if (nonFragmentedOnly && service instanceof FragmentedMigrationAwareService) {
// skip fragmented services
continue;
}
Operation op = service.prepareReplicationOperation(event);
if (op != null) {
op.setServiceName(serviceInfo.getName());
operations.add(op);
}
}
return operations;
}
use of com.hazelcast.spi.impl.servicemanager.ServiceInfo in project hazelcast by hazelcast.
the class ServiceManagerImplTest method getServiceInfos.
// ===================== getServiceInfos ================================
@Test
public void getServiceInfos() {
List<ServiceInfo> result = serviceManager.getServiceInfos(MapService.class);
assertNotNull(result);
assertEquals(1, result.size());
ServiceInfo serviceInfo = result.get(0);
assertEquals(MapService.SERVICE_NAME, serviceInfo.getName());
assertInstanceOf(MapService.class, serviceInfo.getService());
}
Aggregations