Search in sources :

Example 6 with MarshallerContextImpl

use of org.apache.ignite.internal.MarshallerContextImpl in project ignite by apache.

the class MarshallerContextSelfTest method testOnUpdated.

/**
     * @throws Exception If failed.
     */
public void testOnUpdated() throws Exception {
    File workDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "marshaller", false);
    MarshallerContextImpl ctx = new MarshallerContextImpl(null);
    ctx.onMarshallerProcessorStarted(this.ctx, null);
    MarshallerMappingItem item1 = new MarshallerMappingItem(JAVA_ID, 1, String.class.getName());
    ctx.onMappingAccepted(item1);
    // Wait until marshaller context write class to file.
    U.sleep(2_000);
    checkFileName("java.lang.String", Paths.get(workDir + "/1.classname0"));
    MarshallerMappingItem item2 = new MarshallerMappingItem((byte) 2, 2, "Random.Class.Name");
    ctx.onMappingProposed(item2);
    ctx.onMappingAccepted(item2);
    execSvc.shutdown();
    if (execSvc.awaitTermination(1000, TimeUnit.MILLISECONDS))
        checkFileName("Random.Class.Name", Paths.get(workDir + "/2.classname2"));
    else
        fail("Failed to wait for executor service to shutdown");
}
Also used : MarshallerMappingItem(org.apache.ignite.internal.processors.marshaller.MarshallerMappingItem) MarshallerContextImpl(org.apache.ignite.internal.MarshallerContextImpl) File(java.io.File)

Example 7 with MarshallerContextImpl

use of org.apache.ignite.internal.MarshallerContextImpl 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());
}
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

MarshallerContextImpl (org.apache.ignite.internal.MarshallerContextImpl)7 MarshallerMappingItem (org.apache.ignite.internal.processors.marshaller.MarshallerMappingItem)6 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Ignite (org.apache.ignite.Ignite)2 File (java.io.File)1 Map (java.util.Map)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 IgniteKernal (org.apache.ignite.internal.IgniteKernal)1 BinaryContext (org.apache.ignite.internal.binary.BinaryContext)1 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)1 GridBinaryMarshaller (org.apache.ignite.internal.binary.GridBinaryMarshaller)1 MappedName (org.apache.ignite.internal.processors.marshaller.MappedName)1 NullLogger (org.apache.ignite.logger.NullLogger)1