use of org.apache.ignite.internal.processors.platform.memory.PlatformMemory in project ignite by apache.
the class PlatformAbstractService method init.
/** {@inheritDoc} */
@Override
public void init(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.writeBoolean(srvKeepBinary);
writer.writeObject(svc);
writeServiceContext(ctx, writer);
out.synchronize();
ptr = platformCtx.gateway().serviceInit(mem.pointer());
} catch (IgniteCheckedException e) {
throw U.convertException(e);
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformMemory in project ignite by apache.
the class PlatformAbstractService method cancel.
/** {@inheritDoc} */
@Override
public void cancel(ServiceContext ctx) {
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().serviceCancel(mem.pointer());
} catch (IgniteCheckedException e) {
throw U.convertException(e);
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformMemory 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.processors.platform.memory.PlatformMemory 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.processors.platform.memory.PlatformMemory 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;
}
Aggregations