Search in sources :

Example 6 with BinaryRawWriterEx

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

the class PlatformProcessorImpl method start.

/** {@inheritDoc} */
@Override
public void start(boolean activeOnStart) 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(this, 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());
}
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 7 with BinaryRawWriterEx

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

the class PlatformTargetProxyImpl method inStreamAsync.

/** {@inheritDoc} */
@Override
public void inStreamAsync(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.");
        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 8 with BinaryRawWriterEx

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

the class PlatformTargetProxyImpl method outStream.

/** {@inheritDoc} */
@Override
public void outStream(int type, long memPtr) throws Exception {
    try (PlatformMemory mem = platformCtx.memory().get(memPtr)) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx writer = platformCtx.writer(out);
        target.processOutStream(type, writer);
        out.synchronize();
    } catch (Exception e) {
        throw target.convertException(e);
    }
}
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) IgniteException(org.apache.ignite.IgniteException)

Example 9 with BinaryRawWriterEx

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

the class PlatformTargetProxyImpl method inObjectStreamOutObjectStream.

/** {@inheritDoc} */
@Override
public Object inObjectStreamOutObjectStream(int type, Object arg, long inMemPtr, long outMemPtr) throws Exception {
    PlatformMemory inMem = null;
    PlatformMemory outMem = null;
    try {
        BinaryRawReaderEx reader = null;
        if (inMemPtr != 0) {
            inMem = platformCtx.memory().get(inMemPtr);
            reader = platformCtx.reader(inMem);
        }
        PlatformOutputStream out = null;
        BinaryRawWriterEx writer = null;
        if (outMemPtr != 0) {
            outMem = platformCtx.memory().get(outMemPtr);
            out = outMem.output();
            writer = platformCtx.writer(out);
        }
        PlatformTarget res = target.processInObjectStreamOutObjectStream(type, unwrapProxy(arg), reader, writer);
        if (out != null)
            out.synchronize();
        return wrapProxy(res);
    } catch (Exception e) {
        throw target.convertException(e);
    } finally {
        try {
            if (inMem != null)
                inMem.close();
        } finally {
            if (outMem != null)
                outMem.close();
        }
    }
}
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 10 with BinaryRawWriterEx

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

the class PlatformContinuousQueryRemoteFilter method deploy.

/**
     * Deploy filter to native platform.
     */
private void deploy() {
    lock.writeLock().lock();
    try {
        // 1. Do not deploy if the filter has been closed concurrently.
        if (closed)
            throw new CacheEntryListenerException("Failed to deploy the filter because it has been closed.");
        // 2. Deploy.
        PlatformContext ctx = PlatformUtils.platformContext(grid);
        try (PlatformMemory mem = ctx.memory().allocate()) {
            PlatformOutputStream out = mem.output();
            BinaryRawWriterEx writer = ctx.writer(out);
            writer.writeObject(filter);
            out.synchronize();
            ptr = ctx.gateway().continuousQueryFilterCreate(mem.pointer());
        } catch (Exception e) {
            // 3. Close in case of failure.
            close();
            throw new CacheEntryListenerException("Failed to deploy the filter.", e);
        }
    } finally {
        lock.writeLock().unlock();
    }
}
Also used : PlatformContext(org.apache.ignite.internal.processors.platform.PlatformContext) CacheEntryListenerException(javax.cache.event.CacheEntryListenerException) 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) IOException(java.io.IOException) CacheEntryListenerException(javax.cache.event.CacheEntryListenerException)

Aggregations

BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)46 PlatformOutputStream (org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream)41 PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)39 BinaryRawReaderEx (org.apache.ignite.internal.binary.BinaryRawReaderEx)10 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)7 IgniteException (org.apache.ignite.IgniteException)6 PlatformInputStream (org.apache.ignite.internal.processors.platform.memory.PlatformInputStream)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 PlatformNativeException (org.apache.ignite.internal.processors.platform.PlatformNativeException)3 CacheEntryListenerException (javax.cache.event.CacheEntryListenerException)2 CacheLoaderException (javax.cache.integration.CacheLoaderException)2 PlatformContext (org.apache.ignite.internal.processors.platform.PlatformContext)2 PlatformExtendedException (org.apache.ignite.internal.processors.platform.PlatformExtendedException)2 PlatformTargetProxyImpl (org.apache.ignite.internal.processors.platform.PlatformTargetProxyImpl)2 Nullable (org.jetbrains.annotations.Nullable)2 IOException (java.io.IOException)1 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1