Search in sources :

Example 11 with PlatformInputStream

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

the class PlatformAbstractFunc method invoke.

/**
 * Invokes this instance.
 *
 * @return Invocation result.
 */
protected Object invoke() throws IgniteCheckedException {
    assert ignite != null;
    PlatformContext ctx = PlatformUtils.platformContext(ignite);
    try (PlatformMemory mem = ctx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        if (ptr != 0) {
            out.writeBoolean(true);
            out.writeLong(ptr);
        } else {
            out.writeBoolean(false);
            ctx.writer(out).writeObject(func);
        }
        out.synchronize();
        platformCallback(ctx.gateway(), mem.pointer());
        PlatformInputStream in = mem.input();
        in.synchronize();
        return PlatformUtils.readInvocationResult(ctx, ctx.reader(in));
    }
}
Also used : PlatformInputStream(org.apache.ignite.internal.processors.platform.memory.PlatformInputStream) PlatformContext(org.apache.ignite.internal.processors.platform.PlatformContext) PlatformOutputStream(org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream) PlatformMemory(org.apache.ignite.internal.processors.platform.memory.PlatformMemory)

Example 12 with PlatformInputStream

use of org.apache.ignite.internal.processors.platform.memory.PlatformInputStream 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 13 with PlatformInputStream

use of org.apache.ignite.internal.processors.platform.memory.PlatformInputStream 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

PlatformInputStream (org.apache.ignite.internal.processors.platform.memory.PlatformInputStream)13 PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)11 PlatformOutputStream (org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream)10 BinaryRawReaderEx (org.apache.ignite.internal.binary.BinaryRawReaderEx)8 BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)7 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 Nullable (org.jetbrains.annotations.Nullable)3 PlatformContext (org.apache.ignite.internal.processors.platform.PlatformContext)2 PlatformExternalMemory (org.apache.ignite.internal.processors.platform.memory.PlatformExternalMemory)2 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 PlatformExtendedException (org.apache.ignite.internal.processors.platform.PlatformExtendedException)1 PlatformMemoryManager (org.apache.ignite.internal.processors.platform.memory.PlatformMemoryManager)1 NotNull (org.jetbrains.annotations.NotNull)1