use of org.apache.ignite.internal.DuplicateTypeIdException in project ignite by apache.
the class BinaryContext method registerUserClassName.
/**
* Register "type ID to class name" mapping on all nodes to allow for mapping requests resolution form client.
* Other {@link BinaryContext}'s "register" methods and method
* {@link BinaryContext#descriptorForClass(Class, boolean)} already call this functionality so use this method
* only when registering class names whose {@link Class} is unknown.
*
* @param typeId Type ID.
* @param clsName Class Name.
* @return {@code True} if the mapping was registered successfully.
*/
public boolean registerUserClassName(int typeId, String clsName) {
IgniteCheckedException e = null;
boolean res = false;
try {
res = marshCtx.registerClassName(JAVA_ID, typeId, clsName);
} catch (DuplicateTypeIdException dupEx) {
// Ignore if trying to register mapped type name of the already registered class name and vise versa
BinaryInternalMapper mapper = userTypeMapper(typeId);
String oldName = dupEx.getRegisteredClassName();
if (!(mapper.typeName(oldName).equals(clsName) || mapper.typeName(clsName).equals(oldName)))
e = dupEx;
} catch (IgniteCheckedException igniteEx) {
e = igniteEx;
}
if (e != null)
throw new BinaryObjectException("Failed to register class.", e);
return res;
}
Aggregations