use of org.apache.ignite.internal.processors.marshaller.MappedName in project ignite by apache.
the class MarshallerContextImpl method processResource.
/**
* @param url Resource URL.
* @throws IOException In case of error.
*/
private void processResource(URL url) throws IOException {
try (InputStream in = url.openStream()) {
BufferedReader rdr = new BufferedReader(new InputStreamReader(in));
String line;
while ((line = rdr.readLine()) != null) {
if (line.isEmpty() || line.startsWith("#"))
continue;
String clsName = line.trim();
int typeId = clsName.hashCode();
MappedName oldClsName;
if ((oldClsName = sysTypesMap.put(typeId, new MappedName(clsName, true))) != null) {
if (!oldClsName.className().equals(clsName))
throw new IgniteException("Duplicate type ID [id=" + typeId + ", oldClsName=" + oldClsName + ", clsName=" + clsName + ']');
}
sysTypesSet.add(clsName);
}
}
}
use of org.apache.ignite.internal.processors.marshaller.MappedName in project ignite by apache.
the class MarshallerContextImpl method getCachedMappings.
/** */
public ArrayList<Map<Integer, MappedName>> getCachedMappings() {
int size = allCaches.size();
ArrayList<Map<Integer, MappedName>> result = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
Map res;
if (i == JAVA_ID)
res = ((CombinedMap) allCaches.get(JAVA_ID)).userMap;
else
res = allCaches.get(i);
if (res != null && !res.isEmpty())
result.add(res);
else
result.add(Collections.<Integer, MappedName>emptyMap());
}
return result;
}
use of org.apache.ignite.internal.processors.marshaller.MappedName in project ignite by apache.
the class MarshallerContextImpl method resolveMissedMapping.
/**
* @param platformId Platform id.
* @param typeId Type id.
*/
public String resolveMissedMapping(byte platformId, int typeId) {
ConcurrentMap<Integer, MappedName> cache = getCacheFor(platformId);
MappedName mappedName = cache.get(typeId);
if (mappedName != null) {
assert mappedName.accepted() : mappedName;
return mappedName.className();
}
return null;
}
use of org.apache.ignite.internal.processors.marshaller.MappedName in project ignite by apache.
the class MarshallerContextSelfTest method testMultiplatformMappingsCollecting.
/**
* Test for adding non-java mappings (with platformId > 0) to MarshallerContext and collecting them
* for discovery.
*
* @throws Exception If failed.
*/
public void testMultiplatformMappingsCollecting() throws Exception {
String nonJavaClassName = "random.platform.Mapping";
MarshallerContextImpl marshCtx = new MarshallerContextImpl(null);
marshCtx.onMarshallerProcessorStarted(ctx, null);
MarshallerMappingItem item = new MarshallerMappingItem((byte) 2, 101, nonJavaClassName);
marshCtx.onMappingProposed(item);
marshCtx.onMappingAccepted(item);
ArrayList<Map<Integer, MappedName>> allMappings = marshCtx.getCachedMappings();
assertEquals(allMappings.size(), 3);
assertTrue(allMappings.get(0).isEmpty());
assertTrue(allMappings.get(1).isEmpty());
Map<Integer, MappedName> nonJavaMappings = allMappings.get(2);
assertNotNull(nonJavaMappings);
assertNotNull(nonJavaMappings.get(101));
assertEquals(nonJavaClassName, nonJavaMappings.get(101).className());
}
Aggregations