Search in sources :

Example 6 with PlatformContext

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

the class GridQueryProcessor method registerPlatformTypeLocally.

/**
 * Registers platform type locally.
 *
 * @param clsName Class name.
 * @param binProc Binary processor.
 */
private void registerPlatformTypeLocally(String clsName, CacheObjectBinaryProcessorImpl binProc) {
    PlatformProcessor platformProc = ctx.platform();
    if (platformProc == null || !platformProc.hasContext())
        return;
    PlatformContext platformCtx = platformProc.context();
    BinaryMetadata meta = platformCtx.getBinaryType(clsName);
    if (meta != null)
        binProc.binaryContext().registerClassLocally(meta.wrap(binProc.binaryContext()), false, platformCtx.getMarshallerPlatformId());
}
Also used : PlatformProcessor(org.apache.ignite.internal.processors.platform.PlatformProcessor) PlatformContext(org.apache.ignite.internal.processors.platform.PlatformContext) BinaryMetadata(org.apache.ignite.internal.binary.BinaryMetadata)

Example 7 with PlatformContext

use of org.apache.ignite.internal.processors.platform.PlatformContext 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 8 with PlatformContext

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

the class ClientDataStreamerStartRequest method createReceiver.

/**
 * Creates the receiver.
 *
 * @param ctx Kernal context.
 * @param receiverObj Receiver.
 * @param platform Platform code.
 * @param keepBinary Keep binary flag.
 * @return Receiver.
 */
private static StreamReceiver createReceiver(GridKernalContext ctx, Object receiverObj, byte platform, boolean keepBinary) {
    if (receiverObj == null)
        return null;
    switch(platform) {
        case ClientPlatform.JAVA:
            return ((BinaryObject) receiverObj).deserialize();
        case ClientPlatform.DOTNET:
            PlatformContext platformCtx = ctx.platform().context();
            String curPlatform = platformCtx.platform();
            if (!PlatformUtils.PLATFORM_DOTNET.equals(curPlatform)) {
                throw new IgniteException("Stream receiver platform is " + PlatformUtils.PLATFORM_DOTNET + ", current platform is " + curPlatform);
            }
            return platformCtx.createStreamReceiver(receiverObj, 0, keepBinary);
        case ClientPlatform.CPP:
        default:
            throw new UnsupportedOperationException("Invalid stream receiver platform code: " + platform);
    }
}
Also used : BinaryObject(org.apache.ignite.binary.BinaryObject) IgniteException(org.apache.ignite.IgniteException) PlatformContext(org.apache.ignite.internal.processors.platform.PlatformContext)

Example 9 with PlatformContext

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

Aggregations

PlatformContext (org.apache.ignite.internal.processors.platform.PlatformContext)9 PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)4 PlatformOutputStream (org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream)4 IgniteException (org.apache.ignite.IgniteException)3 BinaryObject (org.apache.ignite.binary.BinaryObject)3 BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)3 CacheEntryListenerException (javax.cache.event.CacheEntryListenerException)2 PlatformInputStream (org.apache.ignite.internal.processors.platform.memory.PlatformInputStream)2 IOException (java.io.IOException)1 BinaryMetadata (org.apache.ignite.internal.binary.BinaryMetadata)1 PlatformExtendedException (org.apache.ignite.internal.processors.platform.PlatformExtendedException)1 PlatformProcessor (org.apache.ignite.internal.processors.platform.PlatformProcessor)1