use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream in project ignite by apache.
the class PlatformEventFilterListenerImpl method initialize.
/**
* {@inheritDoc}
*/
@Override
public void initialize(GridKernalContext gridCtx) {
ctx = PlatformUtils.platformContext(gridCtx.grid());
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = ctx.writer(out);
writer.writeObjectDetached(pred);
out.synchronize();
hnd = ctx.gateway().eventFilterCreate(mem.pointer());
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream in project ignite by apache.
the class PlatformEventFilterListenerImpl method apply0.
/**
* Apply impl.
* @param uuid Node if.
* @param evt Event.
* @return Result.
*/
private boolean apply0(final UUID uuid, final Event evt) {
if (!ctx.isEventTypeSupported(evt.type()))
return false;
if (types != null) {
boolean match = false;
for (int type : types) {
if (type == evt.type()) {
match = true;
break;
}
}
if (!match)
return false;
}
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = ctx.writer(out);
ctx.writeEvent(writer, evt);
writer.writeUuid(uuid);
out.synchronize();
int res = ctx.gateway().eventFilterApply(hnd, mem.pointer());
return res != 0;
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream in project ignite by apache.
the class PlatformFullJob method execute0.
/**
* {@inheritDoc}
*/
@Nullable
@Override
public Object execute0(PlatformContext ctx) throws IgniteCheckedException {
boolean cancel = false;
synchronized (this) {
// 1. Create job if necessary.
if (task == null) {
assert ptr == 0;
createJob(ctx);
} else
assert ptr != 0;
// 2. Set correct state.
if (state == STATE_INIT)
state = STATE_RUNNING;
else {
assert state == STATE_CANCELLED;
cancel = true;
}
}
try {
if (task != null)
return runLocal(ctx, cancel);
else {
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
out.writeLong(ptr);
// cancel
out.writeBoolean(cancel);
out.synchronize();
ctx.gateway().computeJobExecute(mem.pointer());
PlatformInputStream in = mem.input();
in.synchronize();
BinaryRawReaderEx reader = ctx.reader(in);
return PlatformUtils.readInvocationResult(ctx, reader);
}
}
} finally {
synchronized (this) {
if (task == null) {
assert ptr != 0;
ctx.gateway().computeJobDestroy(ptr);
}
if (state == STATE_RUNNING)
state = STATE_COMPLETED;
}
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream in project ignite by apache.
the class PlatformMessageFilterImpl method initialize.
/**
* {@inheritDoc}
*/
@Override
public void initialize(GridKernalContext kernalCtx) {
if (ptr != 0)
return;
ctx = PlatformUtils.platformContext(kernalCtx.grid());
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = ctx.writer(out);
writer.writeObject(pred);
out.synchronize();
ptr = ctx.gateway().messagingFilterCreate(mem.pointer());
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream 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);
}
}
Aggregations