Search in sources :

Example 6 with ServiceConfiguration

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);
            }
        });
    });
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) DiscoveryCustomEvent(org.apache.ignite.internal.events.DiscoveryCustomEvent) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) U(org.apache.ignite.internal.util.typedef.internal.U) EVT_DISCOVERY_CUSTOM_EVT(org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) HashMap(java.util.HashMap) IgniteLogger(org.apache.ignite.IgniteLogger) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) HashSet(java.util.HashSet) ClusterNode(org.apache.ignite.cluster.ClusterNode) SERVICE_POOL(org.apache.ignite.internal.managers.communication.GridIoPolicy.SERVICE_POOL) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) Map(java.util.Map) S(org.apache.ignite.internal.util.typedef.internal.S) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) ClusterTopologyServerNotFoundException(org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException) F(org.apache.ignite.internal.util.typedef.F) EVT_NODE_JOINED(org.apache.ignite.events.EventType.EVT_NODE_JOINED) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) GridToStringExclude(org.apache.ignite.internal.util.tostring.GridToStringExclude) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) Set(java.util.Set) UUID(java.util.UUID) TOPIC_SERVICES(org.apache.ignite.internal.GridTopic.TOPIC_SERVICES) GridToStringInclude(org.apache.ignite.internal.util.tostring.GridToStringInclude) Nullable(org.jetbrains.annotations.Nullable) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) TreeMap(java.util.TreeMap) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) NotNull(org.jetbrains.annotations.NotNull) IgniteUuid(org.apache.ignite.lang.IgniteUuid) CacheAffinityChangeMessage(org.apache.ignite.internal.processors.cache.CacheAffinityChangeMessage) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) IgniteUuid(org.apache.ignite.lang.IgniteUuid) Collection(java.util.Collection) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 7 with ServiceConfiguration

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);
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) UUID(java.util.UUID)

Example 8 with ServiceConfiguration

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"));
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration) DummyService(org.apache.ignite.internal.processors.service.DummyService) TabularDataSupport(javax.management.openmbean.TabularDataSupport) CompositeData(javax.management.openmbean.CompositeData) Test(org.junit.Test)

Example 9 with ServiceConfiguration

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;
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration)

Example 10 with ServiceConfiguration

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;
}
Also used : ServiceConfiguration(org.apache.ignite.services.ServiceConfiguration)

Aggregations

ServiceConfiguration (org.apache.ignite.services.ServiceConfiguration)71 Test (org.junit.Test)29 Ignite (org.apache.ignite.Ignite)20 ArrayList (java.util.ArrayList)18 CountDownLatch (java.util.concurrent.CountDownLatch)18 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)15 ClusterNode (org.apache.ignite.cluster.ClusterNode)10 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)9 IgniteUuid (org.apache.ignite.lang.IgniteUuid)8 ServiceDeploymentException (org.apache.ignite.services.ServiceDeploymentException)8 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)7 UUID (java.util.UUID)6 IgniteException (org.apache.ignite.IgniteException)6 IgniteClientDisconnectedCheckedException (org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)5 IgniteEx (org.apache.ignite.internal.IgniteEx)5 HashMap (java.util.HashMap)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 Service (org.apache.ignite.services.Service)4 HashSet (java.util.HashSet)3 List (java.util.List)3