Search in sources :

Example 1 with PlatformTargetProxyImpl

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

the class PlatformAffinityFunction method start.

/**
 * {@inheritDoc}
 */
@Override
public void start() throws IgniteException {
    // userFunc is null when there is nothing overridden
    if (userFunc == null)
        return;
    assert ignite != null;
    ctx = PlatformUtils.platformContext(ignite);
    assert ctx != null;
    try (PlatformMemory mem = ctx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        BinaryRawWriterEx writer = ctx.writer(out);
        writer.writeObject(userFunc);
        out.synchronize();
        baseTarget = baseFunc != null ? new PlatformAffinityFunctionTarget(ctx, baseFunc) : null;
        PlatformTargetProxyImpl baseTargetProxy = baseTarget != null ? new PlatformTargetProxyImpl(baseTarget, ctx) : null;
        ptr = ctx.gateway().affinityFunctionInit(mem.pointer(), baseTargetProxy);
    }
}
Also used : PlatformTargetProxyImpl(org.apache.ignite.internal.processors.platform.PlatformTargetProxyImpl) 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 2 with PlatformTargetProxyImpl

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

the class PlatformStreamReceiverImpl method receive.

/**
 * {@inheritDoc}
 */
@Override
public void receive(IgniteCache<Object, Object> cache, Collection<Map.Entry<Object, Object>> collection) throws IgniteException {
    assert ctx != null;
    try (PlatformMemory mem = ctx.memory().allocate()) {
        PlatformOutputStream out = mem.output();
        out.writeLong(ptr);
        out.writeBoolean(keepBinary);
        BinaryRawWriterEx writer = ctx.writer(out);
        writer.writeObject(pred);
        writer.writeInt(collection.size());
        for (Map.Entry<Object, Object> e : collection) {
            writer.writeObject(e.getKey());
            writer.writeObject(e.getValue());
        }
        out.synchronize();
        PlatformCache cache0 = new PlatformCache(ctx, cache, keepBinary);
        PlatformTargetProxy cacheProxy = new PlatformTargetProxyImpl(cache0, ctx);
        ctx.gateway().dataStreamerStreamReceiverInvoke(ptr, cacheProxy, mem.pointer(), keepBinary);
    }
}
Also used : PlatformCache(org.apache.ignite.internal.processors.platform.cache.PlatformCache) PlatformTargetProxy(org.apache.ignite.internal.processors.platform.PlatformTargetProxy) PlatformTargetProxyImpl(org.apache.ignite.internal.processors.platform.PlatformTargetProxyImpl) PlatformOutputStream(org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream) BinaryRawWriterEx(org.apache.ignite.internal.binary.BinaryRawWriterEx) Map(java.util.Map) PlatformMemory(org.apache.ignite.internal.processors.platform.memory.PlatformMemory)

Aggregations

BinaryRawWriterEx (org.apache.ignite.internal.binary.BinaryRawWriterEx)2 PlatformTargetProxyImpl (org.apache.ignite.internal.processors.platform.PlatformTargetProxyImpl)2 PlatformMemory (org.apache.ignite.internal.processors.platform.memory.PlatformMemory)2 PlatformOutputStream (org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream)2 Map (java.util.Map)1 PlatformTargetProxy (org.apache.ignite.internal.processors.platform.PlatformTargetProxy)1 PlatformCache (org.apache.ignite.internal.processors.platform.cache.PlatformCache)1