use of org.apache.ignite.internal.binary.BinaryRawWriterEx 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.BinaryRawWriterEx 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.BinaryRawWriterEx in project ignite by apache.
the class PlatformCache method writeResult.
/**
* Writes the result to reused stream, if any.
*/
public long writeResult(PlatformMemory mem, Object obj, PlatformWriterClosure clo) {
if (obj == null)
return FALSE;
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = platformCtx.writer(out);
if (clo == null)
writer.writeObjectDetached(obj);
else
clo.write(writer, obj);
out.synchronize();
return TRUE;
}
use of org.apache.ignite.internal.binary.BinaryRawWriterEx 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.BinaryRawWriterEx in project ignite by apache.
the class PlatformAffinityFunction method start.
/**
* {@inheritDoc}
*/
@Override
public void start() throws IgniteException {
// userFunc is null when there is nothing overridden
if (userFunc == null)
return;
assert ignite != null;
ctx = PlatformUtils.platformContext(ignite);
assert ctx != null;
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = ctx.writer(out);
writer.writeObject(userFunc);
out.synchronize();
baseTarget = baseFunc != null ? new PlatformAffinityFunctionTarget(ctx, baseFunc) : null;
PlatformTargetProxyImpl baseTargetProxy = baseTarget != null ? new PlatformTargetProxyImpl(baseTarget, ctx) : null;
ptr = ctx.gateway().affinityFunctionInit(mem.pointer(), baseTargetProxy);
}
}
Aggregations