Search in sources :

Example 6 with MappedName

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);
        }
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) IgniteException(org.apache.ignite.IgniteException) BufferedReader(java.io.BufferedReader) MappedName(org.apache.ignite.internal.processors.marshaller.MappedName)

Example 7 with MappedName

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;
}
Also used : ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) MappedName(org.apache.ignite.internal.processors.marshaller.MappedName) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) GridDhtPartitionFullMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap) GridDhtPartitionMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap) AbstractMap(java.util.AbstractMap)

Example 8 with MappedName

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;
}
Also used : MappedName(org.apache.ignite.internal.processors.marshaller.MappedName)

Example 9 with MappedName

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 &gt; 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());
}
Also used : MarshallerMappingItem(org.apache.ignite.internal.processors.marshaller.MarshallerMappingItem) MarshallerContextImpl(org.apache.ignite.internal.MarshallerContextImpl) MappedName(org.apache.ignite.internal.processors.marshaller.MappedName) Map(java.util.Map)

Aggregations

MappedName (org.apache.ignite.internal.processors.marshaller.MappedName)9 MarshallerMappingItem (org.apache.ignite.internal.processors.marshaller.MarshallerMappingItem)3 Map (java.util.Map)2 BufferedReader (java.io.BufferedReader)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 AbstractMap (java.util.AbstractMap)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 IgniteException (org.apache.ignite.IgniteException)1 MarshallerContextImpl (org.apache.ignite.internal.MarshallerContextImpl)1 GridDhtPartitionFullMap (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap)1 GridDhtPartitionMap (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap)1 MappingExchangeResult (org.apache.ignite.internal.processors.marshaller.MappingExchangeResult)1 GridFutureAdapter (org.apache.ignite.internal.util.future.GridFutureAdapter)1