Search in sources :

Example 16 with BinaryRawReaderEx

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

the class PlatformCacheEntryProcessorImpl method execute0.

/**
 * Executes interop entry processor on a given entry, updates entry and returns result.
 *
 * @param ctx Context.
 * @param entry Entry.
 * @return Processing result.
 */
private Object execute0(PlatformContext ctx, MutableEntry entry) {
    try (PlatformMemory mem = ctx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx writer = ctx.writer(out);
        writeEntryAndProcessor(entry, writer);
        out.synchronize();
        ctx.gateway().cacheInvoke(mem.pointer());
        PlatformInputStream in = mem.input();
        in.synchronize();
        BinaryRawReaderEx reader = ctx.reader(in);
        return readResultAndUpdateEntry(ctx, entry, reader);
    }
}
Also used : PlatformInputStream(org.apache.ignite.internal.processors.platform.memory.PlatformInputStream) 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 17 with BinaryRawReaderEx

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

the class PlatformTargetProxyImpl method inStreamOutStream.

/**
 * {@inheritDoc}
 */
@Override
public void inStreamOutStream(int type, long inMemPtr, long outMemPtr) throws Exception {
    try (PlatformMemory inMem = platformCtx.memory().get(inMemPtr)) {
        BinaryRawReaderEx reader = platformCtx.reader(inMem);
        try (PlatformMemory outMem = platformCtx.memory().get(outMemPtr)) {
            PlatformOutputStream out = outMem.output();
            BinaryRawWriterEx writer = platformCtx.writer(out);
            target.processInStreamOutStream(type, reader, writer);
            out.synchronize();
        }
    } catch (Exception e) {
        throw target.convertException(e);
    }
}
Also used : BinaryRawReaderEx(org.apache.ignite.internal.binary.BinaryRawReaderEx) 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) IgniteException(org.apache.ignite.IgniteException)

Example 18 with BinaryRawReaderEx

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

the class PlatformTargetProxyImpl method inStreamOutListenableAsync.

/**
 * Performs asyncronous operation.
 *
 * @param type Type.
 * @param memPtr Stream pointer.
 * @return Listenable.
 * @throws Exception On error.
 */
private PlatformListenable inStreamOutListenableAsync(int type, long memPtr) throws Exception {
    try (PlatformMemory mem = platformCtx.memory().get(memPtr)) {
        BinaryRawReaderEx reader = platformCtx.reader(mem);
        long futId = reader.readLong();
        int futTyp = reader.readInt();
        final PlatformAsyncResult res = target.processInStreamAsync(type, reader);
        if (res == null)
            throw new IgniteException("PlatformTarget.processInStreamAsync should not return null.");
        IgniteFuture fut = res.future();
        if (fut == null)
            throw new IgniteException("PlatformAsyncResult.future() should not return null.");
        return PlatformFutureUtils.listen(platformCtx, fut, futId, futTyp, new PlatformFutureUtils.Writer() {

            /**
             * {@inheritDoc}
             */
            @Override
            public void write(BinaryRawWriterEx writer, Object obj, Throwable err) {
                res.write(writer, obj);
            }

            /**
             * {@inheritDoc}
             */
            @Override
            public boolean canWrite(Object obj, Throwable err) {
                return err == null;
            }
        }, target);
    } catch (Exception e) {
        throw target.convertException(e);
    }
}
Also used : PlatformFutureUtils(org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils) IgniteFuture(org.apache.ignite.lang.IgniteFuture) BinaryRawReaderEx(org.apache.ignite.internal.binary.BinaryRawReaderEx) IgniteException(org.apache.ignite.IgniteException) IgniteException(org.apache.ignite.IgniteException) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx) PlatformMemory(org.apache.ignite.internal.processors.platform.memory.PlatformMemory)

Example 19 with BinaryRawReaderEx

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

the class PlatformClosureJob method execute0.

/**
 * {@inheritDoc}
 */
@Nullable
@Override
public Object execute0(PlatformContext ctx) throws IgniteCheckedException {
    if (task == null) {
        // Remote job execution.
        assert ptr == 0;
        createJob(ctx);
        try (PlatformMemory mem = ctx.memory().allocate()) {
            PlatformOutputStream out = mem.output();
            out.writeLong(ptr);
            // cancel
            out.writeBoolean(false);
            out.synchronize();
            ctx.gateway().computeJobExecute(mem.pointer());
            PlatformInputStream in = mem.input();
            in.synchronize();
            BinaryRawReaderEx reader = ctx.reader(in);
            return PlatformUtils.readInvocationResult(ctx, reader);
        } finally {
            ctx.gateway().computeJobDestroy(ptr);
        }
    } else {
        // Local job execution.
        assert ptr != 0;
        return runLocal(ctx, false);
    }
}
Also used : PlatformInputStream(org.apache.ignite.internal.processors.platform.memory.PlatformInputStream) PlatformOutputStream(org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream) BinaryRawReaderEx(org.apache.ignite.internal.binary.BinaryRawReaderEx) PlatformMemory(org.apache.ignite.internal.processors.platform.memory.PlatformMemory) Nullable(org.jetbrains.annotations.Nullable)

Example 20 with BinaryRawReaderEx

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

the class PlatformFullJob method serialize.

/**
 * Internal job serialization routine.
 *
 * @throws org.apache.ignite.IgniteCheckedException If failed.
 */
private void serialize() throws IgniteCheckedException {
    try (PlatformMemory mem = ctx.memory().allocate()) {
        PlatformInputStream in = mem.input();
        boolean res = ctx.gateway().computeJobSerialize(ptr, mem.pointer()) == 1;
        in.synchronize();
        BinaryRawReaderEx reader = ctx.reader(in);
        if (res)
            job = reader.readObjectDetached();
        else
            throw new IgniteCheckedException(reader.readString());
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) PlatformInputStream(org.apache.ignite.internal.processors.platform.memory.PlatformInputStream) BinaryRawReaderEx(org.apache.ignite.internal.binary.BinaryRawReaderEx) PlatformMemory(org.apache.ignite.internal.processors.platform.memory.PlatformMemory)

Aggregations

BinaryRawReaderEx (org.apache.ignite.internal.binary.BinaryRawReaderEx)21 PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)14 BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)13 PlatformOutputStream (org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream)11 PlatformInputStream (org.apache.ignite.internal.processors.platform.memory.PlatformInputStream)8 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 IgniteException (org.apache.ignite.IgniteException)4 Nullable (org.jetbrains.annotations.Nullable)3 CacheLoaderException (javax.cache.integration.CacheLoaderException)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)2 IgniteCacheProxy (org.apache.ignite.internal.processors.cache.IgniteCacheProxy)2 PlatformFutureUtils (org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils)2 IgniteFuture (org.apache.ignite.lang.IgniteFuture)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 BinaryFieldMetadata (org.apache.ignite.internal.binary.BinaryFieldMetadata)1 BinaryMetadata (org.apache.ignite.internal.binary.BinaryMetadata)1