use of org.apache.ignite.internal.binary.BinaryRawWriterEx in project ignite by apache.
the class PlatformAbstractService method invokeMethod.
/** {@inheritDoc} */
@Override
public Object invokeMethod(String mthdName, boolean srvKeepBinary, Object[] args) throws IgniteCheckedException {
assert ptr != 0;
assert platformCtx != null;
try (PlatformMemory mem = platformCtx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = platformCtx.writer(out);
writer.writeLong(ptr);
writer.writeBoolean(srvKeepBinary);
writer.writeString(mthdName);
if (args == null)
writer.writeBoolean(false);
else {
writer.writeBoolean(true);
writer.writeInt(args.length);
for (Object arg : args) writer.writeObjectDetached(arg);
}
out.synchronize();
platformCtx.gateway().serviceInvokeMethod(mem.pointer());
PlatformInputStream in = mem.input();
in.synchronize();
BinaryRawReaderEx reader = platformCtx.reader(in);
return PlatformUtils.readInvocationResult(platformCtx, reader);
}
}
use of org.apache.ignite.internal.binary.BinaryRawWriterEx in project ignite by apache.
the class PlatformAbstractService method execute.
/** {@inheritDoc} */
@Override
public void execute(ServiceContext ctx) throws Exception {
assert ptr != 0;
assert platformCtx != null;
try (PlatformMemory mem = platformCtx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = platformCtx.writer(out);
writer.writeLong(ptr);
writer.writeBoolean(srvKeepBinary);
writeServiceContext(ctx, writer);
out.synchronize();
platformCtx.gateway().serviceExecute(mem.pointer());
} catch (IgniteCheckedException e) {
throw U.convertException(e);
}
}
use of org.apache.ignite.internal.binary.BinaryRawWriterEx in project ignite by apache.
the class PlatformUtils method errorData.
/**
* Get error data.
*
* @param err Error.
* @return Error data.
*/
@SuppressWarnings("UnusedDeclaration")
public static byte[] errorData(Throwable err) {
if (err instanceof PlatformExtendedException) {
PlatformContext ctx = ((PlatformExtendedException) err).context();
try (PlatformMemory mem = ctx.memory().allocate()) {
// Write error data.
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = ctx.writer(out);
try {
PlatformUtils.writeErrorData(err, writer, ctx.kernalContext().log(PlatformContext.class));
} finally {
out.synchronize();
}
// Read error data into separate array.
PlatformInputStream in = mem.input();
in.synchronize();
int len = in.remaining();
assert len > 0;
byte[] arr = in.array();
byte[] res = new byte[len];
System.arraycopy(arr, 0, res, 0, len);
return res;
}
} else
return null;
}
use of org.apache.ignite.internal.binary.BinaryRawWriterEx 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.binary.BinaryRawWriterEx 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());
}
}
Aggregations