use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream in project ignite by apache.
the class PlatformUtils method evaluateContinuousQueryEvent.
/**
* Evaluate the filter.
*
* @param ctx Context.
* @param filterPtr Native filter pointer.
* @param evt Event.
* @return Result.
* @throws CacheEntryListenerException In case of failure.
*/
public static boolean evaluateContinuousQueryEvent(PlatformContext ctx, long filterPtr, CacheEntryEvent evt) throws CacheEntryListenerException {
assert filterPtr != 0;
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
out.writeLong(filterPtr);
writeCacheEntryEvent(ctx.writer(out), evt);
out.synchronize();
return ctx.gateway().continuousQueryFilterApply(mem.pointer()) == 1;
} catch (Exception e) {
throw toCacheEntryListenerException(e);
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream in project ignite by apache.
the class PlatformUtils method applyContinuousQueryEvents.
/**
* Apply continuous query events to listener.
*
* @param ctx Context.
* @param lsnrPtr Listener pointer.
* @param evts Events.
* @throws javax.cache.event.CacheEntryListenerException In case of failure.
*/
public static void applyContinuousQueryEvents(PlatformContext ctx, long lsnrPtr, Iterable<CacheEntryEvent> evts) throws CacheEntryListenerException {
assert lsnrPtr != 0;
assert evts != null;
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = ctx.writer(out);
writer.writeLong(lsnrPtr);
int cntPos = writer.reserveInt();
int cnt = 0;
for (CacheEntryEvent evt : evts) {
writeCacheEntryEvent(writer, evt);
cnt++;
}
writer.writeInt(cntPos, cnt);
out.synchronize();
ctx.gateway().continuousQueryListenerApply(mem.pointer());
} catch (Exception e) {
throw toCacheEntryListenerException(e);
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream 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.PlatformOutputStream 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();
try {
ptr = platformCtx.gateway().cacheStoreCreate(mem.pointer());
} catch (IgniteException e) {
// CacheAffinitySharedManager.processClientCacheStartRequests()
throw new IgniteCheckedException("Could not create .NET CacheStore", e);
}
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream in project ignite by apache.
the class PlatformMessageLocalFilter method apply.
/**
* {@inheritDoc}
*/
@Override
public boolean apply(UUID uuid, Object m) {
try (PlatformMemory mem = platformCtx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = platformCtx.writer(out);
writer.writeObject(uuid);
writer.writeObject(m);
out.synchronize();
int res = platformCtx.gateway().messagingFilterApply(hnd, mem.pointer());
return res != 0;
}
}
Aggregations