use of org.apache.ignite.internal.processors.platform.memory.PlatformMemory in project ignite by apache.
the class PlatformFullJob method serialize.
/**
* Internal job serialization routine.
*
* @throws org.apache.ignite.IgniteCheckedException If failed.
*/
private void serialize() throws IgniteCheckedException {
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformInputStream in = mem.input();
boolean res = ctx.gateway().computeJobSerialize(ptr, mem.pointer()) == 1;
in.synchronize();
BinaryRawReaderEx reader = ctx.reader(in);
if (res)
job = reader.readObjectDetached();
else
throw new IgniteCheckedException(reader.readString());
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformMemory 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);
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformMemory in project ignite by apache.
the class PlatformDotNetCacheStore method initialize.
/**
* Initialize the store.
*
* @param ctx Context.
* @param convertBinary Convert binary flag.
* @throws org.apache.ignite.IgniteCheckedException
*/
public void initialize(GridKernalContext ctx, boolean convertBinary) throws IgniteCheckedException {
A.ensure(typName != null || nativeFactory != null, "Either typName or nativeFactory must be set in PlatformDotNetCacheStore");
platformCtx = PlatformUtils.platformContext(ctx.grid());
try (PlatformMemory mem = platformCtx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = platformCtx.writer(out);
write(writer, convertBinary);
out.synchronize();
try {
ptr = platformCtx.gateway().cacheStoreCreate(mem.pointer());
} catch (IgniteException e) {
// CacheAffinitySharedManager.processClientCacheStartRequests()
throw new IgniteCheckedException("Could not create .NET CacheStore", e);
}
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformMemory 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());
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformMemory in project ignite by apache.
the class PlatformTargetProxyImpl method inStreamOutStream.
/**
* {@inheritDoc}
*/
@Override
public void inStreamOutStream(int type, long inMemPtr, long outMemPtr) throws Exception {
try (PlatformMemory inMem = platformCtx.memory().get(inMemPtr)) {
BinaryRawReaderEx reader = platformCtx.reader(inMem);
try (PlatformMemory outMem = platformCtx.memory().get(outMemPtr)) {
PlatformOutputStream out = outMem.output();
BinaryRawWriterEx writer = platformCtx.writer(out);
target.processInStreamOutStream(type, reader, writer);
out.synchronize();
}
} catch (Exception e) {
throw target.convertException(e);
}
}
Aggregations