Class IgniteServicesImpl

    • Field Detail

    • Constructor Detail

      • IgniteServicesImpl

        public IgniteServicesImpl()
        Required by Externalizable.
      • IgniteServicesImpl

        public IgniteServicesImpl​(GridKernalContext ctx,
                                  ClusterGroupAdapter prj,
                                  boolean async)
        Parameters:
        ctx - Kernal context.
        prj - Projection.
        async - Async support flag.
    • Method Detail

      • clusterGroup

        public ClusterGroup clusterGroup()
        Gets the cluster group to which this IgniteServices instance belongs.
        Specified by:
        clusterGroup in interface IgniteServices
        Returns:
        Cluster group to which this IgniteServices instance belongs.
      • deployNodeSingleton

        public void deployNodeSingleton​(String name,
                                        Service svc)
        Deploys a per-node singleton service. Ignite will guarantee that there is always one instance of the service running on each node. Whenever new nodes are started within the underlying cluster group, Ignite will automatically deploy one instance of the service on every new node.

        This method is analogous to calling deployMultiple(name, svc, 0, 1) method.

        Specified by:
        deployNodeSingleton in interface IgniteServices
        Parameters:
        name - Service name.
        svc - Service instance.
      • deployNodeSingletonAsync

        public IgniteFuture<Void> deployNodeSingletonAsync​(String name,
                                                           Service svc)
        Asynchronously deploys a per-node singleton service. Ignite will guarantee that there is always one instance of the service running on each node. Whenever new nodes are started within the underlying cluster group, Ignite will automatically deploy one instance of the service on every new node.

        This method is analogous to calling deployMultipleAsync(name, svc, 0, 1) method.

        Specified by:
        deployNodeSingletonAsync in interface IgniteServices
        Parameters:
        name - Service name.
        svc - Service instance.
        Returns:
        a Future representing pending completion of the operation.
      • deployClusterSingleton

        public void deployClusterSingleton​(String name,
                                           Service svc)
        Deploys a cluster-wide singleton service. Ignite will guarantee that there is always one instance of the service in the cluster. In case if grid node on which the service was deployed crashes or stops, Ignite will automatically redeploy it on another node. However, if the node on which the service is deployed remains in topology, then the service will always be deployed on that node only, regardless of topology changes.

        Note that in case of topology changes, due to network delays, there may be a temporary situation when a singleton service instance will be active on more than one node (e.g. crash detection delay).

        This method is analogous to calling deployMultiple(name, svc, 1, 1) method.

        Specified by:
        deployClusterSingleton in interface IgniteServices
        Parameters:
        name - Service name.
        svc - Service instance.
      • deployClusterSingletonAsync

        public IgniteFuture<Void> deployClusterSingletonAsync​(String name,
                                                              Service svc)
        Asynchronously deploys a cluster-wide singleton service. Ignite will guarantee that there is always one instance of the service in the cluster. In case if grid node on which the service was deployed crashes or stops, Ignite will automatically redeploy it on another node. However, if the node on which the service is deployed remains in topology, then the service will always be deployed on that node only, regardless of topology changes.

        Note that in case of topology changes, due to network delays, there may be a temporary situation when a singleton service instance will be active on more than one node (e.g. crash detection delay).

        This method is analogous to calling deployMultipleAsync(name, svc, 1, 1) method.

        Specified by:
        deployClusterSingletonAsync in interface IgniteServices
        Parameters:
        name - Service name.
        svc - Service instance.
        Returns:
        a Future representing pending completion of the operation.
      • deployMultiple

        public void deployMultiple​(String name,
                                   Service svc,
                                   int totalCnt,
                                   int maxPerNodeCnt)
        Deploys multiple instances of the service on the grid. Ignite will deploy a maximum amount of services equal to 'totalCnt' parameter making sure that there are no more than 'maxPerNodeCnt' service instances running on each node. Whenever topology changes, Ignite will automatically rebalance the deployed services within cluster to make sure that each node will end up with about equal number of deployed instances whenever possible.

        Note that at least one of 'totalCnt' or 'maxPerNodeCnt' parameters must have value greater than 0.

        This method is analogous to the invocation of IgniteServices.deploy(org.apache.ignite.services.ServiceConfiguration) method as follows:

             ServiceConfiguration cfg = new ServiceConfiguration();
        
             cfg.setName(name);
             cfg.setService(svc);
             cfg.setTotalCount(totalCnt);
             cfg.setMaxPerNodeCount(maxPerNodeCnt);
        
             ignite.services().deploy(cfg);
         
        Specified by:
        deployMultiple in interface IgniteServices
        Parameters:
        name - Service name.
        svc - Service instance.
        totalCnt - Maximum number of deployed services in the grid, 0 for unlimited.
        maxPerNodeCnt - Maximum number of deployed services on each node, 0 for unlimited.
      • deployMultipleAsync

        public IgniteFuture<Void> deployMultipleAsync​(String name,
                                                      Service svc,
                                                      int totalCnt,
                                                      int maxPerNodeCnt)
        Asynchronously deploys multiple instances of the service on the grid. Ignite will deploy a maximum amount of services equal to 'totalCnt' parameter making sure that there are no more than 'maxPerNodeCnt' service instances running on each node. Whenever topology changes, Ignite will automatically rebalance the deployed services within cluster to make sure that each node will end up with about equal number of deployed instances whenever possible.

        Note that at least one of 'totalCnt' or 'maxPerNodeCnt' parameters must have value greater than 0.

        This method is analogous to the invocation of IgniteServices.deployAsync(org.apache.ignite.services.ServiceConfiguration) method as follows:

             ServiceConfiguration cfg = new ServiceConfiguration();
        
             cfg.setName(name);
             cfg.setService(svc);
             cfg.setTotalCount(totalCnt);
             cfg.setMaxPerNodeCount(maxPerNodeCnt);
        
             ignite.services().deployAsync(cfg);
         
        Specified by:
        deployMultipleAsync in interface IgniteServices
        Parameters:
        name - Service name.
        svc - Service instance.
        totalCnt - Maximum number of deployed services in the grid, 0 for unlimited.
        maxPerNodeCnt - Maximum number of deployed services on each node, 0 for unlimited.
        Returns:
        a Future representing pending completion of the operation.
      • deployKeyAffinitySingleton

        public void deployKeyAffinitySingleton​(String name,
                                               Service svc,
                                               @Nullable
                                               @Nullable String cacheName,
                                               Object affKey)
        Deploys one instance of this service on the primary node for a given affinity key. Whenever topology changes and primary node assignment changes, Ignite will always make sure that the service is undeployed on the previous primary node and deployed on the new primary node.

        Note that in case of topology changes, due to network delays, there may be a temporary situation when a service instance will be active on more than one node (e.g. crash detection delay).

        This method is analogous to the invocation of IgniteServices.deploy(org.apache.ignite.services.ServiceConfiguration) method as follows:

             ServiceConfiguration cfg = new ServiceConfiguration();
        
             cfg.setName(name);
             cfg.setService(svc);
             cfg.setCacheName(cacheName);
             cfg.setAffinityKey(affKey);
             cfg.setTotalCount(1);
             cfg.setMaxPerNodeCount(1);
        
             ignite.services().deploy(cfg);
         
        Specified by:
        deployKeyAffinitySingleton in interface IgniteServices
        Parameters:
        name - Service name.
        svc - Service instance.
        cacheName - Name of the cache on which affinity for key should be calculated, null for default cache.
        affKey - Affinity cache key.
      • deployKeyAffinitySingletonAsync

        public IgniteFuture<Void> deployKeyAffinitySingletonAsync​(String name,
                                                                  Service svc,
                                                                  @Nullable
                                                                  @Nullable String cacheName,
                                                                  Object affKey)
        Asynchronously deploys one instance of this service on the primary node for a given affinity key. Whenever topology changes and primary node assignment changes, Ignite will always make sure that the service is undeployed on the previous primary node and deployed on the new primary node.

        Note that in case of topology changes, due to network delays, there may be a temporary situation when a service instance will be active on more than one node (e.g. crash detection delay).

        This method is analogous to the invocation of IgniteServices.deployAsync(org.apache.ignite.services.ServiceConfiguration) method as follows:

             ServiceConfiguration cfg = new ServiceConfiguration();
        
             cfg.setName(name);
             cfg.setService(svc);
             cfg.setCacheName(cacheName);
             cfg.setAffinityKey(affKey);
             cfg.setTotalCount(1);
             cfg.setMaxPerNodeCount(1);
        
             ignite.services().deployAsync(cfg);
         
        Specified by:
        deployKeyAffinitySingletonAsync in interface IgniteServices
        Parameters:
        name - Service name.
        svc - Service instance.
        cacheName - Name of the cache on which affinity for key should be calculated, null for default cache.
        affKey - Affinity cache key.
        Returns:
        a Future representing pending completion of the operation.
      • deploy

        public void deploy​(ServiceConfiguration cfg)
        Deploys multiple instances of the service on the grid according to provided configuration. Ignite will deploy a maximum amount of services equal to cfg.getTotalCount() parameter making sure that there are no more than cfg.getMaxPerNodeCount() service instances running on each node. Whenever topology changes, Ignite will automatically rebalance the deployed services within cluster to make sure that each node will end up with about equal number of deployed instances whenever possible.

        If cfg.getAffinityKey() is not null, then Ignite will deploy the service on the primary node for given affinity key. The affinity will be calculated on the cache with cfg.getCacheName() name.

        If cfg.getNodeFilter() is not null, then Ignite will deploy service on all grid nodes for which the provided filter evaluates to true. The node filter will be checked in addition to the underlying cluster group filter, or the whole grid, if the underlying cluster group includes all the cluster nodes.

        Note that at least one of 'totalCnt' or 'maxPerNodeCnt' parameters must have value greater than 0.

        Here is an example of creating service deployment configuration:

             ServiceConfiguration cfg = new ServiceConfiguration();
        
             cfg.setName(name);
             cfg.setService(svc);
             cfg.setTotalCount(0); // Unlimited.
             cfg.setMaxPerNodeCount(2); // Deploy 2 instances of service on each node.
        
             ignite.services().deploy(cfg);
         
        Specified by:
        deploy in interface IgniteServices
        Parameters:
        cfg - Service configuration.
      • deployAsync

        public IgniteFuture<Void> deployAsync​(ServiceConfiguration cfg)
        Asynchronously deploys multiple instances of the service on the grid according to provided configuration. Ignite will deploy a maximum amount of services equal to cfg.getTotalCount() parameter making sure that there are no more than cfg.getMaxPerNodeCount() service instances running on each node. Whenever topology changes, Ignite will automatically rebalance the deployed services within cluster to make sure that each node will end up with about equal number of deployed instances whenever possible.

        If cfg.getAffinityKey() is not null, then Ignite will deploy the service on the primary node for given affinity key. The affinity will be calculated on the cache with cfg.getCacheName() name.

        If cfg.getNodeFilter() is not null, then Ignite will deploy service on all grid nodes for which the provided filter evaluates to true. The node filter will be checked in addition to the underlying cluster group filter, or the whole grid, if the underlying cluster group includes all the cluster nodes.

        Note that at least one of 'totalCnt' or 'maxPerNodeCnt' parameters must have value greater than 0.

        Here is an example of creating service deployment configuration:

             ServiceConfiguration cfg = new ServiceConfiguration();
        
             cfg.setName(name);
             cfg.setService(svc);
             cfg.setTotalCount(0); // Unlimited.
             cfg.setMaxPerNodeCount(2); // Deploy 2 instances of service on each node.
        
             ignite.services().deployAsync(cfg);
         
        Specified by:
        deployAsync in interface IgniteServices
        Parameters:
        cfg - Service configuration.
        Returns:
        a Future representing pending completion of the operation.
      • deployAll

        public void deployAll​(Collection<ServiceConfiguration> cfgs)
        Deploys multiple services described by provided configurations. Depending on specified parameters, multiple instances of the same service may be deployed (see ServiceConfiguration). Whenever topology changes, Ignite will automatically rebalance the deployed services within cluster to make sure that each node will end up with about equal number of deployed instances whenever possible. If deployment of some of the provided services fails, then ServiceDeploymentException containing a list of failed services will be thrown. It is guaranteed that all services that were provided to this method and are not present in the list of failed services are successfully deployed by the moment of the exception being thrown. Note that if exception is thrown, then partial deployment may have occurred.
        Specified by:
        deployAll in interface IgniteServices
        Parameters:
        cfgs - Collection of service configurations to be deployed.
        See Also:
        IgniteServices.deploy(ServiceConfiguration), IgniteServices.deployAllAsync(Collection)
      • deployAllAsync

        public IgniteFuture<Void> deployAllAsync​(Collection<ServiceConfiguration> cfgs)
        Asynchronously deploys multiple services described by provided configurations. Depending on specified parameters, multiple instances of the same service may be deployed (see ServiceConfiguration). Whenever topology changes, Ignite will automatically rebalance the deployed services within cluster to make sure that each node will end up with about equal number of deployed instances whenever possible. If deployment of some of the provided services fails, then ServiceDeploymentException containing a list of failed services will be thrown from get() method of the returned future. It is guaranteed that all services, that were provided to this method and are not present in the list of failed services, are successfully deployed by the moment of the exception being thrown. Note that if exception is thrown, then partial deployment may have occurred.
        Specified by:
        deployAllAsync in interface IgniteServices
        Parameters:
        cfgs - Collection of service configurations to be deployed.
        Returns:
        a Future representing pending completion of the operation.
        See Also:
        IgniteServices.deploy(ServiceConfiguration), IgniteServices.deployAll(Collection)
      • cancelAll

        public void cancelAll​(Collection<String> names)
        Cancels services with specified names.

        Note that depending on user logic, it may still take extra time for a service to finish execution, even after it was cancelled.

        Supports asynchronous execution (see IgniteAsyncSupport).

        Specified by:
        cancelAll in interface IgniteServices
        Parameters:
        names - Names of services to cancel.
      • cancelAllAsync

        public IgniteFuture<Void> cancelAllAsync​(Collection<String> names)
        Asynchronously cancels services with specified names.

        Note that depending on user logic, it may still take extra time for a service to finish execution, even after it was cancelled.

        Specified by:
        cancelAllAsync in interface IgniteServices
        Parameters:
        names - Names of services to cancel.
        Returns:
        a Future representing pending completion of the operation.
      • cancelAll

        public void cancelAll()
        Cancels all deployed services.

        Note that depending on user logic, it may still take extra time for a service to finish execution, even after it was cancelled.

        Supports asynchronous execution (see IgniteAsyncSupport).

        Specified by:
        cancelAll in interface IgniteServices
      • cancelAllAsync

        public IgniteFuture<Void> cancelAllAsync()
        Asynchronously cancels all deployed services.

        Note that depending on user logic, it may still take extra time for a service to finish execution, even after it was cancelled.

        Specified by:
        cancelAllAsync in interface IgniteServices
        Returns:
        a Future representing pending completion of the operation.
      • serviceProxy

        public <T> T serviceProxy​(String name,
                                  Class<? super T> svcItf,
                                  boolean sticky)
                           throws IgniteException
        Gets a handle on remote or local service. The proxy is dynamically created and provided for the specified service.
        Specified by:
        serviceProxy in interface IgniteServices
        Type Parameters:
        T - Service type.
        Parameters:
        name - Service name.
        svcItf - Interface for the service.
        sticky - Whether or not Ignite should always contact the same remote service or try to load-balance between services.
        Returns:
        Proxy over service.
        Throws:
        IgniteException - If failed to create service proxy.
      • serviceProxy

        public <T> T serviceProxy​(String name,
                                  Class<? super T> svcItf,
                                  boolean sticky,
                                  long timeout)
                           throws IgniteException
        Gets a handle on remote or local service with the timeout. The proxy is dynamically created and provided for the specified service.
        Specified by:
        serviceProxy in interface IgniteServices
        Type Parameters:
        T - Service type.
        Parameters:
        name - Service name.
        svcItf - Interface for the service.
        sticky - Whether or not Ignite should always contact the same remote service or try to load-balance between services.
        timeout - If greater than 0 created proxy will wait for service availability only specified time, and will limit remote service invocation time.
        Returns:
        Proxy over service.
        Throws:
        IgniteException - If failed to create service proxy.
      • serviceProxy

        public <T> T serviceProxy​(String name,
                                  Class<? super T> svcItf,
                                  boolean sticky,
                                  @Nullable
                                  @Nullable ServiceCallContext callCtx)
                           throws IgniteException
        Gets a handle on remote or local service with the specified caller context. The proxy is dynamically created and provided for the specified service.
        Specified by:
        serviceProxy in interface IgniteServices
        Type Parameters:
        T - Service type.
        Parameters:
        name - Service name.
        svcItf - Interface for the service.
        sticky - Whether or not Ignite should always contact the same remote service or try to load-balance between services.
        callCtx - Service call context.
        Returns:
        Proxy over service.
        Throws:
        IgniteException - If failed to create service proxy.
        See Also:
        ServiceCallContext
      • serviceProxy

        public <T> T serviceProxy​(String name,
                                  Class<? super T> svcItf,
                                  boolean sticky,
                                  @Nullable
                                  @Nullable ServiceCallContext callCtx,
                                  long timeout)
                           throws IgniteException
        Gets a handle on remote or local service with the specified caller context and the timeout. The proxy is dynamically created and provided for the specified service.
        Specified by:
        serviceProxy in interface IgniteServices
        Type Parameters:
        T - Service type.
        Parameters:
        name - Service name.
        svcItf - Interface for the service.
        sticky - Whether or not Ignite should always contact the same remote service or try to load-balance between services.
        callCtx - Service call context.
        timeout - If greater than 0 created proxy will wait for service availability only specified time, and will limit remote service invocation time.
        Returns:
        Proxy over service.
        Throws:
        IgniteException - If failed to create service proxy.
        See Also:
        ServiceCallContext
      • serviceProxy

        public <T> T serviceProxy​(String name,
                                  Class<? super T> svcItf,
                                  boolean sticky,
                                  @Nullable
                                  @Nullable Supplier<Map<String,​Object>> callAttrsProvider,
                                  long timeout)
                           throws IgniteException
        Gets a remote handle on the service. If service is available locally and no caller context provider is specified, then a local instance is returned and the timeout is ignored, otherwise, a proxy is dynamically created and provided for the specified service.
        Specified by:
        serviceProxy in interface IgniteServicesEx
        Type Parameters:
        T - Service type.
        Parameters:
        name - Service name.
        svcItf - Interface for the service.
        sticky - Whether or not Ignite should always contact the same remote service or try to load-balance between services.
        callAttrsProvider - Service call context attributes provider.
        timeout - If greater than 0 created proxy will wait for service availability only specified time, and will limit remote service invocation time.
        Returns:
        Either proxy over remote service or local service if it is deployed locally and no caller context provider is specified.
        Throws:
        IgniteException - If failed to create service proxy.