You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by al...@apache.org on 2021/12/30 09:25:17 UTC
[ignite] branch master updated: IGNITE-15829 Thin client: Services with ServiceCallContext support - Fixes #9629.
This is an automated email from the ASF dual-hosted git repository.
alexpl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new beb32a8 IGNITE-15829 Thin client: Services with ServiceCallContext support - Fixes #9629.
beb32a8 is described below
commit beb32a85a8af8a6e3c46ed9afdea60fabd3e65dd
Author: Pavel Pereslegin <xx...@gmail.com>
AuthorDate: Thu Dec 30 14:20:54 2021 +0500
IGNITE-15829 Thin client: Services with ServiceCallContext support - Fixes #9629.
Signed-off-by: Aleksey Plekhanov <pl...@gmail.com>
---
.../clients/JavaThinCompatibilityTest.java | 69 +++++++++++++++--
.../org/apache/ignite/client/ClientServices.java | 36 +++++++++
.../apache/ignite/internal/IgniteServicesEx.java | 6 +-
.../apache/ignite/internal/IgniteServicesImpl.java | 19 +++--
.../internal/client/thin/ClientServicesImpl.java | 45 ++++++++++-
.../client/thin/ProtocolBitmaskFeature.java | 5 +-
.../platform/client/ClientBitmaskFeature.java | 5 +-
.../platform/client/ClientMessageParser.java | 2 +-
.../client/service/ClientServiceInvokeRequest.java | 15 +++-
.../platform/services/PlatformServices.java | 4 +-
.../resource/GridResourceServiceInjector.java | 7 +-
.../processors/service/GridServiceProxy.java | 80 ++++++++-----------
.../processors/service/IgniteServiceProcessor.java | 9 +--
.../service/ServiceCallContextHolder.java | 7 +-
.../processors/service/ServiceCallContextImpl.java | 27 +------
.../apache/ignite/services/ServiceCallContext.java | 3 +-
.../ignite/internal/client/thin/ServicesTest.java | 89 +++++++++++++++-------
.../service/IgniteServiceCallContextTest.java | 15 ++++
.../platform/PlatformServiceCallThinTask.java | 10 +--
.../Client/Services/ITestService.cs | 6 ++
.../Client/Services/ServicesClientTest.cs | 49 +++++++++++-
.../Client/Services/TestService.cs | 24 +++++-
.../Services/CallPlatformServiceTest.cs | 4 +-
.../Services/ServicesTest.cs | 25 ++++++
.../Client/Services/IServicesClient.cs | 15 ++++
.../Impl/Client/ClientBitmaskFeature.cs | 3 +-
.../Impl/Client/Services/ServicesClient.cs | 30 +++++++-
.../Impl/Services/ServiceProxySerializer.cs | 6 +-
.../Apache.Ignite.Core/Impl/Services/Services.cs | 27 +++++--
29 files changed, 474 insertions(+), 168 deletions(-)
diff --git a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/clients/JavaThinCompatibilityTest.java b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/clients/JavaThinCompatibilityTest.java
index a584d92..b9f85f1 100644
--- a/modules/compatibility/src/test/java/org/apache/ignite/compatibility/clients/JavaThinCompatibilityTest.java
+++ b/modules/compatibility/src/test/java/org/apache/ignite/compatibility/clients/JavaThinCompatibilityTest.java
@@ -18,7 +18,6 @@
package org.apache.ignite.compatibility.clients;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -57,7 +56,9 @@ import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.lang.IgniteProductVersion;
import org.apache.ignite.platform.PlatformType;
+import org.apache.ignite.resources.ServiceContextResource;
import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceCallContext;
import org.apache.ignite.services.ServiceContext;
import org.apache.ignite.testframework.GridTestUtils;
import org.jetbrains.annotations.NotNull;
@@ -67,6 +68,7 @@ import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.apache.ignite.internal.client.thin.ProtocolBitmaskFeature.GET_SERVICE_DESCRIPTORS;
+import static org.apache.ignite.internal.client.thin.ProtocolBitmaskFeature.SERVICE_INVOKE_CALLCTX;
import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;
/**
@@ -91,6 +93,9 @@ public class JavaThinCompatibilityTest extends AbstractClientCompatibilityTest {
@Override protected void initNode(Ignite ignite) {
ignite.services().deployNodeSingleton("test_service", new EchoService());
+ if (ver.compareTo(VER_2_13_0) >= 0)
+ ignite.services().deployNodeSingleton("ctx_service", new CtxService());
+
super.initNode(ignite);
}
@@ -325,6 +330,34 @@ public class JavaThinCompatibilityTest extends AbstractClientCompatibilityTest {
}
/** */
+ private void testServicesWithCallerContext() {
+ X.println(">>>> Testing services with caller context");
+
+ ServiceCallContext callCtx = ServiceCallContext.builder().put("key", "value").build();
+
+ try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
+ assertEquals("value", client.services().serviceProxy("ctx_service", CtxServiceInterface.class, callCtx)
+ .attribute("key"));
+ }
+ }
+
+ /** */
+ private void testServicesWithCallerContextThrows() {
+ X.println(">>>> Testing services with caller context throws");
+
+ try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
+ ServiceCallContext callCtx = ServiceCallContext.builder().put("key", "value").build();
+
+ EchoServiceInterface svc =
+ client.services().serviceProxy("test_service", EchoServiceInterface.class, callCtx);
+
+ Throwable err = assertThrowsWithCause(() -> svc.echo(1), ClientFeatureNotSupportedByServerException.class);
+
+ assertEquals("Feature " + SERVICE_INVOKE_CALLCTX.name() + " is not supported by the server", err.getMessage());
+ }
+ }
+
+ /** */
private void testContinuousQueries() throws Exception {
X.println(">>>> Testing continuous queries");
@@ -380,10 +413,14 @@ public class JavaThinCompatibilityTest extends AbstractClientCompatibilityTest {
testContinuousQueries();
if (clientVer.compareTo(VER_2_13_0) >= 0) {
- if (serverVer.compareTo(VER_2_13_0) >= 0)
+ if (serverVer.compareTo(VER_2_13_0) >= 0) {
testServiceDescriptors();
- else
+ testServicesWithCallerContext();
+ }
+ else {
testServiceDescriptorsThrows();
+ testServicesWithCallerContextThrows();
+ }
}
}
@@ -392,11 +429,9 @@ public class JavaThinCompatibilityTest extends AbstractClientCompatibilityTest {
X.println(">>>> Testing services descriptors");
try (IgniteClient client = Ignition.startClient(new ClientConfiguration().setAddresses(ADDR))) {
- Collection<ClientServiceDescriptor> svcs = client.services().serviceDescriptors();
+ assertEquals(2, client.services().serviceDescriptors().size());
- assertEquals(1, svcs.size());
-
- ClientServiceDescriptor svc = svcs.iterator().next();
+ ClientServiceDescriptor svc = client.services().serviceDescriptor("test_service");
assertEquals("test_service", svc.name());
assertEquals(EchoService.class.getName(), svc.serviceClass());
@@ -460,6 +495,26 @@ public class JavaThinCompatibilityTest extends AbstractClientCompatibilityTest {
}
}
+ /** Service for testing the attributes of a service call context. */
+ public static interface CtxServiceInterface {
+ /** */
+ public String attribute(String name);
+ }
+
+ /** */
+ public static class CtxService implements Service, CtxServiceInterface {
+ /** Service context. */
+ @ServiceContextResource
+ private ServiceContext svcCtx;
+
+ /** {@inheritDoc} */
+ @Override public String attribute(String name) {
+ ServiceCallContext callCtx = svcCtx.currentCallContext();
+
+ return svcCtx == null ? null : callCtx.attribute(name);
+ }
+ }
+
/** */
public static class EchoJob implements ComputeJob {
/** Value. */
diff --git a/modules/core/src/main/java/org/apache/ignite/client/ClientServices.java b/modules/core/src/main/java/org/apache/ignite/client/ClientServices.java
index 6a46cbd..7f30aec 100644
--- a/modules/core/src/main/java/org/apache/ignite/client/ClientServices.java
+++ b/modules/core/src/main/java/org/apache/ignite/client/ClientServices.java
@@ -18,6 +18,8 @@
package org.apache.ignite.client;
import java.util.Collection;
+import org.apache.ignite.lang.IgniteExperimental;
+import org.apache.ignite.services.ServiceCallContext;
/**
* Thin client services facade.
@@ -72,4 +74,38 @@ public interface ClientServices {
* @return Metadata about all deployed services in the grid.
*/
public ClientServiceDescriptor serviceDescriptor(String name);
+
+ /**
+ * Gets a remote handle on the service with the specified caller context.
+ * <p>
+ * Note: There are no guarantees that each method invocation for the same proxy will always contact the same remote
+ * service (on the same remote node).
+ *
+ * @param name Service name.
+ * @param svcItf Interface for the service.
+ * @param callCtx Service call context.
+ * @param <T> Service type.
+ * @return Proxy over remote service.
+ * @see ServiceCallContext
+ */
+ @IgniteExperimental
+ public <T> T serviceProxy(String name, Class<? super T> svcItf, ServiceCallContext callCtx);
+
+ /**
+ * Gets a remote handle on the service with the specified caller context and timeout.
+ * <p>
+ * Note: There are no guarantees that each method invocation for the same proxy will always contact the same remote
+ * service (on the same remote node).
+ *
+ * @param name Service name.
+ * @param svcItf Interface for the service.
+ * @param callCtx Service call context.
+ * @param timeout If greater than 0 created proxy will wait for service availability only specified time,
+ * and will limit remote service invocation time.
+ * @param <T> Service type.
+ * @return Proxy over remote service.
+ * @see ServiceCallContext
+ */
+ @IgniteExperimental
+ public <T> T serviceProxy(String name, Class<? super T> svcItf, ServiceCallContext callCtx, long timeout);
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesEx.java
index 0966a18..93be0af 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesEx.java
@@ -17,10 +17,10 @@
package org.apache.ignite.internal;
+import java.util.Map;
import java.util.function.Supplier;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteServices;
-import org.apache.ignite.services.ServiceCallContext;
import org.jetbrains.annotations.Nullable;
/**
@@ -36,7 +36,7 @@ public interface IgniteServicesEx extends IgniteServices {
* @param svcItf Interface for the service.
* @param sticky Whether or not Ignite should always contact the same remote
* service or try to load-balance between services.
- * @param callCtxProvider Caller context provider.
+ * @param callAttrsProvider Service call context attributes provider.
* @param timeout If greater than 0 created proxy will wait for service availability only specified time,
* and will limit remote service invocation time.
* @param <T> Service type.
@@ -48,7 +48,7 @@ public interface IgniteServicesEx extends IgniteServices {
String name,
Class<? super T> svcItf,
boolean sticky,
- @Nullable Supplier<ServiceCallContext> callCtxProvider,
+ @Nullable Supplier<Map<String, Object>> callAttrsProvider,
long timeout
) throws IgniteException;
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java
index 115bb8f..f9a83ec 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteServicesImpl.java
@@ -24,18 +24,21 @@ import java.io.ObjectOutput;
import java.io.ObjectStreamException;
import java.util.Collection;
import java.util.Collections;
+import java.util.Map;
import java.util.function.Supplier;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.IgniteServices;
import org.apache.ignite.cluster.ClusterGroup;
import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
+import org.apache.ignite.internal.processors.service.ServiceCallContextImpl;
import org.apache.ignite.internal.util.future.IgniteFutureImpl;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.services.Service;
import org.apache.ignite.services.ServiceCallContext;
+import org.apache.ignite.services.ServiceCallContextBuilder;
import org.apache.ignite.services.ServiceConfiguration;
import org.apache.ignite.services.ServiceDescriptor;
import org.jetbrains.annotations.Nullable;
@@ -385,7 +388,7 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
final boolean sticky,
final long timeout
) throws IgniteException {
- return (T)serviceProxy(name, svcItf, sticky, (Supplier<ServiceCallContext>)null, timeout);
+ return (T)serviceProxy(name, svcItf, sticky, (Supplier<Map<String, Object>>)null, timeout);
}
/** */
@@ -417,7 +420,11 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
@Nullable ServiceCallContext callCtx,
final long timeout
) throws IgniteException {
- return (T)serviceProxy(name, svcItf, sticky, callCtx != null ? () -> callCtx : null, timeout);
+ A.ensure(callCtx == null || callCtx instanceof ServiceCallContextImpl,
+ "\"callCtx\" has an invalid type. Custom implementation of " + ServiceCallContext.class.getSimpleName() +
+ " is not supported. Please use " + ServiceCallContextBuilder.class.getSimpleName() + " to create it.");
+
+ return (T)serviceProxy(name, svcItf, sticky, callCtx != null ? ((ServiceCallContextImpl)callCtx)::values : null, timeout);
}
/** {@inheritDoc} */
@@ -425,10 +432,10 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
final String name,
final Class<? super T> svcItf,
final boolean sticky,
- @Nullable Supplier<ServiceCallContext> callCtxProvider,
+ @Nullable Supplier<Map<String, Object>> callAttrsProvider,
final long timeout
) throws IgniteException {
- return serviceProxy(name, svcItf, sticky, callCtxProvider, timeout, false);
+ return serviceProxy(name, svcItf, sticky, callAttrsProvider, timeout, false);
}
/** */
@@ -436,7 +443,7 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
final String name,
final Class<? super T> svcItf,
final boolean sticky,
- @Nullable Supplier<ServiceCallContext> callCtxProvider,
+ @Nullable Supplier<Map<String, Object>> callAttrsProvider,
final long timeout,
final boolean keepBinary
) {
@@ -448,7 +455,7 @@ public class IgniteServicesImpl extends AsyncSupportAdapter implements IgniteSer
guard();
try {
- return (T)ctx.service().serviceProxy(prj, name, svcItf, sticky, callCtxProvider, timeout, keepBinary);
+ return (T)ctx.service().serviceProxy(prj, name, svcItf, sticky, callAttrsProvider, timeout, keepBinary);
}
finally {
unguard();
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientServicesImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientServicesImpl.java
index bc20fea..f9fcb37 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientServicesImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ClientServicesImpl.java
@@ -23,6 +23,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Map;
import java.util.UUID;
import org.apache.ignite.client.ClientClusterGroup;
import org.apache.ignite.client.ClientException;
@@ -31,10 +32,14 @@ import org.apache.ignite.client.ClientServiceDescriptor;
import org.apache.ignite.client.ClientServices;
import org.apache.ignite.internal.binary.BinaryRawWriterEx;
import org.apache.ignite.internal.binary.BinaryReaderExImpl;
+import org.apache.ignite.internal.processors.service.ServiceCallContextImpl;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.A;
import org.apache.ignite.platform.PlatformServiceMethod;
import org.apache.ignite.platform.PlatformType;
+import org.apache.ignite.services.ServiceCallContext;
+import org.apache.ignite.services.ServiceCallContextBuilder;
+import org.jetbrains.annotations.Nullable;
/**
* Implementation of {@link ClientServices}.
@@ -73,11 +78,25 @@ class ClientServicesImpl implements ClientServices {
/** {@inheritDoc} */
@Override public <T> T serviceProxy(String name, Class<? super T> svcItf, long timeout) {
+ return serviceProxy(name, svcItf, null, timeout);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> T serviceProxy(String name, Class<? super T> svcItf, ServiceCallContext callCtx) {
+ return serviceProxy(name, svcItf, callCtx, 0);
+ }
+
+ /** {@inheritDoc} */
+ @Override public <T> T serviceProxy(String name, Class<? super T> svcItf, ServiceCallContext callCtx, long timeout) {
A.notNullOrEmpty(name, "name");
A.notNull(svcItf, "svcItf");
+ A.ensure(callCtx == null || callCtx instanceof ServiceCallContextImpl,
+ "\"callCtx\" has an invalid type. Custom implementation of " + ServiceCallContext.class.getSimpleName() +
+ " is not supported. Please use " + ServiceCallContextBuilder.class.getSimpleName() + " to create it.");
return (T)Proxy.newProxyInstance(svcItf.getClassLoader(), new Class[] {svcItf},
- new ServiceInvocationHandler<>(name, timeout, grp));
+ new ServiceInvocationHandler<>(name, timeout, grp,
+ callCtx == null ? null : ((ServiceCallContextImpl)callCtx).values()));
}
/** {@inheritDoc} */
@@ -165,14 +184,25 @@ class ClientServicesImpl implements ClientServices {
/** Cluster group. */
private final ClientClusterGroupImpl grp;
+ /** Service call context attributes. */
+ private final Map<String, Object> callAttrs;
+
/**
* @param name Service name.
* @param timeout Timeout.
+ * @param grp Cluster group.
+ * @param callAttrs Service call context attributes.
*/
- private ServiceInvocationHandler(String name, long timeout, ClientClusterGroupImpl grp) {
+ private ServiceInvocationHandler(
+ String name,
+ long timeout,
+ ClientClusterGroupImpl grp,
+ @Nullable Map<String, Object> callAttrs
+ ) {
this.name = name;
this.timeout = timeout;
this.grp = grp;
+ this.callAttrs = callAttrs;
}
/** {@inheritDoc} */
@@ -195,6 +225,9 @@ class ClientServicesImpl implements ClientServices {
/**
* @param ch Payload output channel.
+ * @param nodeIds Node IDs.
+ * @param method Method to call.
+ * @param args Method args.
*/
private void writeServiceInvokeRequest(
PayloadOutputChannel ch,
@@ -202,7 +235,8 @@ class ClientServicesImpl implements ClientServices {
Method method,
Object[] args
) {
- ch.clientChannel().protocolCtx().checkFeatureSupported(ProtocolBitmaskFeature.SERVICE_INVOKE);
+ ch.clientChannel().protocolCtx().checkFeatureSupported(callAttrs != null ?
+ ProtocolBitmaskFeature.SERVICE_INVOKE_CALLCTX : ProtocolBitmaskFeature.SERVICE_INVOKE);
try (BinaryRawWriterEx writer = utils.createBinaryWriter(ch.out())) {
writer.writeString(name);
@@ -238,6 +272,11 @@ class ClientServicesImpl implements ClientServices {
writer.writeObject(args[i]);
}
}
+
+ if (callAttrs != null)
+ writer.writeMap(callAttrs);
+ else if (ch.clientChannel().protocolCtx().isFeatureSupported(ProtocolBitmaskFeature.SERVICE_INVOKE_CALLCTX))
+ writer.writeMap(null);
}
}
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ProtocolBitmaskFeature.java b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ProtocolBitmaskFeature.java
index 1650cc9..568e68a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ProtocolBitmaskFeature.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/client/thin/ProtocolBitmaskFeature.java
@@ -50,7 +50,10 @@ public enum ProtocolBitmaskFeature {
QRY_PARTITIONS_BATCH_SIZE(7),
/** Handle of {@link ClientServices#serviceDescriptors()}. */
- GET_SERVICE_DESCRIPTORS(9);
+ GET_SERVICE_DESCRIPTORS(9),
+
+ /** Invoke service methods with caller context. */
+ SERVICE_INVOKE_CALLCTX(10);
/** */
private static final EnumSet<ProtocolBitmaskFeature> ALL_FEATURES_AS_ENUM_SET =
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientBitmaskFeature.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientBitmaskFeature.java
index 5c195db..ab8ac57 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientBitmaskFeature.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientBitmaskFeature.java
@@ -53,7 +53,10 @@ public enum ClientBitmaskFeature implements ThinProtocolFeature {
BINARY_CONFIGURATION(8),
/** Handle of {@link ClientServices#serviceDescriptors()}. */
- GET_SERVICE_DESCRIPTORS(9);
+ GET_SERVICE_DESCRIPTORS(9),
+
+ /** Invoke service methods with caller context. */
+ SERVICE_INVOKE_CALLCTX(10);
/** */
private static final EnumSet<ClientBitmaskFeature> ALL_FEATURES_AS_ENUM_SET =
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
index 9f134d9..f3fefeb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/ClientMessageParser.java
@@ -491,7 +491,7 @@ public class ClientMessageParser implements ClientListenerMessageParser {
return new ClientExecuteTaskRequest(reader);
case OP_SERVICE_INVOKE:
- return new ClientServiceInvokeRequest(reader);
+ return new ClientServiceInvokeRequest(reader, protocolCtx);
case OP_SERVICE_GET_DESCRIPTORS:
return new ClientServiceGetDescriptorsRequest(reader);
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/service/ClientServiceInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/service/ClientServiceInvokeRequest.java
index c329345..907f95a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/service/ClientServiceInvokeRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/service/ClientServiceInvokeRequest.java
@@ -35,6 +35,7 @@ import org.apache.ignite.internal.cluster.ClusterGroupAdapter;
import org.apache.ignite.internal.processors.platform.PlatformNativeException;
import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
import org.apache.ignite.internal.processors.platform.client.ClientObjectResponse;
+import org.apache.ignite.internal.processors.platform.client.ClientProtocolContext;
import org.apache.ignite.internal.processors.platform.client.ClientRequest;
import org.apache.ignite.internal.processors.platform.client.ClientResponse;
import org.apache.ignite.internal.processors.platform.services.PlatformService;
@@ -45,6 +46,8 @@ import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.services.Service;
import org.apache.ignite.services.ServiceDescriptor;
+import static org.apache.ignite.internal.processors.platform.client.ClientBitmaskFeature.SERVICE_INVOKE_CALLCTX;
+
/**
* Request to invoke service method.
*/
@@ -82,12 +85,16 @@ public class ClientServiceInvokeRequest extends ClientRequest {
/** Objects reader. */
private final BinaryRawReaderEx reader;
+ /** Service call context attributes. */
+ private final Map<String, Object> callAttrs;
+
/**
* Constructor.
*
* @param reader Reader.
+ * @param protocolCtx Protocol context.
*/
- public ClientServiceInvokeRequest(BinaryReaderExImpl reader) {
+ public ClientServiceInvokeRequest(BinaryReaderExImpl reader, ClientProtocolContext protocolCtx) {
super(reader);
name = reader.readString();
@@ -128,6 +135,8 @@ public class ClientServiceInvokeRequest extends ClientRequest {
args[i] = reader.readObjectDetached();
}
+ callAttrs = protocolCtx.isFeatureSupported(SERVICE_INVOKE_CALLCTX) ? reader.readMap() : null;
+
reader.in().position(argsStartPos);
}
@@ -157,7 +166,7 @@ public class ClientServiceInvokeRequest extends ClientRequest {
PlatformService proxy =
((IgniteServicesImpl)services).serviceProxy(name, PlatformService.class, false, timeout, true);
- res = proxy.invokeMethod(methodName, keepBinary(), false, args, null);
+ res = proxy.invokeMethod(methodName, keepBinary(), false, args, callAttrs);
}
else {
// Deserialize Java service arguments when not in keepBinary mode.
@@ -178,7 +187,7 @@ public class ClientServiceInvokeRequest extends ClientRequest {
if (!BinaryArray.useBinaryArrays())
PlatformServices.convertArrayArgs(args, method);
- res = proxy.invokeMethod(method, args, null);
+ res = proxy.invokeMethod(method, args, callAttrs);
}
return new ClientObjectResponse(requestId(), res);
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
index 95e4e2b..9178acc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/services/PlatformServices.java
@@ -43,7 +43,6 @@ import org.apache.ignite.internal.processors.platform.utils.PlatformUtils;
import org.apache.ignite.internal.processors.platform.utils.PlatformWriterBiClosure;
import org.apache.ignite.internal.processors.platform.utils.PlatformWriterClosure;
import org.apache.ignite.internal.processors.service.GridServiceProxy;
-import org.apache.ignite.internal.processors.service.ServiceCallContextImpl;
import org.apache.ignite.internal.util.typedef.T3;
import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.lang.IgnitePredicate;
@@ -632,8 +631,7 @@ public class PlatformServices extends PlatformAbstractTarget {
if (!BinaryArray.useBinaryArrays())
convertArrayArgs(args, mtd);
- return ((GridServiceProxy)proxy)
- .invokeMethod(mtd, args, callAttrs == null ? null : new ServiceCallContextImpl(callAttrs));
+ return ((GridServiceProxy)proxy).invokeMethod(mtd, args, callAttrs);
}
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceServiceInjector.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceServiceInjector.java
index a4b6cde..4853bf2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceServiceInjector.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/resource/GridResourceServiceInjector.java
@@ -23,6 +23,7 @@ import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.IgniteServicesEx;
import org.apache.ignite.internal.managers.deployment.GridDeployment;
import org.apache.ignite.internal.processors.service.ServiceCallContextHolder;
+import org.apache.ignite.internal.processors.service.ServiceCallContextImpl;
import org.apache.ignite.resources.ServiceResource;
import org.apache.ignite.services.Service;
import org.jetbrains.annotations.Nullable;
@@ -74,7 +75,11 @@ public class GridResourceServiceInjector extends GridResourceBasicInjector<Colle
ann.serviceName(),
(Class<? super T>)ann.proxyInterface(),
ann.proxySticky(),
- ann.forwardCallerContext() ? ServiceCallContextHolder::current : null,
+ ann.forwardCallerContext() ? () -> {
+ ServiceCallContextImpl callCtx = ServiceCallContextHolder.current();
+
+ return callCtx == null ? null : callCtx.values();
+ } : null,
0
);
}
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
index c888286..f2d4886 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProxy.java
@@ -59,7 +59,6 @@ import org.apache.ignite.marshaller.Marshaller;
import org.apache.ignite.platform.PlatformServiceMethod;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.services.Service;
-import org.apache.ignite.services.ServiceCallContext;
import org.jetbrains.annotations.Nullable;
import static org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_IO_POLICY;
@@ -123,7 +122,7 @@ public class GridServiceProxy<T> implements Serializable {
* @param sticky Whether multi-node request should be done.
* @param timeout Service availability wait timeout. Cannot be negative.
* @param ctx Context.
- * @param callCtxProvider Caller context provider.
+ * @param callAttrsProvider Service call context attributes provider.
* @param keepBinary {@code True} if results should be in binary form.
*/
public GridServiceProxy(ClusterGroup prj,
@@ -132,7 +131,7 @@ public class GridServiceProxy<T> implements Serializable {
boolean sticky,
long timeout,
GridKernalContext ctx,
- @Nullable Supplier<ServiceCallContext> callCtxProvider,
+ @Nullable Supplier<Map<String, Object>> callAttrsProvider,
boolean keepBinary
) {
assert timeout >= 0 : timeout;
@@ -151,7 +150,7 @@ public class GridServiceProxy<T> implements Serializable {
proxy = (T)Proxy.newProxyInstance(
svc.getClassLoader(),
new Class[] {svc},
- new ProxyInvocationHandler(callCtxProvider)
+ new ProxyInvocationHandler(callAttrsProvider)
);
}
@@ -173,15 +172,11 @@ public class GridServiceProxy<T> implements Serializable {
*
* @param mtd Method.
* @param args Arugments.
- * @param callCtx Service call context.
+ * @param callAttrs Service call context attributes.
* @return Result.
*/
@SuppressWarnings("BusyWait")
- public Object invokeMethod(
- final Method mtd,
- final Object[] args,
- @Nullable ServiceCallContext callCtx
- ) throws Throwable {
+ public Object invokeMethod(Method mtd, Object[] args, @Nullable Map<String, Object> callAttrs) throws Throwable {
if (U.isHashCodeMethod(mtd))
return System.identityHashCode(proxy);
else if (U.isEqualsMethod(mtd))
@@ -211,7 +206,7 @@ public class GridServiceProxy<T> implements Serializable {
Service svc = svcCtx.service();
if (svc != null)
- return callServiceLocally(svc, mtd, args, callCtx);
+ return callServiceLocally(svc, mtd, args, callAttrs);
}
}
else {
@@ -220,7 +215,7 @@ public class GridServiceProxy<T> implements Serializable {
// Execute service remotely.
return unmarshalResult(ctx.closure().callAsyncNoFailover(
GridClosureCallMode.BROADCAST,
- new ServiceProxyCallable(methodName(mtd), name, mtd.getParameterTypes(), args, callCtx),
+ new ServiceProxyCallable(methodName(mtd), name, mtd.getParameterTypes(), args, callAttrs),
Collections.singleton(node),
false,
waitTimeout,
@@ -287,45 +282,42 @@ public class GridServiceProxy<T> implements Serializable {
* @param svc Service to be called.
* @param mtd Method to call.
* @param args Method args.
- * @param callCtx Service call context.
+ * @param callAttrs Service call context attributes.
* @return Invocation result.
*/
private Object callServiceLocally(
Service svc,
Method mtd,
Object[] args,
- @Nullable ServiceCallContext callCtx
+ @Nullable Map<String, Object> callAttrs
) throws Exception {
- if (svc instanceof PlatformService && !PLATFORM_SERVICE_INVOKE_METHOD.equals(mtd)) {
- Map<String, Object> callAttrs = callCtx == null ? null : ((ServiceCallContextImpl)callCtx).values();
-
+ if (svc instanceof PlatformService && !PLATFORM_SERVICE_INVOKE_METHOD.equals(mtd))
return ((PlatformService)svc).invokeMethod(methodName(mtd), false, true, args, callAttrs);
- }
else
- return callServiceMethod(svc, mtd, args, callCtx);
+ return callServiceMethod(svc, mtd, args, callAttrs);
}
/**
* @param svc Service to be called.
* @param mtd Method to call.
* @param args Method args.
- * @param callCtx Service call context.
+ * @param callAttrs Service call context attributes.
* @return Invocation result.
*/
private static Object callServiceMethod(
Service svc,
Method mtd,
Object[] args,
- @Nullable ServiceCallContext callCtx
+ @Nullable Map<String, Object> callAttrs
) throws InvocationTargetException, IllegalAccessException {
- if (callCtx != null)
- ServiceCallContextHolder.current(callCtx);
+ if (callAttrs != null)
+ ServiceCallContextHolder.current(new ServiceCallContextImpl(callAttrs));
try {
return mtd.invoke(svc, args);
}
finally {
- if (callCtx != null)
+ if (callAttrs != null)
ServiceCallContextHolder.current(null);
}
}
@@ -465,19 +457,19 @@ public class GridServiceProxy<T> implements Serializable {
* Invocation handler for service proxy.
*/
private class ProxyInvocationHandler implements InvocationHandler {
- /** Caller context provider. */
- private final Supplier<ServiceCallContext> callCtxProvider;
+ /** Service call context attributes provider. */
+ private final Supplier<Map<String, Object>> callAttrsProvider;
/**
- * @param callCtxProvider Caller context provider.
+ * @param callAttrsProvider Service call context attributes provider.
*/
- public ProxyInvocationHandler(@Nullable Supplier<ServiceCallContext> callCtxProvider) {
- this.callCtxProvider = callCtxProvider;
+ public ProxyInvocationHandler(@Nullable Supplier<Map<String, Object>> callAttrsProvider) {
+ this.callAttrsProvider = callAttrsProvider;
}
/** {@inheritDoc} */
@Override public Object invoke(Object proxy, final Method mtd, final Object[] args) throws Throwable {
- return invokeMethod(mtd, args, callCtxProvider != null ? callCtxProvider.get() : null);
+ return invokeMethod(mtd, args, callAttrsProvider != null ? callAttrsProvider.get() : null);
}
}
@@ -500,8 +492,8 @@ public class GridServiceProxy<T> implements Serializable {
/** Args. */
private Object[] args;
- /** Service call context. */
- private ServiceCallContext callCtx;
+ /** Service call context attributes. */
+ private Map<String, Object> callAttrs;
/** Grid instance. */
@IgniteInstanceResource
@@ -519,20 +511,20 @@ public class GridServiceProxy<T> implements Serializable {
* @param svcName Service name.
* @param argTypes Argument types.
* @param args Arguments for invocation.
- * @param callCtx Service call context.
+ * @param callAttrs Service call context attributes.
*/
private ServiceProxyCallable(
String mtdName,
String svcName,
Class<?>[] argTypes,
Object[] args,
- @Nullable ServiceCallContext callCtx
+ @Nullable Map<String, Object> callAttrs
) {
this.mtdName = mtdName;
this.svcName = svcName;
this.argTypes = argTypes;
this.args = args;
- this.callCtx = callCtx;
+ this.callAttrs = callAttrs;
}
/** {@inheritDoc} */
@@ -559,7 +551,7 @@ public class GridServiceProxy<T> implements Serializable {
/** */
private Object callPlatformService(PlatformService srv) {
try {
- return srv.invokeMethod(mtdName, false, true, args, callCtx != null ? ((ServiceCallContextImpl)callCtx).values() : null);
+ return srv.invokeMethod(mtdName, false, true, args, callAttrs);
}
catch (PlatformNativeException ne) {
throw new ServiceProxyException(U.convertException(ne));
@@ -575,7 +567,7 @@ public class GridServiceProxy<T> implements Serializable {
throw new GridServiceMethodNotFoundException(svcName, mtdName, argTypes);
try {
- return callServiceMethod(srv, mtd, args, callCtx);
+ return callServiceMethod(srv, mtd, args, callAttrs);
}
catch (InvocationTargetException e) {
throw new ServiceProxyException(e.getCause());
@@ -588,13 +580,7 @@ public class GridServiceProxy<T> implements Serializable {
U.writeString(out, mtdName);
U.writeArray(out, argTypes);
U.writeArray(out, args);
-
- if (callCtx != null) {
- out.writeBoolean(true);
- callCtx.writeExternal(out);
- }
- else
- out.writeBoolean(false);
+ U.writeMap(out, callAttrs);
}
/** {@inheritDoc} */
@@ -603,11 +589,7 @@ public class GridServiceProxy<T> implements Serializable {
mtdName = U.readString(in);
argTypes = U.readClassArray(in);
args = U.readArray(in);
-
- if (in.readBoolean()) {
- callCtx = new ServiceCallContextImpl();
- callCtx.readExternal(in);
- }
+ callAttrs = U.readMap(in);
}
/** {@inheritDoc} */
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/IgniteServiceProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/IgniteServiceProcessor.java
index 2c10253..055fc58 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/IgniteServiceProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/IgniteServiceProcessor.java
@@ -84,7 +84,6 @@ import org.apache.ignite.marshaller.jdk.JdkMarshaller;
import org.apache.ignite.plugin.security.SecurityException;
import org.apache.ignite.plugin.security.SecurityPermission;
import org.apache.ignite.services.Service;
-import org.apache.ignite.services.ServiceCallContext;
import org.apache.ignite.services.ServiceConfiguration;
import org.apache.ignite.services.ServiceContext;
import org.apache.ignite.services.ServiceDeploymentException;
@@ -1020,7 +1019,7 @@ public class IgniteServiceProcessor extends GridProcessorAdapter implements Igni
* @param name Service name.
* @param srvcCls Service class.
* @param sticky Whether multi-node request should be done.
- * @param callCtxProvider Caller context provider.
+ * @param callAttrsProvider Service call context attributes provider.
* @param timeout If greater than 0 limits service acquire time. Cannot be negative.
* @param <T> Service interface type.
* @return The proxy of a service by its name and class.
@@ -1031,7 +1030,7 @@ public class IgniteServiceProcessor extends GridProcessorAdapter implements Igni
String name,
Class<? super T> srvcCls,
boolean sticky,
- @Nullable Supplier<ServiceCallContext> callCtxProvider,
+ @Nullable Supplier<Map<String, Object>> callAttrsProvider,
long timeout,
boolean keepBinary
) throws IgniteException {
@@ -1043,7 +1042,7 @@ public class IgniteServiceProcessor extends GridProcessorAdapter implements Igni
if (ctx != null) {
Service srvc = ctx.service();
- if (srvc != null && callCtxProvider == null) {
+ if (srvc != null && callAttrsProvider == null) {
if (srvcCls.isAssignableFrom(srvc.getClass()))
return (T)srvc;
else if (!PlatformService.class.isAssignableFrom(srvc.getClass())) {
@@ -1054,7 +1053,7 @@ public class IgniteServiceProcessor extends GridProcessorAdapter implements Igni
}
}
- return new GridServiceProxy<T>(prj, name, srvcCls, sticky, timeout, ctx, callCtxProvider, keepBinary).proxy();
+ return new GridServiceProxy<T>(prj, name, srvcCls, sticky, timeout, ctx, callAttrsProvider, keepBinary).proxy();
}
/**
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceCallContextHolder.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceCallContextHolder.java
index a9a449c..efcfa7e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceCallContextHolder.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceCallContextHolder.java
@@ -17,7 +17,6 @@
package org.apache.ignite.internal.processors.service;
-import org.apache.ignite.services.ServiceCallContext;
import org.jetbrains.annotations.Nullable;
/**
@@ -25,19 +24,19 @@ import org.jetbrains.annotations.Nullable;
*/
public class ServiceCallContextHolder {
/** Service call context of the current thread. */
- private static final ThreadLocal<ServiceCallContext> locCallCtx = new ThreadLocal<>();
+ private static final ThreadLocal<ServiceCallContextImpl> locCallCtx = new ThreadLocal<>();
/**
* @return Service call context of the current thread.
*/
- @Nullable public static ServiceCallContext current() {
+ @Nullable public static ServiceCallContextImpl current() {
return locCallCtx.get();
}
/**
* @param callCtx Service call context of the current thread.
*/
- static void current(@Nullable ServiceCallContext callCtx) {
+ static void current(@Nullable ServiceCallContextImpl callCtx) {
if (callCtx != null)
locCallCtx.set(callCtx);
else
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceCallContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceCallContextImpl.java
index ab53c12b..c9dc6d0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceCallContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/ServiceCallContextImpl.java
@@ -17,32 +17,17 @@
package org.apache.ignite.internal.processors.service;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.util.HashMap;
import java.util.Map;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.services.ServiceCallContext;
/**
* Service call context implementation.
*/
public class ServiceCallContextImpl implements ServiceCallContext {
- /** */
- private static final long serialVersionUID = 0L;
-
/** Service call context attributes. */
private Map<String, Object> attrs;
/**
- * Default contructor.
- */
- public ServiceCallContextImpl() {
- attrs = new HashMap<>();
- }
-
- /**
* @param attrs Service call context attributes.
*/
public ServiceCallContextImpl(Map<String, Object> attrs) {
@@ -59,20 +44,10 @@ public class ServiceCallContextImpl implements ServiceCallContext {
return (byte[])attrs.get(name);
}
- /** {@inheritDoc} */
- @Override public void writeExternal(ObjectOutput out) throws IOException {
- U.writeMap(out, attrs);
- }
-
- /** {@inheritDoc} */
- @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- attrs = U.readMap(in);
- }
-
/**
* @return Service call context attributes.
*/
- Map<String, Object> values() {
+ public Map<String, Object> values() {
return attrs;
}
}
diff --git a/modules/core/src/main/java/org/apache/ignite/services/ServiceCallContext.java b/modules/core/src/main/java/org/apache/ignite/services/ServiceCallContext.java
index 3830edc..8eae10b 100644
--- a/modules/core/src/main/java/org/apache/ignite/services/ServiceCallContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/services/ServiceCallContext.java
@@ -17,7 +17,6 @@
package org.apache.ignite.services;
-import java.io.Externalizable;
import org.apache.ignite.lang.IgniteExperimental;
/**
@@ -58,7 +57,7 @@ import org.apache.ignite.lang.IgniteExperimental;
* @see ServiceCallContextBuilder
*/
@IgniteExperimental
-public interface ServiceCallContext extends Externalizable {
+public interface ServiceCallContext {
/**
* Create a context builder.
*
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/client/thin/ServicesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/client/thin/ServicesTest.java
index 6185da5..ee670a1 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/client/thin/ServicesTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/client/thin/ServicesTest.java
@@ -34,13 +34,17 @@ import org.apache.ignite.internal.binary.BinaryArray;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.platform.PlatformType;
import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.resources.ServiceContextResource;
import org.apache.ignite.services.Service;
+import org.apache.ignite.services.ServiceCallContext;
+import org.apache.ignite.services.ServiceCallContextBuilder;
import org.apache.ignite.services.ServiceContext;
import org.apache.ignite.testframework.GridTestUtils;
import org.junit.Test;
import static org.apache.ignite.IgniteSystemProperties.IGNITE_USE_BINARY_ARRAYS;
import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;
+import static org.junit.Assert.assertArrayEquals;
/**
* Checks service invocation for thin client.
@@ -222,6 +226,39 @@ public class ServicesTest extends AbstractThinClientTest {
}
}
+ /** Test custom caller context. */
+ @Test
+ public void testServiceCallContext() {
+ String attrName = "testAttr";
+ String attrVal = "test";
+ String binAttrName = "binTestAttr";
+ byte[] binAttrVal = attrVal.getBytes();
+
+ try (IgniteClient client = startClient(0)) {
+ // Check proxy creation with an invalid implementation.
+ ServiceCallContext customCls = new ServiceCallContext() {
+ @Override public String attribute(String name) { return null; }
+
+ @Override public byte[] binaryAttribute(String name) { return null; }
+ };
+
+ GridTestUtils.assertThrowsAnyCause(log, () -> client.services().serviceProxy(NODE_SINGLTON_SERVICE_NAME,
+ TestServiceInterface.class, customCls), IllegalArgumentException.class, "\"callCtx\" has an invalid type.");
+
+ // Check proxy creation with a valid caller context.
+ ServiceCallContext callCtx = new ServiceCallContextBuilder()
+ .put(attrName, attrVal)
+ .put(binAttrName, binAttrVal)
+ .build();
+
+ TestServiceInterface svc = client.services().serviceProxy(NODE_SINGLTON_SERVICE_NAME,
+ TestServiceInterface.class, callCtx);
+
+ assertEquals(attrVal, svc.testContextAttribute(attrName));
+ assertArrayEquals(binAttrVal, svc.testContextBinaryAttribute(binAttrName));
+ }
+ }
+
/**
* Test that services executed on cluster group.
*/
@@ -383,6 +420,12 @@ public class ServicesTest extends AbstractThinClientTest {
public Object testException();
/** */
+ public String testContextAttribute(String name);
+
+ /** */
+ public byte[] testContextBinaryAttribute(String name);
+
+ /** */
public boolean waitLatch() throws Exception;
}
@@ -393,20 +436,9 @@ public class ServicesTest extends AbstractThinClientTest {
/** Latch. */
public static CountDownLatch latch;
- /** {@inheritDoc} */
- @Override public void cancel(ServiceContext ctx) {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void init(ServiceContext ctx) throws Exception {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void execute(ServiceContext ctx) throws Exception {
- // No-op.
- }
+ /** Service context. */
+ @ServiceContextResource
+ private ServiceContext svcCtx;
/** {@inheritDoc} */
@Override public String testMethod() {
@@ -459,6 +491,20 @@ public class ServicesTest extends AbstractThinClientTest {
}
/** {@inheritDoc} */
+ @Override public String testContextAttribute(String name) {
+ ServiceCallContext callCtx = svcCtx.currentCallContext();
+
+ return callCtx == null ? null : callCtx.attribute(name);
+ }
+
+ /** {@inheritDoc} */
+ @Override public byte[] testContextBinaryAttribute(String name) {
+ ServiceCallContext callCtx = svcCtx.currentCallContext();
+
+ return callCtx == null ? null : callCtx.binaryAttribute(name);
+ }
+
+ /** {@inheritDoc} */
@Override public boolean waitLatch() throws Exception {
latch.await(10L, TimeUnit.SECONDS);
@@ -483,21 +529,6 @@ public class ServicesTest extends AbstractThinClientTest {
Ignite ignite;
/** {@inheritDoc} */
- @Override public void cancel(ServiceContext ctx) {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void init(ServiceContext ctx) throws Exception {
- // No-op.
- }
-
- /** {@inheritDoc} */
- @Override public void execute(ServiceContext ctx) throws Exception {
- // No-op.
- }
-
- /** {@inheritDoc} */
@Override public UUID nodeId() {
return ignite.cluster().localNode().id();
}
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceCallContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceCallContextTest.java
index 20fbcb6..c2ccd86 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceCallContextTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/IgniteServiceCallContextTest.java
@@ -110,6 +110,21 @@ public class IgniteServiceCallContextTest extends GridCommonAbstractTest {
}
/**
+ * Check proxy creation with an invalid implementation.
+ */
+ @Test
+ public void testInvalidContextImplementation() {
+ ServiceCallContext callCtx = new ServiceCallContext() {
+ @Override public String attribute(String name) { return null; }
+
+ @Override public byte[] binaryAttribute(String name) { return null; }
+ };
+
+ GridTestUtils.assertThrowsAnyCause(log, () -> grid(0).services().serviceProxy(SVC_NAME, TestService.class,
+ sticky, callCtx), IllegalArgumentException.class, "\"callCtx\" has an invalid type.");
+ }
+
+ /**
* Check context attribute.
*/
@Test
diff --git a/modules/core/src/test/java/org/apache/ignite/platform/PlatformServiceCallThinTask.java b/modules/core/src/test/java/org/apache/ignite/platform/PlatformServiceCallThinTask.java
index efe8841..b08fd7f 100644
--- a/modules/core/src/test/java/org/apache/ignite/platform/PlatformServiceCallThinTask.java
+++ b/modules/core/src/test/java/org/apache/ignite/platform/PlatformServiceCallThinTask.java
@@ -22,6 +22,7 @@ import org.apache.ignite.client.IgniteClient;
import org.apache.ignite.compute.ComputeJobAdapter;
import org.apache.ignite.internal.processors.platform.services.PlatformService;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.services.ServiceCallContext;
import org.apache.ignite.testframework.GridTestUtils;
/**
@@ -47,7 +48,9 @@ public class PlatformServiceCallThinTask extends AbstractPlatformServiceCallTask
/** {@inheritDoc} */
@Override TestPlatformService serviceProxy() {
- return client.services().serviceProxy(srvcName, TestPlatformService.class);
+ ServiceCallContext callCtx = ServiceCallContext.builder().put("attr", "value").build();
+
+ return client.services().serviceProxy(srvcName, TestPlatformService.class, callCtx);
}
/** {@inheritDoc} */
@@ -71,10 +74,5 @@ public class PlatformServiceCallThinTask extends AbstractPlatformServiceCallTask
return null;
}, ClientException.class, "Failed to invoke platform service");
}
-
- /** {@inheritDoc} */
- @Override protected void checkContextAttribute(TestPlatformService srv) {
- // TODO IGNITE-15829 Remove this method override.
- }
}
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/ITestService.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/ITestService.cs
index 4bfba68..9061f194 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/ITestService.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/ITestService.cs
@@ -62,5 +62,11 @@ namespace Apache.Ignite.Core.Tests.Client.Services
/** */
Guid GetNodeId();
+
+ /** */
+ string ContextAttribute(string name);
+
+ /** */
+ byte[] ContextBinaryAttribute(string name);
}
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/ServicesClientTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/ServicesClientTest.cs
index 82f1350..1b1d174 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/ServicesClientTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/ServicesClientTest.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Core.Tests.Client.Services
using System;
using System.Collections.Generic;
using System.Linq;
+ using System.Text;
using Apache.Ignite.Core.Binary;
using Apache.Ignite.Core.Client;
using Apache.Ignite.Core.Client.Services;
@@ -565,6 +566,31 @@ namespace Apache.Ignite.Core.Tests.Client.Services
Assert.AreEqual(1, task.Result);
}
+
+ /// <summary>
+ /// Tests custom caller context.
+ /// </summary>
+ [Test]
+ public void TestServiceCallContext()
+ {
+ string attrName = "attr";
+ string binAttrName = "binAttr";
+ string attrValue = "value";
+ byte[] binAttrValue = Encoding.UTF8.GetBytes(attrValue);
+
+ IServiceCallContext callCtx = new ServiceCallContextBuilder()
+ .Set(attrName, attrValue)
+ .Set(binAttrName, binAttrValue)
+ .Build();
+
+ var svc = DeployAndGetTestService<ITestService>(null, callCtx);
+
+ Assert.AreEqual(attrValue, svc.ContextAttribute(attrName));
+ Assert.AreEqual(binAttrValue, svc.ContextBinaryAttribute(binAttrName));
+
+ Assert.Throws<ArgumentException>(() =>
+ DeployAndGetTestService<ITestService>(null, new CustomServiceCallContext()));
+ }
[Test]
public void TestGetServiceDescriptors()
@@ -610,7 +636,8 @@ namespace Apache.Ignite.Core.Tests.Client.Services
/// <summary>
/// Deploys test service and returns client-side proxy.
/// </summary>
- private T DeployAndGetTestService<T>(Func<IServicesClient, IServicesClient> transform = null) where T : class
+ private T DeployAndGetTestService<T>(Func<IServicesClient, IServicesClient> transform = null,
+ IServiceCallContext callCtx = null) where T : class
{
ServerServices.DeployClusterSingleton(ServiceName, new TestService());
@@ -621,7 +648,7 @@ namespace Apache.Ignite.Core.Tests.Client.Services
services = transform(services);
}
- return services.GetServiceProxy<T>(ServiceName);
+ return services.GetServiceProxy<T>(ServiceName, callCtx);
}
/// <summary>
@@ -631,6 +658,24 @@ namespace Apache.Ignite.Core.Tests.Client.Services
{
get { return Ignition.GetIgnite().GetServices(); }
}
+
+ /// <summary>
+ /// Custom implementation of the service call context.
+ /// </summary>
+ private class CustomServiceCallContext : IServiceCallContext
+ {
+ /** <inheritdoc /> */
+ public string GetAttribute(string name)
+ {
+ return null;
+ }
+
+ /** <inheritdoc /> */
+ public byte[] GetBinaryAttribute(string name)
+ {
+ return null;
+ }
+ }
}
/// <summary>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/TestService.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/TestService.cs
index c61b43a..1b80573 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/TestService.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/Services/TestService.cs
@@ -34,6 +34,9 @@ namespace Apache.Ignite.Core.Tests.Client.Services
/** */
[InstanceResource]
private readonly IIgnite _ignite = null;
+
+ /** Service context. */
+ private IServiceContext _ctx;
/** */
public const string ExceptionText = "Some error";
@@ -70,7 +73,8 @@ namespace Apache.Ignite.Core.Tests.Client.Services
{
var tcs = new TaskCompletionSource<int>();
new Timer(_ => tcs.SetResult(1)).Change(500, -1);
- return tcs.Task; }
+ return tcs.Task;
+ }
/** <inheritdoc /> */
public Person PersonMethod(Person person)
@@ -112,11 +116,27 @@ namespace Apache.Ignite.Core.Tests.Client.Services
{
return _ignite.GetCluster().GetLocalNode().Id;
}
+
+ /** <inheritdoc /> */
+ public string ContextAttribute(string name)
+ {
+ IServiceCallContext callCtx = _ctx.CurrentCallContext;
+
+ return callCtx == null ? null : callCtx.GetAttribute(name);
+ }
+
+ /** <inheritdoc /> */
+ public byte[] ContextBinaryAttribute(string name)
+ {
+ IServiceCallContext callCtx = _ctx.CurrentCallContext;
+
+ return callCtx == null ? null : callCtx.GetBinaryAttribute(name);
+ }
/** <inheritdoc /> */
public void Init(IServiceContext context)
{
- // No-op.
+ _ctx = context;
}
/** <inheritdoc /> */
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/CallPlatformServiceTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/CallPlatformServiceTest.cs
index fd0e77b..1c52dfe 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/CallPlatformServiceTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/CallPlatformServiceTest.cs
@@ -272,7 +272,9 @@ namespace Apache.Ignite.Core.Tests.Services
public string contextAttribute(string name)
{
- return _ctx.CurrentCallContext.GetAttribute(name);
+ IServiceCallContext callCtx = _ctx.CurrentCallContext;
+
+ return callCtx == null ? null : callCtx.GetAttribute(name);
}
/** <inheritdoc /> */
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
index 2c1fbf0..798a98e 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Services/ServicesTest.cs
@@ -320,6 +320,13 @@ namespace Apache.Ignite.Core.Tests.Services
Services.DeployClusterSingleton(SvcName, svc);
+ // Check proxy creation with an invalid implementation.
+ Assert.Throws<ArgumentException>(() =>
+ Grid1.GetServices().GetServiceProxy<ITestIgniteService>(SvcName, false, new CustomServiceCallContext()));
+
+ Assert.Throws<ArgumentException>(() =>
+ Grid1.GetServices().GetDynamicServiceProxy(SvcName, false, new CustomServiceCallContext()));
+
foreach (var grid in Grids)
{
var nodeId = grid.GetCluster().ForLocal().GetNode().Id;
@@ -1914,6 +1921,24 @@ namespace Apache.Ignite.Core.Tests.Services
}
}
+ /// <summary>
+ /// Custom implementation of the service call context.
+ /// </summary>
+ private class CustomServiceCallContext : IServiceCallContext
+ {
+ /** <inheritdoc /> */
+ public string GetAttribute(string name)
+ {
+ return null;
+ }
+
+ /** <inheritdoc /> */
+ public byte[] GetBinaryAttribute(string name)
+ {
+ return null;
+ }
+ }
+
#if NETCOREAPP
/// <summary>
/// Adds support of the local dates to the Ignite timestamp serialization.
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Services/IServicesClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Services/IServicesClient.cs
index 0d20bb0..f788d67 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Client/Services/IServicesClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Client/Services/IServicesClient.cs
@@ -18,6 +18,8 @@
namespace Apache.Ignite.Core.Client.Services
{
using System.Collections.Generic;
+ using Apache.Ignite.Core.Common;
+ using Apache.Ignite.Core.Services;
/// <summary>
/// Ignite distributed services client.
@@ -41,6 +43,19 @@ namespace Apache.Ignite.Core.Client.Services
T GetServiceProxy<T>(string serviceName) where T : class;
/// <summary>
+ /// Gets a proxy for the service with the specified name and caller context.
+ /// <para />
+ /// Note: service proxies are not "sticky" - there is no guarantee that all calls will be made to the same
+ /// remote service instance.
+ /// </summary>
+ /// <typeparam name="T">Service type.</typeparam>
+ /// <param name="serviceName">Service name.</param>
+ /// <param name="callCtx">Service call context.</param>
+ /// <returns>Proxy object that forwards all member calls to a remote Ignite service.</returns>
+ [IgniteExperimental]
+ T GetServiceProxy<T>(string serviceName, IServiceCallContext callCtx) where T : class;
+
+ /// <summary>
/// Gets metadata about all deployed services in the grid.
/// </summary>
/// <returns>Metadata about all deployed services in the grid.</returns>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientBitmaskFeature.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientBitmaskFeature.cs
index d8a2196..9feffe2 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientBitmaskFeature.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientBitmaskFeature.cs
@@ -31,6 +31,7 @@ namespace Apache.Ignite.Core.Impl.Client
ServiceInvoke = 5, // The flag is not necessary and exists for legacy reasons
// DefaultQueryTimeout = 6, // IGNITE-13692
QueryPartitionsBatchSize = 7,
- BinaryConfiguration = 8
+ BinaryConfiguration = 8,
+ ServiceInvokeCtx = 10
}
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Services/ServicesClient.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Services/ServicesClient.cs
index 9c323af..272fce3 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Services/ServicesClient.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/Services/ServicesClient.cs
@@ -19,6 +19,7 @@ namespace Apache.Ignite.Core.Impl.Client.Services
{
using System;
using System.Collections.Generic;
+ using System.Collections;
using System.Diagnostics;
using System.Reflection;
using Apache.Ignite.Core.Client;
@@ -27,6 +28,7 @@ namespace Apache.Ignite.Core.Impl.Client.Services
using Apache.Ignite.Core.Impl.Common;
using Apache.Ignite.Core.Impl.Services;
using Apache.Ignite.Core.Platform;
+ using Apache.Ignite.Core.Services;
/// <summary>
/// Services client.
@@ -86,12 +88,22 @@ namespace Apache.Ignite.Core.Impl.Client.Services
/** <inheritdoc /> */
public T GetServiceProxy<T>(string serviceName) where T : class
{
+ return GetServiceProxy<T>(serviceName, null);
+ }
+
+ /** <inheritdoc /> */
+ public T GetServiceProxy<T>(string serviceName, IServiceCallContext callCtx) where T : class
+ {
IgniteArgumentCheck.NotNullOrEmpty(serviceName, "name");
+ IgniteArgumentCheck.Ensure(callCtx == null || callCtx is ServiceCallContext, "callCtx",
+ "custom implementation of " + typeof(ServiceCallContext).Name + " is not supported." +
+ " Please use " + typeof(ServiceCallContextBuilder).Name + " to create it.");
var platformType = GetServiceDescriptor(serviceName).PlatformType;
+ IDictionary callAttrs = callCtx == null ? null : ((ServiceCallContext) callCtx).Values();
return ServiceProxyFactory<T>.CreateProxy(
- (method, args) => InvokeProxyMethod(serviceName, method, args, platformType)
+ (method, args) => InvokeProxyMethod(serviceName, method, args, platformType, callAttrs)
);
}
@@ -137,10 +149,10 @@ namespace Apache.Ignite.Core.Impl.Client.Services
/// <summary>
/// Invokes the proxy method.
/// </summary>
- private object InvokeProxyMethod(string serviceName, MethodBase method, object[] args, PlatformType platformType)
+ private object InvokeProxyMethod(string serviceName, MethodBase method, object[] args,
+ PlatformType platformType, IDictionary callAttrs)
{
- return _ignite.Socket.DoOutInOp(
- ClientOp.ServiceInvoke,
+ return _ignite.Socket.DoOutInOp(ClientOp.ServiceInvoke,
ctx =>
{
var w = ctx.Writer;
@@ -172,6 +184,16 @@ namespace Apache.Ignite.Core.Impl.Client.Services
w.WriteString(method.Name);
ServiceProxySerializer.WriteMethodArguments(w, null, args, platformType);
+
+ if (ctx.Features.HasFeature(ClientBitmaskFeature.ServiceInvokeCtx))
+ {
+ w.WriteDictionary(callAttrs);
+ }
+ else if (callAttrs != null)
+ {
+ throw new IgniteClientException(
+ "Passing caller context to the service is not supported by the server");
+ }
},
ctx =>
{
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
index 9a0e20d..d987d74 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/ServiceProxySerializer.cs
@@ -41,9 +41,9 @@ namespace Apache.Ignite.Core.Impl.Services
/// <param name="method">Method (optional, can be null).</param>
/// <param name="arguments">Arguments.</param>
/// <param name="platformType">The platform.</param>
- /// <param name="callCtx">Service call context.</param>
+ /// <param name="callAttrs">Service call context attributes.</param>
public static void WriteProxyMethod(BinaryWriter writer, string methodName, MethodBase method,
- object[] arguments, PlatformType platformType, IServiceCallContext callCtx)
+ object[] arguments, PlatformType platformType, IDictionary callAttrs)
{
Debug.Assert(writer != null);
@@ -58,7 +58,7 @@ namespace Apache.Ignite.Core.Impl.Services
else
writer.WriteBoolean(false);
- writer.WriteDictionary(callCtx == null ? null : ((ServiceCallContext) callCtx).Values());
+ writer.WriteDictionary(callAttrs);
}
/// <summary>
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
index 657aa02..eeb4b96 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Services/Services.cs
@@ -17,6 +17,7 @@
namespace Apache.Ignite.Core.Impl.Services
{
+ using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@@ -391,9 +392,10 @@ namespace Apache.Ignite.Core.Impl.Services
});
var platform = GetServiceDescriptors().Cast<ServiceDescriptor>().Single(x => x.Name == name).PlatformType;
+ var callAttrs = GetCallerContextAttributes(callCtx);
return ServiceProxyFactory<T>.CreateProxy((method, args) =>
- InvokeProxyMethod(javaProxy, method.Name, method, args, platform, callCtx));
+ InvokeProxyMethod(javaProxy, method.Name, method, args, platform, callAttrs));
}
/** <inheritDoc /> */
@@ -429,9 +431,10 @@ namespace Apache.Ignite.Core.Impl.Services
});
var platform = GetServiceDescriptors().Cast<ServiceDescriptor>().Single(x => x.Name == name).PlatformType;
+ var callAttrs = GetCallerContextAttributes(callCtx);
return new DynamicServiceProxy((methodName, args) =>
- InvokeProxyMethod(javaProxy, methodName, null, args, platform, callCtx));
+ InvokeProxyMethod(javaProxy, methodName, null, args, platform, callAttrs));
}
/// <summary>
@@ -442,12 +445,12 @@ namespace Apache.Ignite.Core.Impl.Services
/// <param name="method">Method to invoke.</param>
/// <param name="args">Arguments.</param>
/// <param name="platformType">The platform.</param>
- /// <param name="callCtx">Service call context.</param>
+ /// <param name="callAttrs">Service call context attributes.</param>
/// <returns>
/// Invocation result.
/// </returns>
private object InvokeProxyMethod(IPlatformTargetInternal proxy, string methodName,
- MethodBase method, object[] args, PlatformType platformType, IServiceCallContext callCtx)
+ MethodBase method, object[] args, PlatformType platformType, IDictionary callAttrs)
{
bool locRegisterSameJavaType = Marshaller.RegisterSameJavaTypeTl.Value;
@@ -459,7 +462,7 @@ namespace Apache.Ignite.Core.Impl.Services
try
{
return DoOutInOp(OpInvokeMethod,
- writer => ServiceProxySerializer.WriteProxyMethod(writer, methodName, method, args, platformType, callCtx),
+ writer => ServiceProxySerializer.WriteProxyMethod(writer, methodName, method, args, platformType, callAttrs),
(stream, res) => ServiceProxySerializer.ReadInvocationResult(stream, Marshaller, _keepBinary),
proxy);
}
@@ -491,6 +494,20 @@ namespace Apache.Ignite.Core.Impl.Services
}
/// <summary>
+ /// Gets the attributes of the service call context.
+ /// </summary>
+ /// <param name="callCtx">Service call context.</param>
+ /// <returns>Service call context attributes.</returns>
+ private IDictionary GetCallerContextAttributes(IServiceCallContext callCtx)
+ {
+ IgniteArgumentCheck.Ensure(callCtx == null || callCtx is ServiceCallContext, "callCtx",
+ "custom implementation of " + typeof(ServiceCallContext).Name + " is not supported." +
+ " Please use " + typeof(ServiceCallContextBuilder).Name + " to create it.");
+
+ return callCtx == null ? null : ((ServiceCallContext) callCtx).Values();
+ }
+
+ /// <summary>
/// Performs ServiceConfiguration validation.
/// </summary>
/// <param name="configuration">Service configuration</param>