Search in sources :

Example 26 with PlatformOutputStream

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

the class PlatformCache method writeResult.

/**
 * Writes the result to reused stream, if any.
 */
public long writeResult(PlatformMemory mem, Object obj, PlatformWriterClosure clo) {
    if (obj == null)
        return FALSE;
    PlatformOutputStream out = mem.output();
    BinaryRawWriterEx writer = platformCtx.writer(out);
    if (clo == null)
        writer.writeObjectDetached(obj);
    else
        clo.write(writer, obj);
    out.synchronize();
    return TRUE;
}
Also used : PlatformOutputStream(org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx)

Example 27 with PlatformOutputStream

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

the class PlatformCacheEntryFilterImpl method init.

/**
 * Initializes this instance.
 *
 * @param cacheId Optional cache id for platform cache.
 */
private void init(Integer cacheId) {
    try (PlatformMemory mem = ctx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx writer = ctx.writer(out);
        writer.writeObject(pred);
        if (cacheId != null) {
            writer.writeBoolean(true);
            writer.writeInt(cacheId);
        } else {
            writer.writeBoolean(false);
        }
        out.synchronize();
        ptr = ctx.gateway().cacheEntryFilterCreate(mem.pointer());
    }
}
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 28 with PlatformOutputStream

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

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

the class PlatformProcessorImpl method start.

/**
 * {@inheritDoc}
 */
@Override
public void start() throws IgniteCheckedException {
    try (PlatformMemory mem = platformCtx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx writer = platformCtx.writer(out);
        writer.writeString(ctx.igniteInstanceName());
        out.synchronize();
        platformCtx.gateway().onStart(new PlatformTargetProxyImpl(this, platformCtx), mem.pointer());
    }
    // At this moment all necessary native libraries must be loaded, so we can process with store creation.
    storeLock.writeLock().lock();
    try {
        for (StoreInfo store : pendingStores) registerStore0(store.store, store.convertBinary);
        pendingStores.clear();
        started = true;
    } finally {
        storeLock.writeLock().unlock();
    }
    // Add Interop node attributes.
    ctx.addNodeAttribute(PlatformUtils.ATTR_PLATFORM, interopCfg.platform());
    // Register query entity meta.
    ctx.query().registerMetadataForRegisteredCaches(true);
}
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 30 with PlatformOutputStream

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

the class PlatformContextImpl method addNode.

/**
 * {@inheritDoc}
 */
@Override
public void addNode(ClusterNode node) {
    if (node == null || sentNodes.contains(node.id()))
        return;
    // Send node info to the native platform
    try (PlatformMemory mem0 = mem.allocate()) {
        PlatformOutputStream out = mem0.output();
        BinaryRawWriterEx w = writer(out);
        w.writeUuid(node.id());
        PlatformUtils.writeNodeAttributes(w, node.attributes());
        w.writeCollection(node.addresses());
        w.writeCollection(node.hostNames());
        w.writeLong(node.order());
        w.writeBoolean(node.isLocal());
        w.writeBoolean(node.isDaemon());
        w.writeBoolean(node.isClient());
        w.writeObjectDetached(node.consistentId());
        PlatformUtils.writeNodeVersion(w, node.version());
        writeClusterMetrics(w, node.metrics());
        out.synchronize();
        gateway().nodeInfo(mem0.pointer());
    }
    sentNodes.add(node.id());
}
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)

Aggregations

PlatformOutputStream (org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream)51 PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)48 BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)46 BinaryRawReaderEx (org.apache.ignite.internal.binary.BinaryRawReaderEx)11 PlatformInputStream (org.apache.ignite.internal.processors.platform.memory.PlatformInputStream)10 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 IgniteException (org.apache.ignite.IgniteException)7 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 IOException (java.io.IOException)1 Map (java.util.Map)1 CacheEntryEvent (javax.cache.event.CacheEntryEvent)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 ComputeJobResultPolicy (org.apache.ignite.compute.ComputeJobResultPolicy)1 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)1