use of org.apache.ignite.internal.binary.BinaryContext in project ignite by apache.
the class GridAbstractTest method createStandaloneBinaryMarshaller.
/**
* Create instance of {@link BinaryMarshaller} suitable for use
* without starting a grid upon given {@link IgniteConfiguration}.
* @return Binary marshaller.
* @throws IgniteCheckedException if failed.
*/
protected BinaryMarshaller createStandaloneBinaryMarshaller(IgniteConfiguration cfg) throws IgniteCheckedException {
BinaryMarshaller marsh = new BinaryMarshaller();
BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), cfg, new NullLogger());
marsh.setContext(new MarshallerContextTestImpl());
IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, cfg);
return marsh;
}
use of org.apache.ignite.internal.binary.BinaryContext in project ignite by apache.
the class IgniteTestResources method getMarshaller.
/**
* @return Marshaller.
* @throws IgniteCheckedException If failed.
*/
@SuppressWarnings("unchecked")
public static synchronized Marshaller getMarshaller() throws IgniteCheckedException {
String marshallerName = System.getProperty(MARSH_CLASS_NAME, GridTestProperties.getProperty(GridTestProperties.MARSH_CLASS_NAME));
Marshaller marsh;
if (marshallerName == null)
marsh = new BinaryMarshaller();
else {
try {
Class<? extends Marshaller> cls = (Class<? extends Marshaller>) Class.forName(marshallerName);
marsh = cls.newInstance();
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
throw new IgniteCheckedException("Failed to create test marshaller [marshaller=" + marshallerName + ']', e);
}
}
marsh.setContext(new MarshallerContextTestImpl());
if (marsh instanceof BinaryMarshaller) {
BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), new NullLogger());
IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, new IgniteConfiguration());
}
return marsh;
}
use of org.apache.ignite.internal.binary.BinaryContext in project ignite by apache.
the class PlatformContextImpl method processMetadata.
/** {@inheritDoc} */
@SuppressWarnings("ConstantConditions")
@Override
public void processMetadata(BinaryRawReaderEx reader) {
Collection<BinaryMetadata> metas = PlatformUtils.readCollection(reader, new PlatformReaderClosure<BinaryMetadata>() {
@Override
public BinaryMetadata read(BinaryRawReaderEx reader) {
int typeId = reader.readInt();
String typeName = reader.readString();
String affKey = reader.readString();
Map<String, BinaryFieldMetadata> fields = PlatformUtils.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);
}
});
BinaryContext binCtx = cacheObjProc.binaryContext();
for (BinaryMetadata meta : metas) binCtx.updateMetadata(meta.typeId(), meta);
}
use of org.apache.ignite.internal.binary.BinaryContext in project ignite by apache.
the class GridCacheUtilsSelfTest method binaryMarshaller.
/**
* @return Binary marshaller.
* @throws IgniteCheckedException if failed.
*/
private BinaryMarshaller binaryMarshaller() throws IgniteCheckedException {
IgniteConfiguration iCfg = new IgniteConfiguration();
BinaryConfiguration bCfg = new BinaryConfiguration();
iCfg.setBinaryConfiguration(bCfg);
BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), iCfg, new NullLogger());
BinaryMarshaller marsh = new BinaryMarshaller();
marsh.setContext(new MarshallerContextTestImpl(null));
IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg);
return marsh;
}
Aggregations