Search in sources :

Example 36 with PlatformOutputStream

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);
    }
}
Also used : PlatformOutputStream(org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream) PlatformMemory(org.apache.ignite.internal.processors.platform.memory.PlatformMemory) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) CacheEntryListenerException(javax.cache.event.CacheEntryListenerException) PlatformExtendedException(org.apache.ignite.internal.processors.platform.PlatformExtendedException) CacheException(javax.cache.CacheException) PlatformNativeException(org.apache.ignite.internal.processors.platform.PlatformNativeException)

Example 37 with PlatformOutputStream

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);
    }
}
Also used : PlatformOutputStream(org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx) CacheEntryEvent(javax.cache.event.CacheEntryEvent) PlatformMemory(org.apache.ignite.internal.processors.platform.memory.PlatformMemory) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) CacheEntryListenerException(javax.cache.event.CacheEntryListenerException) PlatformExtendedException(org.apache.ignite.internal.processors.platform.PlatformExtendedException) CacheException(javax.cache.CacheException) PlatformNativeException(org.apache.ignite.internal.processors.platform.PlatformNativeException)

Example 38 with PlatformOutputStream

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);
    }
}
Also used : PlatformCache(org.apache.ignite.internal.processors.platform.cache.PlatformCache) PlatformTargetProxy(org.apache.ignite.internal.processors.platform.PlatformTargetProxy) PlatformTargetProxyImpl(org.apache.ignite.internal.processors.platform.PlatformTargetProxyImpl) PlatformOutputStream(org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx) Map(java.util.Map) PlatformMemory(org.apache.ignite.internal.processors.platform.memory.PlatformMemory)

Example 39 with PlatformOutputStream

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);
        }
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) PlatformOutputStream(org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx) PlatformMemory(org.apache.ignite.internal.processors.platform.memory.PlatformMemory)

Example 40 with PlatformOutputStream

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;
    }
}
Also used : PlatformOutputStream(org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx) PlatformMemory(org.apache.ignite.internal.processors.platform.memory.PlatformMemory)

Aggregations

PlatformOutputStream (org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream)51 PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)48 BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)46 BinaryRawReaderEx (org.apache.ignite.internal.binary.BinaryRawReaderEx)11 PlatformInputStream (org.apache.ignite.internal.processors.platform.memory.PlatformInputStream)10 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 IgniteException (org.apache.ignite.IgniteException)7 PlatformContext (org.apache.ignite.internal.processors.platform.PlatformContext)4 PlatformNativeException (org.apache.ignite.internal.processors.platform.PlatformNativeException)4 CacheEntryListenerException (javax.cache.event.CacheEntryListenerException)3 PlatformExtendedException (org.apache.ignite.internal.processors.platform.PlatformExtendedException)3 Nullable (org.jetbrains.annotations.Nullable)3 CacheException (javax.cache.CacheException)2 PlatformTargetProxyImpl (org.apache.ignite.internal.processors.platform.PlatformTargetProxyImpl)2 IOException (java.io.IOException)1 Map (java.util.Map)1 CacheEntryEvent (javax.cache.event.CacheEntryEvent)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 ComputeJobResultPolicy (org.apache.ignite.compute.ComputeJobResultPolicy)1 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)1