use of org.apache.ignite.internal.binary.BinaryRawReaderEx in project ignite by apache.
the class PlatformTargetProxyImpl method inStreamAsync.
/** {@inheritDoc} */
@Override
public void inStreamAsync(int type, long memPtr) throws Exception {
try (PlatformMemory mem = platformCtx.memory().get(memPtr)) {
BinaryRawReaderEx reader = platformCtx.reader(mem);
long futId = reader.readLong();
int futTyp = reader.readInt();
final PlatformAsyncResult res = target.processInStreamAsync(type, reader);
if (res == null)
throw new IgniteException("PlatformTarget.processInStreamAsync should not return null.");
IgniteFuture fut = res.future();
if (fut == null)
throw new IgniteException("PlatformAsyncResult.future() should not return null.");
PlatformFutureUtils.listen(platformCtx, fut, futId, futTyp, new PlatformFutureUtils.Writer() {
/** {@inheritDoc} */
@Override
public void write(BinaryRawWriterEx writer, Object obj, Throwable err) {
res.write(writer, obj);
}
/** {@inheritDoc} */
@Override
public boolean canWrite(Object obj, Throwable err) {
return err == null;
}
}, target);
} catch (Exception e) {
throw target.convertException(e);
}
}
use of org.apache.ignite.internal.binary.BinaryRawReaderEx in project ignite by apache.
the class PlatformProcessorImpl method getOrCreateCacheFromConfig.
/** {@inheritDoc} */
@Override
public PlatformTargetProxy getOrCreateCacheFromConfig(long memPtr) throws IgniteCheckedException {
BinaryRawReaderEx reader = platformCtx.reader(platformCtx.memory().get(memPtr));
CacheConfiguration cfg = PlatformConfigurationUtils.readCacheConfiguration(reader);
IgniteCacheProxy cache = reader.readBoolean() ? (IgniteCacheProxy) ctx.grid().getOrCreateCache(cfg, PlatformConfigurationUtils.readNearConfiguration(reader)) : (IgniteCacheProxy) ctx.grid().getOrCreateCache(cfg);
return createPlatformCache(cache);
}
use of org.apache.ignite.internal.binary.BinaryRawReaderEx in project ignite by apache.
the class ClientMessageParser method decode.
/**
* {@inheritDoc}
*/
@Override
public ClientListenerRequest decode(byte[] msg) {
assert msg != null;
BinaryInputStream inStream = new BinaryHeapInputStream(msg);
// skipHdrCheck must be true (we have 103 op code).
BinaryRawReaderEx reader = new BinaryReaderExImpl(marsh.context(), inStream, null, null, true, true);
return decode(reader);
}
use of org.apache.ignite.internal.binary.BinaryRawReaderEx in project ignite by apache.
the class PlatformAbstractService method invokeMethod.
/**
* {@inheritDoc}
*/
@Override
public Object invokeMethod(String mthdName, boolean srvKeepBinary, Object[] args) throws IgniteCheckedException {
assert ptr != 0;
assert platformCtx != null;
try (PlatformMemory mem = platformCtx.memory().allocate()) {
PlatformOutputStream out = mem.output();
BinaryRawWriterEx writer = platformCtx.writer(out);
writer.writeLong(ptr);
writer.writeBoolean(srvKeepBinary);
writer.writeString(mthdName);
if (args == null)
writer.writeBoolean(false);
else {
writer.writeBoolean(true);
writer.writeInt(args.length);
for (Object arg : args) writer.writeObjectDetached(arg);
}
out.synchronize();
platformCtx.gateway().serviceInvokeMethod(mem.pointer());
PlatformInputStream in = mem.input();
in.synchronize();
BinaryRawReaderEx reader = platformCtx.reader(in);
return PlatformUtils.readInvocationResult(platformCtx, reader);
}
}
use of org.apache.ignite.internal.binary.BinaryRawReaderEx in project ignite by apache.
the class PlatformUtils method readBinaryMetadata.
/**
* Reads the binary metadata.
*
* @param reader Reader.
* @return Binary type metadata.
*/
public static BinaryMetadata readBinaryMetadata(BinaryRawReaderEx reader) {
int typeId = reader.readInt();
String typeName = reader.readString();
String affKey = reader.readString();
Map<String, BinaryFieldMetadata> fields = readLinkedMap(reader, new PlatformReaderBiClosure<String, BinaryFieldMetadata>() {
@Override
public IgniteBiTuple<String, BinaryFieldMetadata> read(BinaryRawReaderEx reader) {
String name = reader.readString();
int typeId = reader.readInt();
int fieldId = reader.readInt();
return new IgniteBiTuple<String, BinaryFieldMetadata>(name, new BinaryFieldMetadata(typeId, fieldId));
}
});
Map<String, Integer> enumMap = null;
boolean isEnum = reader.readBoolean();
if (isEnum) {
int size = reader.readInt();
enumMap = new LinkedHashMap<>(size);
for (int idx = 0; idx < size; idx++) enumMap.put(reader.readString(), reader.readInt());
}
// Read schemas
int schemaCnt = reader.readInt();
List<BinarySchema> schemas = null;
if (schemaCnt > 0) {
schemas = new ArrayList<>(schemaCnt);
for (int i = 0; i < schemaCnt; i++) {
int id = reader.readInt();
int fieldCnt = reader.readInt();
List<Integer> fieldIds = new ArrayList<>(fieldCnt);
for (int j = 0; j < fieldCnt; j++) fieldIds.add(reader.readInt());
schemas.add(new BinarySchema(id, fieldIds));
}
}
return new BinaryMetadata(typeId, typeName, fields, affKey, schemas, isEnum, enumMap);
}
Aggregations