Search in sources :

Example 51 with PlatformMemory

use of org.apache.ignite.internal.processors.platform.memory.PlatformMemory in project ignite by apache.

the class PlatformAbstractJob method createJob.

/**
 * Create job in native platform if needed.
 *
 * @param ctx Context.
 * @return {@code True} if job was created, {@code false} if this is local job and creation is not necessary.
 * @throws org.apache.ignite.IgniteCheckedException If failed.
 */
protected boolean createJob(PlatformContext ctx) throws IgniteCheckedException {
    if (ptr == 0) {
        try (PlatformMemory mem = ctx.memory().allocate()) {
            PlatformOutputStream out = mem.output();
            BinaryRawWriterEx writer = ctx.writer(out);
            writer.writeObject(job);
            out.synchronize();
            ptr = ctx.gateway().computeJobCreate(mem.pointer());
        }
        return true;
    } else
        return false;
}
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 52 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)

Aggregations

PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)52 PlatformOutputStream (org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream)48 BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)45 BinaryRawReaderEx (org.apache.ignite.internal.binary.BinaryRawReaderEx)14 PlatformInputStream (org.apache.ignite.internal.processors.platform.memory.PlatformInputStream)11 IgniteException (org.apache.ignite.IgniteException)9 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 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 PlatformFutureUtils (org.apache.ignite.internal.processors.platform.utils.PlatformFutureUtils)2 IgniteFuture (org.apache.ignite.lang.IgniteFuture)2 IOException (java.io.IOException)1 Map (java.util.Map)1 CacheEntryEvent (javax.cache.event.CacheEntryEvent)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1