Search in sources :

Example 21 with PlatformMemory

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;
    }
}
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)

Example 22 with PlatformMemory

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());
    }
}
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)

Example 23 with PlatformMemory

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

Example 24 with PlatformMemory

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);
    }
}
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 25 with PlatformMemory

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());
    }
}
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

PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)44 PlatformOutputStream (org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream)41 BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)39 BinaryRawReaderEx (org.apache.ignite.internal.binary.BinaryRawReaderEx)11 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 IgniteException (org.apache.ignite.IgniteException)7 PlatformInputStream (org.apache.ignite.internal.processors.platform.memory.PlatformInputStream)7 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 Map (java.util.Map)2 CacheException (javax.cache.CacheException)2 PlatformContext (org.apache.ignite.internal.processors.platform.PlatformContext)2 PlatformTargetProxyImpl (org.apache.ignite.internal.processors.platform.PlatformTargetProxyImpl)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CacheEntryEvent (javax.cache.event.CacheEntryEvent)1