use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.
the class BinaryContext method configure.
/**
* @param marsh Binary marshaller.
* @param cfg Configuration.
* @throws BinaryObjectException In case of error.
*/
public void configure(BinaryMarshaller marsh, IgniteConfiguration cfg) throws BinaryObjectException {
if (marsh == null)
return;
this.marsh = marsh;
marshCtx = marsh.getContext();
BinaryConfiguration binaryCfg = cfg.getBinaryConfiguration();
if (binaryCfg == null)
binaryCfg = new BinaryConfiguration();
assert marshCtx != null;
optmMarsh.setContext(marshCtx);
configure(binaryCfg.getNameMapper(), binaryCfg.getIdMapper(), binaryCfg.getSerializer(), binaryCfg.getTypeConfigurations());
compactFooter = binaryCfg.isCompactFooter();
}
use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.
the class BinaryObjectExceptionSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
cfg.setMarshaller(new BinaryMarshaller());
cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(IP_FINDER));
cfg.setCacheConfiguration(new CacheConfiguration(cacheName).setCopyOnRead(true));
BinaryConfiguration bcfg = new BinaryConfiguration().setNameMapper(new BinaryBasicNameMapper(false));
cfg.setBinaryConfiguration(bcfg);
return cfg;
}
use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.
the class GridAbstractTest method getConfiguration.
/**
* This method should be overridden by subclasses to change configuration parameters.
*
* @param igniteInstanceName Ignite instance name.
* @return Grid configuration used for starting of grid.
* @throws Exception If failed.
*/
@SuppressWarnings("deprecation")
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = getConfiguration(igniteInstanceName, getTestResources());
cfg.setNodeId(null);
if (GridTestProperties.getProperty(GridTestProperties.BINARY_COMPACT_FOOTERS) != null) {
if (!Boolean.valueOf(GridTestProperties.getProperty(GridTestProperties.BINARY_COMPACT_FOOTERS))) {
BinaryConfiguration bCfg = cfg.getBinaryConfiguration();
if (bCfg == null) {
bCfg = new BinaryConfiguration();
cfg.setBinaryConfiguration(bCfg);
}
bCfg.setCompactFooter(false);
}
}
if (Boolean.valueOf(GridTestProperties.getProperty(BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER))) {
BinaryConfiguration bCfg = cfg.getBinaryConfiguration();
if (bCfg == null) {
bCfg = new BinaryConfiguration();
cfg.setBinaryConfiguration(bCfg);
}
bCfg.setNameMapper(new BinaryBasicNameMapper(true));
}
if (igniteInstanceName != null && igniteInstanceName.matches(".*\\d")) {
String idStr = UUID.randomUUID().toString();
if (igniteInstanceName.startsWith(getTestIgniteInstanceName())) {
String idxStr = String.valueOf(getTestIgniteInstanceIndex(igniteInstanceName));
while (idxStr.length() < 5) idxStr = '0' + idxStr;
char[] chars = idStr.toCharArray();
for (int i = 0; i < idxStr.length(); i++) chars[chars.length - idxStr.length() + i] = idxStr.charAt(i);
cfg.setNodeId(UUID.fromString(new String(chars)));
} else {
char[] chars = idStr.toCharArray();
chars[0] = igniteInstanceName.charAt(igniteInstanceName.length() - 1);
chars[1] = '0';
chars[chars.length - 3] = '0';
chars[chars.length - 2] = '0';
chars[chars.length - 1] = igniteInstanceName.charAt(igniteInstanceName.length() - 1);
cfg.setNodeId(UUID.fromString(new String(chars)));
}
}
if (isMultiJvm())
((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(LOCAL_IP_FINDER);
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);
}
}
}
}
use of org.apache.ignite.configuration.BinaryConfiguration in project ignite by apache.
the class GridDefaultBinaryMappersBinaryMetaDataSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
BinaryConfiguration bCfg = new BinaryConfiguration();
bCfg.setNameMapper(new BinaryBasicNameMapper(false));
bCfg.setIdMapper(new BinaryBasicIdMapper(false));
bCfg.setClassNames(Arrays.asList(TestObject1.class.getName(), TestObject2.class.getName()));
cfg.setBinaryConfiguration(bCfg);
cfg.setMarshaller(new BinaryMarshaller());
CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
cfg.setCacheConfiguration(ccfg);
GridDefaultBinaryMappersBinaryMetaDataSelfTest.cfg = cfg;
return cfg;
}
Aggregations