use of org.apache.ignite.internal.binary.BinaryRawReaderEx in project ignite by apache.
the class PlatformFullTask method map.
/**
* {@inheritDoc}
*/
@NotNull
@Override
public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> subgrid, @Nullable Object arg) {
assert arg == null;
lock.readLock().lock();
try {
assert !done;
Collection<ClusterNode> nodes = compute.clusterGroup().nodes();
PlatformMemoryManager memMgr = ctx.memory();
try (PlatformMemory mem = memMgr.allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = ctx.writer(out);
writer.writeLong(taskPtr);
write(writer, nodes, subgrid);
out.synchronize();
ctx.gateway().computeTaskMap(mem.pointer());
PlatformInputStream in = mem.input();
in.synchronize();
BinaryRawReaderEx reader = ctx.reader(in);
return read(reader, nodes);
}
} finally {
lock.readLock().unlock();
}
}
use of org.apache.ignite.internal.binary.BinaryRawReaderEx in project ignite by apache.
the class PlatformFullJob method execute0.
/**
* {@inheritDoc}
*/
@Nullable
@Override
public Object execute0(PlatformContext ctx) throws IgniteCheckedException {
boolean cancel = false;
synchronized (this) {
// 1. Create job if necessary.
if (task == null) {
assert ptr == 0;
createJob(ctx);
} else
assert ptr != 0;
// 2. Set correct state.
if (state == STATE_INIT)
state = STATE_RUNNING;
else {
assert state == STATE_CANCELLED;
cancel = true;
}
}
try {
if (task != null)
return runLocal(ctx, cancel);
else {
try (PlatformMemory mem = ctx.memory().allocate()) {
PlatformOutputStream out = mem.output();
out.writeLong(ptr);
// cancel
out.writeBoolean(cancel);
out.synchronize();
ctx.gateway().computeJobExecute(mem.pointer());
PlatformInputStream in = mem.input();
in.synchronize();
BinaryRawReaderEx reader = ctx.reader(in);
return PlatformUtils.readInvocationResult(ctx, reader);
}
}
} finally {
synchronized (this) {
if (task == null) {
assert ptr != 0;
ctx.gateway().computeJobDestroy(ptr);
}
if (state == STATE_RUNNING)
state = STATE_COMPLETED;
}
}
}
use of org.apache.ignite.internal.binary.BinaryRawReaderEx in project ignite by apache.
the class PlatformJavaObjectFactoryProxy method readBinary.
/**
* {@inheritDoc}
*/
@Override
public void readBinary(BinaryReader reader) throws BinaryObjectException {
BinaryRawReaderEx rawReader = (BinaryRawReaderEx) reader.rawReader();
factoryTyp = rawReader.readInt();
clsName = rawReader.readString();
payload = rawReader.readObjectDetached();
int propsSize = rawReader.readInt();
if (propsSize > 0) {
props = new HashMap<>(propsSize);
for (int i = 0; i < propsSize; i++) {
String key = rawReader.readString();
Object val = rawReader.readObjectDetached();
props.put(key, val);
}
}
}
use of org.apache.ignite.internal.binary.BinaryRawReaderEx in project ignite by apache.
the class PlatformTargetProxyImpl method inObjectStreamOutObjectStream.
/**
* {@inheritDoc}
*/
@Override
public Object inObjectStreamOutObjectStream(int type, Object arg, long inMemPtr, long outMemPtr) throws Exception {
PlatformMemory inMem = null;
PlatformMemory outMem = null;
try {
BinaryRawReaderEx reader = null;
if (inMemPtr != 0) {
inMem = platformCtx.memory().get(inMemPtr);
reader = platformCtx.reader(inMem);
}
PlatformOutputStream out = null;
BinaryRawWriterEx writer = null;
if (outMemPtr != 0) {
outMem = platformCtx.memory().get(outMemPtr);
out = outMem.output();
writer = platformCtx.writer(out);
}
PlatformTarget res = target.processInObjectStreamOutObjectStream(type, unwrapProxy(arg), reader, writer);
if (out != null)
out.synchronize();
return wrapProxy(res);
} catch (Exception e) {
throw target.convertException(e);
} finally {
try {
if (inMem != null)
inMem.close();
} finally {
if (outMem != null)
outMem.close();
}
}
}
use of org.apache.ignite.internal.binary.BinaryRawReaderEx in project ignite by apache.
the class PlatformProcessorImpl method createCacheFromConfig.
/** {@inheritDoc} */
@Override
public PlatformTargetProxy createCacheFromConfig(long memPtr) throws IgniteCheckedException {
BinaryRawReaderEx reader = platformCtx.reader(platformCtx.memory().get(memPtr));
CacheConfiguration cfg = PlatformConfigurationUtils.readCacheConfiguration(reader);
IgniteCacheProxy cache = reader.readBoolean() ? (IgniteCacheProxy) ctx.grid().createCache(cfg, PlatformConfigurationUtils.readNearConfiguration(reader)) : (IgniteCacheProxy) ctx.grid().createCache(cfg);
return createPlatformCache(cache);
}
Aggregations