Search in sources :

Example 6 with BinaryIdMapper

use of org.apache.ignite.binary.BinaryIdMapper in project ignite by apache.

the class GridBinaryWildcardsSelfTest method testTypeConfigurationsWithNonGlobalMapperJar.

/**
 * @throws Exception If failed.
 */
public void testTypeConfigurationsWithNonGlobalMapperJar() throws Exception {
    BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() {

        @SuppressWarnings("IfMayBeConditional")
        @Override
        public int typeId(String clsName) {
            if (clsName.endsWith("1"))
                return 300;
            else if (clsName.endsWith("2"))
                return 400;
            else
                return -500;
        }

        @Override
        public int fieldId(int typeId, String fieldName) {
            return 0;
        }
    }, Arrays.asList(new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"), new BinaryTypeConfiguration("unknown.*")));
    BinaryContext ctx = binaryContext(marsh);
    Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
    assertEquals(3, typeMappers.size());
    assertFalse(((BinaryBasicNameMapper) typeMappers.get(CLASS1_FULL_NAME).nameMapper()).isSimpleName());
    assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
    assertFalse(((BinaryBasicNameMapper) typeMappers.get(CLASS2_FULL_NAME).nameMapper()).isSimpleName());
    assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
}
Also used : BinaryBasicNameMapper(org.apache.ignite.binary.BinaryBasicNameMapper) BinaryIdMapper(org.apache.ignite.binary.BinaryIdMapper) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration)

Example 7 with BinaryIdMapper

use of org.apache.ignite.binary.BinaryIdMapper in project ignite by apache.

the class GridBinaryWildcardsSelfTest method testClassNamesWithCustomMapperJar.

/**
 * @throws Exception If failed.
 */
public void testClassNamesWithCustomMapperJar() throws Exception {
    BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() {

        @SuppressWarnings("IfMayBeConditional")
        @Override
        public int typeId(String clsName) {
            if (clsName.endsWith("1"))
                return 300;
            else if (clsName.endsWith("2"))
                return 400;
            else
                return -500;
        }

        @Override
        public int fieldId(int typeId, String fieldName) {
            return 0;
        }
    }, Arrays.asList(new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"), new BinaryTypeConfiguration("unknown.*")));
    BinaryContext ctx = binaryContext(marsh);
    Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
    assertEquals(3, typeMappers.size());
    assertFalse(((BinaryBasicNameMapper) typeMappers.get(CLASS1_FULL_NAME).nameMapper()).isSimpleName());
    assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
    assertFalse(((BinaryBasicNameMapper) typeMappers.get(CLASS2_FULL_NAME).nameMapper()).isSimpleName());
    assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
}
Also used : BinaryBasicNameMapper(org.apache.ignite.binary.BinaryBasicNameMapper) BinaryIdMapper(org.apache.ignite.binary.BinaryIdMapper) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration)

Example 8 with BinaryIdMapper

use of org.apache.ignite.binary.BinaryIdMapper in project ignite by apache.

the class GridBinaryWildcardsSelfTest method testClassNamesCustomMappers.

/**
 * @throws Exception If failed.
 */
