use of org.apache.ignite.internal.processors.platform.PlatformContext in project ignite by apache.
the class GridQueryProcessor method registerPlatformTypeLocally.
/**
* Registers platform type locally.
*
* @param clsName Class name.
* @param binProc Binary processor.
*/
private void registerPlatformTypeLocally(String clsName, CacheObjectBinaryProcessorImpl binProc) {
PlatformProcessor platformProc = ctx.platform();
if (platformProc == null || !platformProc.hasContext())
return;
PlatformContext platformCtx = platformProc.context();
BinaryMetadata meta = platformCtx.getBinaryType(clsName);
if (meta != null)
binProc.binaryContext().registerClassLocally(meta.wrap(binProc.binaryContext()), false, platformCtx.getMarshallerPlatformId());
}
use of org.apache.ignite.internal.processors.platform.PlatformContext in project ignite by apache.
the class PlatformAbstractFunc method invoke.
/**
* Invokes this instance.
*
* @return Invocation result.
*/
protected Object invoke() throws IgniteCheckedException {
assert ignite != null;
PlatformContext ctx = PlatformUtils.platformContext(ignite);
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
if (ptr != 0) {
out.writeBoolean(true);
out.writeLong(ptr);
} else {
out.writeBoolean(false);
ctx.writer(out).writeObject(func);
}
out.synchronize();
platformCallback(ctx.gateway(), mem.pointer());
PlatformInputStream in = mem.input();
in.synchronize();
return PlatformUtils.readInvocationResult(ctx, ctx.reader(in));
}
}
use of org.apache.ignite.internal.processors.platform.PlatformContext in project ignite by apache.
the class ClientDataStreamerStartRequest method createReceiver.
/**
* Creates the receiver.
*
* @param ctx Kernal context.
* @param receiverObj Receiver.
* @param platform Platform code.
* @param keepBinary Keep binary flag.
* @return Receiver.
*/
private static StreamReceiver createReceiver(GridKernalContext ctx, Object receiverObj, byte platform, boolean keepBinary) {
if (receiverObj == null)
return null;
switch(platform) {
case ClientPlatform.JAVA:
return ((BinaryObject) receiverObj).deserialize();
case ClientPlatform.DOTNET:
PlatformContext platformCtx = ctx.platform().context();
String curPlatform = platformCtx.platform();
if (!PlatformUtils.PLATFORM_DOTNET.equals(curPlatform)) {
throw new IgniteException("Stream receiver platform is " + PlatformUtils.PLATFORM_DOTNET + ", current platform is " + curPlatform);
}
return platformCtx.createStreamReceiver(receiverObj, 0, keepBinary);
case ClientPlatform.CPP:
default:
throw new UnsupportedOperationException("Invalid stream receiver platform code: " + platform);
}
}
use of org.apache.ignite.internal.processors.platform.PlatformContext in project ignite by apache.
the class PlatformLocalEventListener method apply.
/**
* {@inheritDoc}
*/
@Override
public boolean apply(Event evt) {
assert ignite != null;
PlatformContext ctx = PlatformUtils.platformContext(ignite);
assert ctx != null;
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = ctx.writer(out);
writer.writeInt(id);
ctx.writeEvent(writer, evt);
out.synchronize();
long res = ctx.gateway().eventLocalListenerApply(mem.pointer());
return res != 0;
}
}
Aggregations