Search in sources :

Example 11 with BinaryRawWriterEx

use of org.apache.ignite.internal.binary.BinaryRawWriterEx in project ignite by apache.

the class PlatformClusterNodeFilterImpl method apply.

/** {@inheritDoc} */
@Override
public boolean apply(ClusterNode clusterNode) {
    try (PlatformMemory mem = ctx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx writer = ctx.writer(out);
        writer.writeObject(pred);
        ctx.writeNode(writer, clusterNode);
        out.synchronize();
        return ctx.gateway().clusterNodeFilterApply(mem.pointer()) != 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 12 with BinaryRawWriterEx

use of org.apache.ignite.internal.binary.BinaryRawWriterEx in project ignite by apache.

the class PlatformProcessorImpl method getIgniteConfiguration.

/** {@inheritDoc} */
@Override
public void getIgniteConfiguration(long memPtr) {
    PlatformOutputStream stream = platformCtx.memory().get(memPtr).output();
    BinaryRawWriterEx writer = platformCtx.writer(stream);
    PlatformConfigurationUtils.writeIgniteConfiguration(writer, ignite().configuration());
    stream.synchronize();
}
Also used : PlatformOutputStream(org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx)

Example 13 with BinaryRawWriterEx

use of org.apache.ignite.internal.binary.BinaryRawWriterEx in project ignite by apache.

the class PlatformProcessorImpl method getCacheNames.

/** {@inheritDoc} */
@Override
public void getCacheNames(long memPtr) {
    PlatformOutputStream stream = platformCtx.memory().get(memPtr).output();
    BinaryRawWriterEx writer = platformCtx.writer(stream);
    Collection<String> names = ignite().cacheNames();
    writer.writeInt(names.size());
    for (String name : names) writer.writeString(name);
    stream.synchronize();
}
Also used : PlatformOutputStream(org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx)

Example 14 with BinaryRawWriterEx

use of org.apache.ignite.internal.binary.BinaryRawWriterEx in project ignite by apache.

the class PlatformDotNetCacheStore method loadAll.

/** {@inheritDoc} */
@Override
public Map<K, V> loadAll(final Iterable<? extends K> keys) {
    try {
        final Map<K, V> loaded = new HashMap<>();
        final Collection keys0 = (Collection) keys;
        doInvoke(new IgniteInClosureX<BinaryRawWriterEx>() {

            @Override
            public void applyx(BinaryRawWriterEx writer) throws IgniteCheckedException {
                writer.writeByte(OP_LOAD_ALL);
                writer.writeLong(session());
                writer.writeString(ses.cacheName());
                writer.writeInt(keys0.size());
                for (Object o : keys0) writer.writeObject(o);
            }
        }, new IgniteInClosureX<BinaryRawReaderEx>() {

            @Override
            public void applyx(BinaryRawReaderEx reader) {
                int cnt = reader.readInt();
                for (int i = 0; i < cnt; i++) loaded.put((K) reader.readObjectDetached(), (V) reader.readObjectDetached());
            }
        });
        return loaded;
    } catch (IgniteCheckedException e) {
        throw new CacheLoaderException(e);
    }
}
Also used : HashMap(java.util.HashMap) BinaryRawReaderEx(org.apache.ignite.internal.binary.BinaryRawReaderEx) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CacheLoaderException(javax.cache.integration.CacheLoaderException) Collection(java.util.Collection) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx)

Example 15 with BinaryRawWriterEx

use of org.apache.ignite.internal.binary.BinaryRawWriterEx in project ignite by apache.

the class PlatformDotNetCacheStore method doInvoke.

/**
     * Perform actual invoke.
     *
     * @param task Task.
     * @param readClo Reader.
     * @return Result.
     * @throws org.apache.ignite.IgniteCheckedException If failed.
     */
protected int doInvoke(IgniteInClosure<BinaryRawWriterEx> task, IgniteInClosure<BinaryRawReaderEx> readClo) throws IgniteCheckedException {
    try (PlatformMemory mem = platformCtx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx writer = platformCtx.writer(out);
        writer.writeLong(ptr);
        task.apply(writer);
        out.synchronize();
        int res = platformCtx.gateway().cacheStoreInvoke(mem.pointer());
        if (res != 0) {
            // Read error
            Object nativeErr = platformCtx.reader(mem.input()).readObjectDetached();
            throw platformCtx.createNativeException(nativeErr);
        }
        if (readClo != null) {
            BinaryRawReaderEx reader = platformCtx.reader(mem);
            readClo.apply(reader);
        }
        return res;
    }
}
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)

Aggregations

BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)46 PlatformOutputStream (org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream)41 PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)39 BinaryRawReaderEx (org.apache.ignite.internal.binary.BinaryRawReaderEx)10 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 IgniteException (org.apache.ignite.IgniteException)6 PlatformInputStream (org.apache.ignite.internal.processors.platform.memory.PlatformInputStream)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 PlatformNativeException (org.apache.ignite.internal.processors.platform.PlatformNativeException)3 CacheEntryListenerException (javax.cache.event.CacheEntryListenerException)2 CacheLoaderException (javax.cache.integration.CacheLoaderException)2 PlatformContext (org.apache.ignite.internal.processors.platform.PlatformContext)2 PlatformExtendedException (org.apache.ignite.internal.processors.platform.PlatformExtendedException)2 PlatformTargetProxyImpl (org.apache.ignite.internal.processors.platform.PlatformTargetProxyImpl)2 Nullable (org.jetbrains.annotations.Nullable)2 IOException (java.io.IOException)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1