Search in sources :

Example 56 with BinaryRawWriterEx

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

the class PlatformMessageLocalFilter method apply.

/**
 * {@inheritDoc}
 */
@Override
public boolean apply(UUID uuid, Object m) {
    try (PlatformMemory mem = platformCtx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx writer = platformCtx.writer(out);
        writer.writeObject(uuid);
        writer.writeObject(m);
        out.synchronize();
        int res = platformCtx.gateway().messagingFilterApply(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 57 with BinaryRawWriterEx

use of org.apache.ignite.internal.binary.BinaryRawWriterEx 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 58 with BinaryRawWriterEx

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

the class PlatformMessageFilterImpl method apply.

/**
 * {@inheritDoc}
 */
@Override
public boolean apply(UUID uuid, Object m) {
    if (ptr == 0)
        // Destroyed.
        return false;
    try (PlatformMemory mem = ctx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx writer = ctx.writer(out);
        writer.writeObject(uuid);
        writer.writeObject(m);
        out.synchronize();
        return ctx.gateway().messagingFilterApply(ptr, 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 59 with BinaryRawWriterEx

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

the class PlatformLocalEventListener method apply.

/**
 * {@inheritDoc}
 */
@Override
public boolean apply(Event evt) {
    assert ignite != null;
    PlatformContext ctx = PlatformUtils.platformContext(ignite);
    assert ctx != null;
    try (PlatformMemory mem = ctx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx writer = ctx.writer(out);
        writer.writeInt(id);
        ctx.writeEvent(writer, evt);
        out.synchronize();
        long res = ctx.gateway().eventLocalListenerApply(mem.pointer());
        return res != 0;
    }
}
Also used : PlatformContext(org.apache.ignite.internal.processors.platform.PlatformContext) 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 60 with BinaryRawWriterEx

use of org.apache.ignite.internal.binary.BinaryRawWriterEx 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

BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)60 PlatformOutputStream (org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream)46 PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)45 BinaryRawReaderEx (org.apache.ignite.internal.binary.BinaryRawReaderEx)13 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 IgniteException (org.apache.ignite.IgniteException)8 Map (java.util.Map)5 PlatformInputStream (org.apache.ignite.internal.processors.platform.memory.PlatformInputStream)5 HashMap (java.util.HashMap)4 Nullable (org.jetbrains.annotations.Nullable)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 BinaryWriterExImpl (org.apache.ignite.internal.binary.BinaryWriterExImpl)3 Array (java.lang.reflect.Array)2 SimpleEntry (java.util.AbstractMap.SimpleEntry)2 Arrays (java.util.Arrays)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 LinkedList (java.util.LinkedList)2