public void testClassNamesCustomMappers() throws Exception {
    BinaryMarshaller marsh = binaryMarshaller(null, new BinaryIdMapper() {

        @SuppressWarnings("IfMayBeConditional")
        @Override
        public int typeId(String clsName) {
            if (clsName.endsWith("1"))
                return 300;
            else if (clsName.endsWith("2"))
                return 400;
            else if (clsName.endsWith("InnerClass"))
                return 500;
            else
                return -500;
        }

        @Override
        public int fieldId(int typeId, String fieldName) {
            return 0;
        }
    }, Arrays.asList(new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"), new BinaryTypeConfiguration("unknown.*")));
    BinaryContext ctx = binaryContext(marsh);
    Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
    assertEquals(3, typeMappers.size());
    assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
    assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
    assertEquals(500, typeMappers.get(INNER_CLASS_FULL_NAME).idMapper().typeId(INNER_CLASS_FULL_NAME));
}
Also used : BinaryIdMapper(org.apache.ignite.binary.BinaryIdMapper) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration)

Example 9 with BinaryIdMapper

use of org.apache.ignite.binary.BinaryIdMapper in project ignite by apache.

the class GridBinaryWildcardsSelfTest method testTypeConfigurationsWithNonGlobalMapper.

/**
 * @throws Exception If failed.
 */
public void testTypeConfigurationsWithNonGlobalMapper() throws Exception {
    BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(true), new BinaryIdMapper() {

        @SuppressWarnings("IfMayBeConditional")
        @Override
        public int typeId(String clsName) {
            if (clsName.endsWith("1"))
                return 300;
            else if (clsName.endsWith("2"))
                return 400;
            else if (clsName.endsWith("InnerClass"))
                return 500;
            else
                return -500;
        }

        @Override
        public int fieldId(int typeId, String fieldName) {
            return 0;
        }
    }, Arrays.asList(new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"), new BinaryTypeConfiguration("unknown.*")));
    BinaryContext ctx = binaryContext(marsh);
    Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
    assertEquals(3, typeMappers.size());
    assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
    assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
    assertEquals(500, typeMappers.get(INNER_CLASS_FULL_NAME).idMapper().typeId(INNER_CLASS_FULL_NAME));
}
Also used : BinaryBasicNameMapper(org.apache.ignite.binary.BinaryBasicNameMapper) BinaryIdMapper(org.apache.ignite.binary.BinaryIdMapper) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration)

Example 10 with BinaryIdMapper

use of org.apache.ignite.binary.BinaryIdMapper in project ignite by apache.

the class GridBinaryWildcardsSelfTest method testTypeConfigurationsWithGlobalMapperJar.

/**
 * @throws Exception If failed.
 */
public void testTypeConfigurationsWithGlobalMapperJar() throws Exception {
    BinaryMarshaller marsh = binaryMarshaller(new BinaryBasicNameMapper(false), new BinaryIdMapper() {

        @SuppressWarnings("IfMayBeConditional")
        @Override
        public int typeId(String clsName) {
            if (clsName.endsWith("1"))
                return 300;
            else if (clsName.endsWith("2"))
                return 400;
            else
                return -500;
        }

        @Override
        public int fieldId(int typeId, String fieldName) {
            return 0;
        }
    }, Arrays.asList(new BinaryTypeConfiguration("org.apache.ignite.internal.binary.test.*"), new BinaryTypeConfiguration("unknown.*")));
    BinaryContext ctx = binaryContext(marsh);
    Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers = U.field(ctx, "cls2Mappers");
    assertEquals(3, typeMappers.size());
    assertFalse(((BinaryBasicNameMapper) typeMappers.get(CLASS1_FULL_NAME).nameMapper()).isSimpleName());
    assertEquals(300, typeMappers.get(CLASS1_FULL_NAME).idMapper().typeId(CLASS1_FULL_NAME));
    assertFalse(((BinaryBasicNameMapper) typeMappers.get(CLASS2_FULL_NAME).nameMapper()).isSimpleName());
    assertEquals(400, typeMappers.get(CLASS2_FULL_NAME).idMapper().typeId(CLASS2_FULL_NAME));
}
Also used : BinaryBasicNameMapper(org.apache.ignite.binary.BinaryBasicNameMapper) BinaryIdMapper(org.apache.ignite.binary.BinaryIdMapper) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration)

Aggregations

BinaryIdMapper (org.apache.ignite.binary.BinaryIdMapper)23 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)21 BinaryBasicNameMapper (org.apache.ignite.binary.BinaryBasicNameMapper)12 BinaryBasicIdMapper (org.apache.ignite.binary.BinaryBasicIdMapper)7 BinaryNameMapper (org.apache.ignite.binary.BinaryNameMapper)4 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)2 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteException (org.apache.ignite.IgniteException)1 BinaryObjectException (org.apache.ignite.binary.BinaryObjectException)1 BinarySerializer (org.apache.ignite.binary.BinarySerializer)1 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 PlatformConfiguration (org.apache.ignite.configuration.PlatformConfiguration)1