use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.
the class BinaryMarshallerSelfTest method binaryMarshaller.
/**
* @return Binary marshaller.
*/
protected BinaryMarshaller binaryMarshaller(BinaryNameMapper nameMapper, BinaryIdMapper mapper, BinarySerializer serializer, Collection<BinaryTypeConfiguration> cfgs, Collection<String> excludedClasses) throws IgniteCheckedException {
IgniteConfiguration iCfg = new IgniteConfiguration();
BinaryConfiguration bCfg = new BinaryConfiguration();
bCfg.setNameMapper(nameMapper);
bCfg.setIdMapper(mapper);
bCfg.setSerializer(serializer);
bCfg.setCompactFooter(compactFooter());
bCfg.setTypeConfigurations(cfgs);
iCfg.setBinaryConfiguration(bCfg);
iCfg.setClientMode(false);
iCfg.setDiscoverySpi(new TcpDiscoverySpi() {
@Override
public void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException {
//No-op.
}
});
BinaryContext ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), iCfg, new NullLogger());
BinaryMarshaller marsh = new BinaryMarshaller();
MarshallerContextTestImpl marshCtx = new MarshallerContextTestImpl(null, excludedClasses);
GridTestKernalContext kernCtx = new GridTestKernalContext(log, iCfg);
kernCtx.add(new GridDiscoveryManager(kernCtx));
marshCtx.onMarshallerProcessorStarted(kernCtx, null);
marsh.setContext(marshCtx);
IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg);
return marsh;
}
use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.
the class BinaryFooterOffsetsAbstractSelfTest method beforeTest.
/** {@inheritDoc} */
@Override
protected void beforeTest() throws Exception {
super.beforeTest();
ctx = new BinaryContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration(), new NullLogger());
marsh = new BinaryMarshaller();
IgniteConfiguration iCfg = new IgniteConfiguration();
BinaryConfiguration bCfg = new BinaryConfiguration();
bCfg.setTypeConfigurations(Arrays.asList(new BinaryTypeConfiguration(TestObject.class.getName())));
bCfg.setCompactFooter(compactFooter());
iCfg.setBinaryConfiguration(bCfg);
marsh.setContext(new MarshallerContextTestImpl(null));
IgniteUtils.invoke(BinaryMarshaller.class, marsh, "setBinaryContext", ctx, iCfg);
}
use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.
the class BinaryEnumsSelfTest method getConfiguration.
/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
if (register) {
BinaryConfiguration bCfg = new BinaryConfiguration();
BinaryTypeConfiguration enumCfg = new BinaryTypeConfiguration(EnumType.class.getName());
enumCfg.setEnum(true);
if (igniteInstanceName.equals(WRONG_CONF_NODE_NAME))
enumCfg.setEnumValues(F.asMap(EnumType.ONE.name(), EnumType.ONE.ordinal(), EnumType.TWO.name(), EnumType.ONE.ordinal()));
else
enumCfg.setEnumValues(F.asMap(EnumType.ONE.name(), EnumType.ONE.ordinal(), EnumType.TWO.name(), EnumType.TWO.ordinal()));
bCfg.setTypeConfigurations(Arrays.asList(enumCfg, new BinaryTypeConfiguration(EnumHolder.class.getName())));
cfg.setBinaryConfiguration(bCfg);
}
cfg.setMarshaller(new BinaryMarshaller());
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
ccfg.setName(CACHE_NAME);
ccfg.setCacheMode(CacheMode.PARTITIONED);
cfg.setCacheConfiguration(ccfg);
return cfg;
}
use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.
the class GridSpringBeanSerializationSelfTest method config.
/**
* @return Grid configuration.
*/
private IgniteConfiguration config() {
IgniteConfiguration cfg = new IgniteConfiguration();
TcpDiscoverySpi disco = new TcpDiscoverySpi();
disco.setIpFinder(IP_FINDER);
cfg.setDiscoverySpi(disco);
cfg.setUserAttributes(F.asMap(ATTR_KEY, true));
cfg.setConnectorConfiguration(null);
cfg.setIgniteInstanceName(getTestIgniteInstanceName());
cfg.setBinaryConfiguration(new BinaryConfiguration());
return cfg;
}
use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.
the class CacheObjectBinaryProcessorImpl method start.
/** {@inheritDoc} */
@Override
public void start(boolean activeOnStart) throws IgniteCheckedException {
if (marsh instanceof BinaryMarshaller) {
if (ctx.clientNode())
ctx.event().addLocalEventListener(clientDisconLsnr, EVT_CLIENT_NODE_DISCONNECTED);
transport = new BinaryMetadataTransport(metadataLocCache, ctx, log);
BinaryMetadataHandler metaHnd = new BinaryMetadataHandler() {
@Override
public void addMeta(int typeId, BinaryType newMeta) throws BinaryObjectException {
assert newMeta != null;
assert newMeta instanceof BinaryTypeImpl;
if (!discoveryStarted) {
BinaryMetadataHolder holder = metadataLocCache.get(typeId);
BinaryMetadata oldMeta = holder != null ? holder.metadata() : null;
BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, ((BinaryTypeImpl) newMeta).metadata());
if (oldMeta != mergedMeta)
metadataLocCache.putIfAbsent(typeId, new BinaryMetadataHolder(mergedMeta, 0, 0));
return;
}
BinaryMetadata newMeta0 = ((BinaryTypeImpl) newMeta).metadata();
CacheObjectBinaryProcessorImpl.this.addMeta(typeId, newMeta0.wrap(binaryCtx));
}
@Override
public BinaryType metadata(int typeId) throws BinaryObjectException {
return CacheObjectBinaryProcessorImpl.this.metadata(typeId);
}
@Override
public BinaryMetadata metadata0(int typeId) throws BinaryObjectException {
return CacheObjectBinaryProcessorImpl.this.metadata0(typeId);
}
@Override
public BinaryType metadata(int typeId, int schemaId) throws BinaryObjectException {
return CacheObjectBinaryProcessorImpl.this.metadata(typeId, schemaId);
}
};
BinaryMarshaller bMarsh0 = (BinaryMarshaller) marsh;
binaryCtx = new BinaryContext(metaHnd, ctx.config(), ctx.log(BinaryContext.class));
IgniteUtils.invoke(BinaryMarshaller.class, bMarsh0, "setBinaryContext", binaryCtx, ctx.config());
binaryMarsh = new GridBinaryMarshaller(binaryCtx);
binaries = new IgniteBinaryImpl(ctx, this);
if (!getBoolean(IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK)) {
BinaryConfiguration bCfg = ctx.config().getBinaryConfiguration();
if (bCfg != null) {
Map<String, Object> map = new HashMap<>();
map.put("globIdMapper", bCfg.getIdMapper() != null ? bCfg.getIdMapper().getClass().getName() : null);
map.put("globSerializer", bCfg.getSerializer() != null ? bCfg.getSerializer().getClass() : null);
map.put("compactFooter", bCfg.isCompactFooter());
if (bCfg.getTypeConfigurations() != null) {
Map<Object, Object> typeCfgsMap = new HashMap<>();
for (BinaryTypeConfiguration c : bCfg.getTypeConfigurations()) {
typeCfgsMap.put(c.getTypeName() != null, Arrays.asList(c.getIdMapper() != null ? c.getIdMapper().getClass() : null, c.getSerializer() != null ? c.getSerializer().getClass() : null, c.isEnum()));
if (c.isEnum())
BinaryUtils.validateEnumValues(c.getTypeName(), c.getEnumValues());
}
map.put("typeCfgs", typeCfgsMap);
}
ctx.addNodeAttribute(IgniteNodeAttributes.ATTR_BINARY_CONFIGURATION, map);
}
}
}
}
Aggregations