use of org.apache.ignite.internal.processors.platform.memory.PlatformInputStream 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.memory.PlatformInputStream in project ignite by apache.
the class PlatformClosureJob method execute0.
/**
* {@inheritDoc}
*/
@Nullable
@Override
public Object execute0(PlatformContext ctx) throws IgniteCheckedException {
if (task == null) {
// Remote job execution.
assert ptr == 0;
createJob(ctx);
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
out.writeLong(ptr);
// cancel
out.writeBoolean(false);
out.synchronize();
ctx.gateway().computeJobExecute(mem.pointer());
PlatformInputStream in = mem.input();
in.synchronize();
BinaryRawReaderEx reader = ctx.reader(in);
return PlatformUtils.readInvocationResult(ctx, reader);
} finally {
ctx.gateway().computeJobDestroy(ptr);
}
} else {
// Local job execution.
assert ptr != 0;
return runLocal(ctx, false);
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformInputStream in project ignite by apache.
the class PlatformFullJob method serialize.
/**
* Internal job serialization routine.
*
* @throws org.apache.ignite.IgniteCheckedException If failed.
*/
private void serialize() throws IgniteCheckedException {
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformInputStream in = mem.input();
boolean res = ctx.gateway().computeJobSerialize(ptr, mem.pointer()) == 1;
in.synchronize();
BinaryRawReaderEx reader = ctx.reader(in);
if (res)
job = reader.readObjectDetached();
else
throw new IgniteCheckedException(reader.readString());
}
}
Aggregations