You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Artem Shutak (JIRA)" <ji...@apache.org> on 2016/01/15 16:43:40 UTC
[jira] [Comment Edited] (IGNITE-2395) Binary marshaller: id mapper
must be resolved according to configuration.
[ https://issues.apache.org/jira/browse/IGNITE-2395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15101869#comment-15101869 ]
Artem Shutak edited comment on IGNITE-2395 at 1/15/16 3:43 PM:
---------------------------------------------------------------
How to resolve id mapper according to configuration (code example)
{code}
/**
* @param typeName Type name.
* @param cfg Binary configuration.
* @return BinaryIdMapper according to configuration.
*/
private static BinaryIdMapper resolveIdMapper(String typeName, BinaryConfiguration cfg) {
assert typeName != null;
BinaryIdMapper globalIdMapper = cfg.getIdMapper();
Collection<BinaryTypeConfiguration> typeCfgs = cfg.getTypeConfigurations();
if (typeCfgs != null) {
for (BinaryTypeConfiguration typeCfg : typeCfgs) {
String clsName = typeCfg.getTypeName();
if (clsName != null && clsName.endsWith(".*")) {
String pkgName = clsName.substring(0, clsName.length() - 2);
String typePkgName = typeName.substring(0, typeName.lastIndexOf('.'));
if (pkgName.equals(typePkgName)) {
BinaryIdMapper idMapper = globalIdMapper;
if (typeCfg.getIdMapper() != null)
idMapper = typeCfg.getIdMapper();
idMapper = resolveIdMapper(idMapper);
return idMapper;
}
}
}
}
return resolveIdMapper(globalIdMapper);
}
{code}
was (Author: ashutak):
How to resolve id mapper according configuration (code example)
{code}
/**
* @param typeName Type name.
* @param cfg Binary configuration.
* @return BinaryIdMapper according to configuration.
*/
private static BinaryIdMapper resolveIdMapper(String typeName, BinaryConfiguration cfg) {
assert typeName != null;
BinaryIdMapper globalIdMapper = cfg.getIdMapper();
Collection<BinaryTypeConfiguration> typeCfgs = cfg.getTypeConfigurations();
if (typeCfgs != null) {
for (BinaryTypeConfiguration typeCfg : typeCfgs) {
String clsName = typeCfg.getTypeName();
if (clsName != null && clsName.endsWith(".*")) {
String pkgName = clsName.substring(0, clsName.length() - 2);
String typePkgName = typeName.substring(0, typeName.lastIndexOf('.'));
if (pkgName.equals(typePkgName)) {
BinaryIdMapper idMapper = globalIdMapper;
if (typeCfg.getIdMapper() != null)
idMapper = typeCfg.getIdMapper();
idMapper = resolveIdMapper(idMapper);
return idMapper;
}
}
}
}
return resolveIdMapper(globalIdMapper);
}
{code}
> Binary marshaller: id mapper must be resolved according to configuration.
> -------------------------------------------------------------------------
>
> Key: IGNITE-2395
> URL: https://issues.apache.org/jira/browse/IGNITE-2395
> Project: Ignite
> Issue Type: Bug
> Reporter: Artem Shutak
> Assignee: Artem Shutak
> Priority: Critical
> Fix For: 1.6
>
>
> The following scenario does not works
> - start node with BinaryMarshaller and set BinaryConfiguration with not-default BinaryIdMapper (see BinarySimpleNameIdMapper)
> - Execute the following code (it fails):
> {code}
> BinaryObjectBuilder builder = builder("org.my.Class");
> BinaryObject bo = builder.build();
> assertEquals("class".hashCode(), bo.type().typeId());
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)