use of org.apache.ignite.internal.binary.BinaryRawReaderEx in project ignite by apache.
the class PlatformCacheEntryProcessorImpl method execute0.
/**
* Executes interop entry processor on a given entry, updates entry and returns result.
*
* @param ctx Context.
* @param entry Entry.
* @return Processing result.
*/
private Object execute0(PlatformContext ctx, MutableEntry entry) {
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = ctx.writer(out);
writeEntryAndProcessor(entry, writer);
out.synchronize();
ctx.gateway().cacheInvoke(mem.pointer());
PlatformInputStream in = mem.input();
in.synchronize();
BinaryRawReaderEx reader = ctx.reader(in);
return readResultAndUpdateEntry(ctx, entry, reader);
}
}
use of org.apache.ignite.internal.binary.BinaryRawReaderEx in project ignite by apache.
the class PlatformTargetProxyImpl method inStreamOutStream.
/**
* {@inheritDoc}
*/
@Override
public void inStreamOutStream(int type, long inMemPtr, long outMemPtr) throws Exception {
try (PlatformMemory inMem = platformCtx.memory().get(inMemPtr)) {
BinaryRawReaderEx reader = platformCtx.reader(inMem);
try (PlatformMemory outMem = platformCtx.memory().get(outMemPtr)) {
PlatformOutputStream out = outMem.output();
BinaryRawWriterEx writer = platformCtx.writer(out);
target.processInStreamOutStream(type, reader, writer);
out.synchronize();
}
} catch (Exception e) {
throw target.convertException(e);
}
}
use of org.apache.ignite.internal.binary.BinaryRawReaderEx in project ignite by apache.
the class PlatformTargetProxyImpl method inStreamOutListenableAsync.
/**
* Performs asyncronous operation.
*
* @param type Type.
* @param memPtr Stream pointer.
* @return Listenable.
* @throws Exception On error.
*/
private PlatformListenable inStreamOutListenableAsync(int type, long memPtr) throws Exception {
try (PlatformMemory mem = platformCtx.memory().get(memPtr)) {
BinaryRawReaderEx reader = platformCtx.reader(mem);
long futId = reader.readLong();
int futTyp = reader.readInt();
final PlatformAsyncResult res = target.processInStreamAsync(type, reader);
if (res == null)
throw new IgniteException("PlatformTarget.processInStreamAsync should not return null.");
IgniteFuture fut = res.future();
if (fut == null)
throw new IgniteException("PlatformAsyncResult.future() should not return null.");
return PlatformFutureUtils.listen(platformCtx, fut, futId, futTyp, new PlatformFutureUtils.Writer() {
/**
* {@inheritDoc}
*/
@Override
public void write(BinaryRawWriterEx writer, Object obj, Throwable err) {
res.write(writer, obj);
}
/**
* {@inheritDoc}
*/
@Override
public boolean canWrite(Object obj, Throwable err) {
return err == null;
}
}, target);
} catch (Exception e) {
throw target.convertException(e);
}
}
use of org.apache.ignite.internal.binary.BinaryRawReaderEx 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.binary.BinaryRawReaderEx 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