use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class ServiceDeploymentTask method onReceiveFullDeploymentsMessage.
/**
* Handles received full services map message.
*
* @param msg Full services map message.
*/
protected void onReceiveFullDeploymentsMessage(ServiceClusterDeploymentResultBatch msg) {
assert depId.equals(msg.deploymentId()) : "Wrong message's deployment process id, msg=" + msg;
initTaskFut.listen((IgniteInClosure<IgniteInternalFuture<?>>) fut -> {
if (isCompleted())
return;
ctx.closure().runLocalSafe((GridPlainRunnable) () -> {
try {
ServiceDeploymentActions depResults = msg.servicesDeploymentActions();
assert depResults != null : "Services deployment actions should be attached.";
final Map<IgniteUuid, Map<UUID, Integer>> fullTops = depResults.deploymentTopologies();
final Map<IgniteUuid, Collection<byte[]>> fullErrors = depResults.deploymentErrors();
depActions.deploymentTopologies(fullTops);
depActions.deploymentErrors(fullErrors);
srvcProc.updateServicesTopologies(fullTops);
final Map<IgniteUuid, ServiceInfo> services = srvcProc.deployedServices();
fullTops.forEach((srvcId, top) -> {
Integer expCnt = top.getOrDefault(ctx.localNodeId(), 0);
if (expCnt < srvcProc.localInstancesCount(srvcId)) {
ServiceInfo desc = services.get(srvcId);
assert desc != null;
ServiceConfiguration cfg = desc.configuration();
try {
srvcProc.redeploy(srvcId, cfg, top);
} catch (IgniteCheckedException e) {
log.error("Error occured during cancel exceed service instances: " + "[srvcId=" + srvcId + ", name=" + desc.name() + ']', e);
}
}
});
completeSuccess();
} catch (Throwable t) {
log.error("Failed to process services full deployments message, msg=" + msg, t);
completeError(t);
}
});
});
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class ServiceDeploymentTask method processDeploymentActions.
/**
* @param depActions Services deployment actions.
*/
private void processDeploymentActions(@NotNull ServiceDeploymentActions depActions) {
srvcProc.updateDeployedServices(depActions);
depActions.servicesToUndeploy().forEach((srvcId, desc) -> {
srvcProc.deployment().deployerBlockingSectionBegin();
try {
srvcProc.undeploy(srvcId);
} finally {
srvcProc.deployment().deployerBlockingSectionEnd();
}
});
if (!depActions.servicesToDeploy().isEmpty()) {
final Collection<UUID> evtTopNodes = F.nodeIds(ctx.discovery().nodes(evtTopVer));
depActions.servicesToDeploy().forEach((srvcId, desc) -> {
try {
ServiceConfiguration cfg = desc.configuration();
TreeMap<UUID, Integer> oldTop = filterDeadNodes(evtTopNodes, desc.topologySnapshot());
Map<UUID, Integer> top = reassign(srvcId, cfg, evtTopVer, oldTop);
expDeps.put(srvcId, top);
Integer expCnt = top.getOrDefault(ctx.localNodeId(), 0);
if (expCnt > srvcProc.localInstancesCount(srvcId)) {
srvcProc.deployment().deployerBlockingSectionBegin();
try {
srvcProc.redeploy(srvcId, cfg, top);
} finally {
srvcProc.deployment().deployerBlockingSectionEnd();
}
}
} catch (IgniteCheckedException e) {
depErrors.computeIfAbsent(srvcId, c -> new ArrayList<>()).add(e);
}
});
}
createAndSendSingleDeploymentsMessage(depId, depErrors);
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class JmxExporterSpiTest method testServices.
/**
*/
@Test
public void testServices() throws Exception {
ServiceConfiguration srvcCfg = new ServiceConfiguration();
srvcCfg.setName("service");
srvcCfg.setMaxPerNodeCount(1);
srvcCfg.setService(new DummyService());
ignite.services().deploy(srvcCfg);
TabularDataSupport srvs = systemView(SVCS_VIEW);
assertEquals(ignite.context().service().serviceDescriptors().size(), srvs.size());
CompositeData sysView = srvs.get(new Object[] { 0 });
assertEquals(srvcCfg.getName(), sysView.get("name"));
assertEquals(srvcCfg.getMaxPerNodeCount(), sysView.get("maxPerNodeCount"));
assertEquals(DummyService.class.getName(), sysView.get("serviceClass"));
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceDeploymentCompoundFutureSelfTest method config.
/**
* @param name Name.
* @return Dummy configuration with a specified name.
*/
private ServiceConfiguration config(String name) {
ServiceConfiguration cfg = new ServiceConfiguration();
cfg.setName(name);
return cfg;
}
use of org.apache.ignite.services.ServiceConfiguration in project ignite by apache.
the class GridServiceMetricsTest method serviceCfg.
/**
* Provides test service configuration.
*/
private static ServiceConfiguration serviceCfg(Service srvc, int perClusterCnt, int perNodeCnt) {
ServiceConfiguration svcCfg = new ServiceConfiguration();
svcCfg.setName(SRVC_NAME);
svcCfg.setService(srvc);
svcCfg.setMaxPerNodeCount(perNodeCnt);
svcCfg.setTotalCount(perClusterCnt);
svcCfg.setStatisticsEnabled(true);
return svcCfg;
}
Aggregations