use of org.apache.ignite.internal.processors.platform.services.PlatformService in project ignite by apache.
the class ClientServiceInvokeRequest method process.
/**
* {@inheritDoc}
*/
@Override
public ClientResponse process(ClientConnectionContext ctx) {
if (F.isEmpty(name))
throw new IgniteException("Service name can't be empty");
if (F.isEmpty(methodName))
throw new IgniteException("Method name can't be empty");
ServiceDescriptor desc = findServiceDescriptor(ctx, name);
Class<?> svcCls = desc.serviceClass();
ClusterGroupAdapter grp = ctx.kernalContext().cluster().get();
grp = (ClusterGroupAdapter) (nodeIds.isEmpty() ? grp.forServers() : grp.forNodeIds(nodeIds));
IgniteServices services = grp.services();
try {
Object res;
if (PlatformService.class.isAssignableFrom(svcCls)) {
// Never deserialize platform service arguments and result: may contain platform-only types.
PlatformService proxy = ((IgniteServicesImpl) services).serviceProxy(name, PlatformService.class, false, timeout, true);
res = proxy.invokeMethod(methodName, keepBinary(), false, args, callAttrs);
} else {
// Deserialize Java service arguments when not in keepBinary mode.
if (!keepBinary() && args.length > 0) {
for (int i = 0; i < args.length; i++) {
if (paramTypeIds != null)
// Skip parameter typeId, we already read it in constructor.
reader.readInt();
args[i] = reader.readObject();
}
}
GridServiceProxy<?> proxy = new GridServiceProxy<>(grp, name, Service.class, false, timeout, ctx.kernalContext(), null, true);
Method method = resolveMethod(ctx, svcCls);
if (!BinaryArray.useBinaryArrays())
PlatformServices.convertArrayArgs(args, method);
res = proxy.invokeMethod(method, args, callAttrs);
}
return new ClientObjectResponse(requestId(), res);
} catch (PlatformNativeException e) {
ctx.kernalContext().log(getClass()).error("Failed to invoke platform service", e);
throw new IgniteException("Failed to invoke platform service, see server logs for details");
} catch (Throwable e) {
throw new IgniteException(e);
}
}
Aggregations