use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream in project ignite by apache.
the class PlatformCache method writeResult.
/**
* Writes the result to reused stream, if any.
*/
public long writeResult(PlatformMemory mem, Object obj, PlatformWriterClosure clo) {
if (obj == null)
return FALSE;
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = platformCtx.writer(out);
if (clo == null)
writer.writeObjectDetached(obj);
else
clo.write(writer, obj);
out.synchronize();
return TRUE;
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream in project ignite by apache.
the class PlatformCacheEntryFilterImpl method init.
/**
* Initializes this instance.
*
* @param cacheId Optional cache id for platform cache.
*/
private void init(Integer cacheId) {
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = ctx.writer(out);
writer.writeObject(pred);
if (cacheId != null) {
writer.writeBoolean(true);
writer.writeInt(cacheId);
} else {
writer.writeBoolean(false);
}
out.synchronize();
ptr = ctx.gateway().cacheEntryFilterCreate(mem.pointer());
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream in project ignite by apache.
the class PlatformCacheEntryProcessorImpl method execute0.
/**
* Executes interop entry processor on a given entry, updates entry and returns result.
*
* @param ctx Context.
* @param entry Entry.
* @return Processing result.
*/
private Object execute0(PlatformContext ctx, MutableEntry entry) {
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = ctx.writer(out);
writeEntryAndProcessor(entry, writer);
out.synchronize();
ctx.gateway().cacheInvoke(mem.pointer());
PlatformInputStream in = mem.input();
in.synchronize();
BinaryRawReaderEx reader = ctx.reader(in);
return readResultAndUpdateEntry(ctx, entry, reader);
}
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream 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());
// Register query entity meta.
ctx.query().registerMetadataForRegisteredCaches(true);
}
use of org.apache.ignite.internal.processors.platform.memory.PlatformOutputStream in project ignite by apache.
the class PlatformContextImpl method addNode.
/**
* {@inheritDoc}
*/
@Override
public void addNode(ClusterNode node) {
if (node == null || sentNodes.contains(node.id()))
return;
// Send node info to the native platform
try (PlatformMemory mem0 = mem.allocate()) {
PlatformOutputStream out = mem0.output();
BinaryRawWriterEx w = writer(out);
w.writeUuid(node.id());
PlatformUtils.writeNodeAttributes(w, node.attributes());
w.writeCollection(node.addresses());
w.writeCollection(node.hostNames());
w.writeLong(node.order());
w.writeBoolean(node.isLocal());
w.writeBoolean(node.isDaemon());
w.writeBoolean(node.isClient());
w.writeObjectDetached(node.consistentId());
PlatformUtils.writeNodeVersion(w, node.version());
writeClusterMetrics(w, node.metrics());
out.synchronize();
gateway().nodeInfo(mem0.pointer());
}
sentNodes.add(node.id());
}
Aggregations