Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-23346

.NET: AttributeNodeFilter does not work with Services

    XMLWordPrintableJSON

Details

    • Docs Required, Release Notes Required

    Description

      Add the following to ServicesClientTest.cs

              [Test]
              public void TestNodeFilter()
              {
                  ServerServices.Deploy(new ServiceConfiguration
                  {
                      Name = "s",
                      Service = new TestService(),
                      TotalCount = 2,
                      MaxPerNodeCount = 2,
                      NodeFilter = new AttributeNodeFilter("x", "y")
                  });
      
                  var services = Client.GetServices();
      
                  var proxy = services.GetServiceProxy<ITestService>("s");
      
                  proxy.PersonMethod(new Person(1));
              }
      

      Result:

      Apache.Ignite.Core.Services.ServiceDeploymentException : Service deployment failed with an exception. Examine InnerException for details.
        ----> Apache.Ignite.Core.Services.ServiceDeploymentException : Failed to deploy some services.
        ----> Apache.Ignite.Core.Common.JavaException : class org.apache.ignite.services.ServiceDeploymentException: Failed to deploy some services.
      	at org.apache.ignite.internal.processors.service.GridServiceDeploymentCompoundFuture.processFailure(GridServiceDeploymentCompoundFuture.java:52)
      	at org.apache.ignite.internal.util.future.GridCompoundFuture.apply(GridCompoundFuture.java:126)
      	at org.apache.ignite.internal.util.future.GridCompoundFuture.apply(GridCompoundFuture.java:46)
      	at org.apache.ignite.internal.util.future.GridFutureAdapter.notifyListener(GridFutureAdapter.java:474)
      	at org.apache.ignite.internal.util.future.GridFutureAdapter.unblock(GridFutureAdapter.java:350)
      	at org.apache.ignite.internal.util.future.GridFutureAdapter.unblockAll(GridFutureAdapter.java:338)
      	at org.apache.ignite.internal.util.future.GridFutureAdapter.onDone(GridFutureAdapter.java:585)
      	at org.apache.ignite.internal.util.future.GridFutureAdapter.onDone(GridFutureAdapter.java:565)
      	at org.apache.ignite.internal.util.future.GridFutureAdapter.onDone(GridFutureAdapter.java:553)
      	at org.apache.ignite.internal.processors.service.IgniteServiceProcessor.completeInitiatingFuture(IgniteServiceProcessor.java:1518)
      	at org.apache.ignite.internal.processors.service.ServiceDeploymentTask.lambda$completeInitiatingFuture$10(ServiceDeploymentTask.java:546)
      	at java.base/java.util.HashMap.forEach(HashMap.java:1337)
      	at java.base/java.util.Collections$UnmodifiableMap.forEach(Collections.java:1505)
      	at org.apache.ignite.internal.processors.service.ServiceDeploymentTask.completeInitiatingFuture(ServiceDeploymentTask.java:515)
      	at org.apache.ignite.internal.processors.service.ServiceDeploymentTask.completeSuccess(ServiceDeploymentTask.java:773)
      	at org.apache.ignite.internal.processors.service.ServiceDeploymentTask.lambda$onReceiveFullDeploymentsMessage$9(ServiceDeploymentTask.java:495)
      	at org.apache.ignite.internal.util.IgniteUtils.wrapThreadLoader(IgniteUtils.java:7530)
      	at org.apache.ignite.internal.processors.closure.GridClosureProcessor$1.body(GridClosureProcessor.java:649)
      	at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:125)
      	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
      	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
      	at java.base/java.lang.Thread.run(Thread.java:829)
      	Suppressed: class org.apache.ignite.IgniteCheckedException: Failed to calculate assignments for service, cfg=LazyServiceConfiguration [srvcClsName=org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetServiceImpl, svcCls=, nodeFilterCls=PlatformClusterNodeFilterImpl]
      		at org.apache.ignite.internal.processors.service.ServiceDeploymentTask.reassign(ServiceDeploymentTask.java:593)
      		at org.apache.ignite.internal.processors.service.ServiceDeploymentTask.lambda$processDeploymentActions$5(ServiceDeploymentTask.java:307)
      		at java.base/java.util.HashMap.forEach(HashMap.java:1337)
      		at java.base/java.util.Collections$UnmodifiableMap.forEach(Collections.java:1505)
      		at org.apache.ignite.internal.processors.service.ServiceDeploymentTask.processDeploymentActions(ServiceDeploymentTask.java:301)
      		at org.apache.ignite.internal.processors.service.ServiceDeploymentTask.init(ServiceDeploymentTask.java:261)
      		at org.apache.ignite.internal.processors.service.ServiceDeploymentManager$ServicesDeploymentWorker.body(ServiceDeploymentManager.java:475)
      		at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:125)
      		... 1 more
      		Suppressed: class org.apache.ignite.IgniteCheckedException: Failed to calculate assignments for service, cfg=LazyServiceConfiguration [srvcClsName=org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetServiceImpl, svcCls=PlatformDotNetServiceImpl, nodeFilterCls=PlatformClusterNodeFilterImpl]
      			... 9 more
      		Caused by: class org.apache.ignite.IgniteException: Should not be called from .NET side.
      			at org.apache.ignite.internal.processors.platform.callback.PlatformCallbackUtils.inLongOutLong(Native Method)
      			at org.apache.ignite.internal.processors.platform.callback.PlatformCallbackGateway.clusterNodeFilterApply(PlatformCallbackGateway.java:963)
      			at org.apache.ignite.internal.processors.platform.cluster.PlatformClusterNodeFilterImpl.apply(PlatformClusterNodeFilterImpl.java:66)
      			at org.apache.ignite.internal.processors.platform.cluster.PlatformClusterNodeFilterImpl.apply(PlatformClusterNodeFilterImpl.java:33)
      			at org.apache.ignite.internal.processors.service.IgniteServiceProcessor.reassign(IgniteServiceProcessor.java:1165)
      			at org.apache.ignite.internal.processors.service.ServiceDeploymentTask.reassign(ServiceDeploymentTask.java:582)
      			... 8 more
      	Caused by: class org.apache.ignite.IgniteException: Should not be called from .NET side.
      		at org.apache.ignite.internal.processors.platform.callback.PlatformCallbackUtils.inLongOutLong(Native Method)
      		at org.apache.ignite.internal.processors.platform.callback.PlatformCallbackGateway.clusterNodeFilterApply(PlatformCallbackGateway.java:963)
      		at org.apache.ignite.internal.processors.platform.cluster.PlatformClusterNodeFilterImpl.apply(PlatformClusterNodeFilterImpl.java:66)
      		at org.apache.ignite.internal.processors.platform.cluster.PlatformClusterNodeFilterImpl.apply(PlatformClusterNodeFilterImpl.java:33)
      		at org.apache.ignite.internal.processors.service.IgniteServiceProcessor.reassign(IgniteServiceProcessor.java:1165)
      		at org.apache.ignite.internal.processors.service.ServiceDeploymentTask.reassign(ServiceDeploymentTask.java:582)
      		... 8 more
      

      Workaround

      Implement your own AttributeNodeFilter

          public class MyAttributeNodeFilter : IClusterNodeFilter
          {
              private readonly IDictionary<string, object> _attributes;
      
              public MyAttributeNodeFilter(IDictionary<string, object> attributes)
              {
                  _attributes = attributes;
              }
      
              public bool Invoke(IClusterNode node)
              {
                  foreach (var attr in _attributes)
                  {
                      if (!node.Attributes.TryGetValue(attr.Key, out var nodeAttr) || 
                          !nodeAttr.Equals(attr.Value))
                      {
                          return false;
                      }
                  }
      
                  return true;
              }
          }
      

      Attachments

        Activity

          People

            ptupitsyn Pavel Tupitsyn
            ptupitsyn Pavel Tupitsyn
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: