Search in sources :

Example 16 with BinaryRawWriterEx

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

the class PlatformDotNetCacheStore method load.

/** {@inheritDoc} */
@Nullable
@Override
public V load(final K key) {
    try {
        final GridTuple<V> val = new GridTuple<>();
        doInvoke(new IgniteInClosureX<BinaryRawWriterEx>() {

            @Override
            public void applyx(BinaryRawWriterEx writer) throws IgniteCheckedException {
                writer.writeByte(OP_LOAD);
                writer.writeLong(session());
                writer.writeString(ses.cacheName());
                writer.writeObject(key);
            }
        }, new IgniteInClosureX<BinaryRawReaderEx>() {

            @Override
            public void applyx(BinaryRawReaderEx reader) {
                val.set((V) reader.readObjectDetached());
            }
        });
        return val.get();
    } catch (IgniteCheckedException e) {
        throw new CacheLoaderException(e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CacheLoaderException(javax.cache.integration.CacheLoaderException) GridTuple(org.apache.ignite.internal.util.lang.GridTuple) BinaryRawReaderEx(org.apache.ignite.internal.binary.BinaryRawReaderEx) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with BinaryRawWriterEx

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

the class PlatformConfigurationUtils method writeDotNetConfiguration.

/**
     * Write .Net configuration to the stream.
     *
     * @param writer Writer.
     * @param cfg Configuration.
     */
public static void writeDotNetConfiguration(BinaryRawWriterEx writer, PlatformDotNetConfiguration cfg) {
    // 1. Write assemblies.
    PlatformUtils.writeNullableCollection(writer, cfg.getAssemblies());
    PlatformDotNetBinaryConfiguration binaryCfg = cfg.getBinaryConfiguration();
    if (binaryCfg != null) {
        writer.writeBoolean(true);
        PlatformUtils.writeNullableCollection(writer, binaryCfg.getTypesConfiguration(), new PlatformWriterClosure<PlatformDotNetBinaryTypeConfiguration>() {

            @Override
            public void write(BinaryRawWriterEx writer, PlatformDotNetBinaryTypeConfiguration typ) {
                writer.writeString(typ.getTypeName());
                writer.writeString(typ.getNameMapper());
                writer.writeString(typ.getIdMapper());
                writer.writeString(typ.getSerializer());
                writer.writeString(typ.getAffinityKeyFieldName());
                writer.writeObject(typ.getKeepDeserialized());
                writer.writeBoolean(typ.isEnum());
            }
        });
        PlatformUtils.writeNullableCollection(writer, binaryCfg.getTypes());
        writer.writeString(binaryCfg.getDefaultNameMapper());
        writer.writeString(binaryCfg.getDefaultIdMapper());
        writer.writeString(binaryCfg.getDefaultSerializer());
        writer.writeBoolean(binaryCfg.isDefaultKeepDeserialized());
    } else
        writer.writeBoolean(false);
}
Also used : PlatformDotNetBinaryTypeConfiguration(org.apache.ignite.platform.dotnet.PlatformDotNetBinaryTypeConfiguration) PlatformDotNetBinaryConfiguration(org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx)

Example 18 with BinaryRawWriterEx

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

the class PlatformMessageFilterImpl method initialize.

/** {@inheritDoc} */
@Override
public void initialize(GridKernalContext kernalCtx) {
    if (ptr != 0)
        return;
    ctx = PlatformUtils.platformContext(kernalCtx.grid());
    try (PlatformMemory mem = ctx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx writer = ctx.writer(out);
        writer.writeObject(pred);
        out.synchronize();
        ptr = ctx.gateway().messagingFilterCreate(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 19 with BinaryRawWriterEx

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

the class PlatformAbstractService method init.

/** {@inheritDoc} */
@Override
public void init(ServiceContext ctx) throws Exception {
    assert ptr == 0;
    assert platformCtx != null;
    try (PlatformMemory mem = platformCtx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx writer = platformCtx.writer(out);
        writer.writeBoolean(srvKeepBinary);
        writer.writeObject(svc);
        writeServiceContext(ctx, writer);
        out.synchronize();
        ptr = platformCtx.gateway().serviceInit(mem.pointer());
    } catch (IgniteCheckedException e) {
        throw U.convertException(e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) 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 20 with BinaryRawWriterEx

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

the class PlatformAbstractService method cancel.

/** {@inheritDoc} */
@Override
public void cancel(ServiceContext ctx) {
    assert ptr != 0;
    assert platformCtx != null;
    try (PlatformMemory mem = platformCtx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx writer = platformCtx.writer(out);
        writer.writeLong(ptr);
        writer.writeBoolean(srvKeepBinary);
        writeServiceContext(ctx, writer);
        out.synchronize();
        platformCtx.gateway().serviceCancel(mem.pointer());
    } catch (IgniteCheckedException e) {
        throw U.convertException(e);
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) 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

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