use of org.apache.ignite.internal.processors.platform.memory.PlatformMemory 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.PlatformMemory 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.PlatformMemory in project ignite by apache.
the class PlatformTestPluginTarget method invokeCallback.
/**
* Invokes the platform callback.
*
* @param val Value to send.
* @return Result.
*/
private String invokeCallback(String val) {
PlatformMemory outMem = platformCtx.memory().allocate();
PlatformMemory inMem = platformCtx.memory().allocate();
PlatformOutputStream outStream = outMem.output();
BinaryRawWriterEx writer = platformCtx.writer(outStream);
writer.writeString(val);
outStream.synchronize();
platformCtx.gateway().pluginCallback(1, outMem, inMem);
BinaryRawReaderEx reader = platformCtx.reader(inMem);
return reader.readString();
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformMemory in project ignite by apache.
the class PlatformStreamReceiverImpl method receive.
/** {@inheritDoc} */
@Override
public void receive(IgniteCache<Object, Object> cache, Collection<Map.Entry<Object, Object>> collection) throws IgniteException {
assert ctx != null;
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
out.writeLong(ptr);
out.writeBoolean(keepBinary);
BinaryRawWriterEx writer = ctx.writer(out);
writer.writeObject(pred);
writer.writeInt(collection.size());
for (Map.Entry<Object, Object> e : collection) {
writer.writeObject(e.getKey());
writer.writeObject(e.getValue());
}
out.synchronize();
PlatformCache cache0 = new PlatformCache(ctx, cache, keepBinary);
PlatformTargetProxy cacheProxy = new PlatformTargetProxyImpl(cache0, ctx);
ctx.gateway().dataStreamerStreamReceiverInvoke(ptr, cacheProxy, mem.pointer(), keepBinary);
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformMemory in project ignite by apache.
the class PlatformDotNetCacheStore method initialize.
/**
* Initialize the store.
*
* @param ctx Context.
* @param convertBinary Convert binary flag.
* @throws org.apache.ignite.IgniteCheckedException
*/
public void initialize(GridKernalContext ctx, boolean convertBinary) throws IgniteCheckedException {
A.ensure(typName != null || nativeFactory != null, "Either typName or nativeFactory must be set in PlatformDotNetCacheStore");
platformCtx = PlatformUtils.platformContext(ctx.grid());
try (PlatformMemory mem = platformCtx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = platformCtx.writer(out);
write(writer, convertBinary);
out.synchronize();
ptr = platformCtx.gateway().cacheStoreCreate(mem.pointer());
}
}
Aggregations