Search in sources :

Example 26 with Marshaller

use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.

the class GridTopicExternalizableSelfTest method testSerializationTopicCreatedByGridUuidAndLong.

/**
 * @throws Exception If failed.
 */
public void testSerializationTopicCreatedByGridUuidAndLong() throws Exception {
    for (Marshaller marsh : getMarshallers()) {
        info("Test GridTopic externalization [marshaller=" + marsh + ']');
        for (GridTopic topic : GridTopic.values()) {
            Externalizable msgOut = (Externalizable) topic.topic(A_GRID_UUID, A_LONG);
            assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh));
        }
    }
}
Also used : Marshaller(org.apache.ignite.marshaller.Marshaller) Externalizable(java.io.Externalizable)

Example 27 with Marshaller

use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.

the class GridTopicExternalizableSelfTest method testSerializationTopicCreatedByStringAndUUIDAndIntAndLong.

/**
 * @throws Exception If failed.
 */
public void testSerializationTopicCreatedByStringAndUUIDAndIntAndLong() throws Exception {
    for (Marshaller marsh : getMarshallers()) {
        info("Test GridTopic externalization [marshaller=" + marsh + ']');
        for (GridTopic topic : GridTopic.values()) {
            Externalizable msgOut = (Externalizable) topic.topic(A_STRING, AN_UUID, AN_INT, A_LONG);
            assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh));
        }
    }
}
Also used : Marshaller(org.apache.ignite.marshaller.Marshaller) Externalizable(java.io.Externalizable)

Example 28 with Marshaller

use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.

the class CacheEnumOperationsAbstractTest method assertBinaryEnum.

/**
 * @param cache Cache.
 * @param key Key.
 * @param expVal Expected value.
 */
private static void assertBinaryEnum(IgniteCache<Object, Object> cache, int key, TestEnum expVal) {
    Marshaller marsh = ((IgniteCacheProxy) cache).context().marshaller();
    if (marsh instanceof BinaryMarshaller) {
        BinaryObject enumObj = (BinaryObject) cache.withKeepBinary().get(key);
        assertEquals(expVal.ordinal(), enumObj.enumOrdinal());
        assertTrue(enumObj.type().isEnum());
        assertTrue(enumObj instanceof BinaryEnumObjectImpl);
    }
}
Also used : BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) Marshaller(org.apache.ignite.marshaller.Marshaller) BinaryObject(org.apache.ignite.binary.BinaryObject) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) BinaryEnumObjectImpl(org.apache.ignite.internal.binary.BinaryEnumObjectImpl)

Example 29 with Marshaller

use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.

the class OptimizedMarshallerNodeFailoverTest method testRestartAllNodes.

/**
 * @throws Exception If failed.
 */
public void testRestartAllNodes() throws Exception {
    cache = true;
    String home = U.getIgniteHome();
    String[] workDirs = new String[3];
    for (int i = 0; i < 3; i++) {
        workDirs[i] = home + "/work/marshallerTestNode_" + i;
        File file = new File(workDirs[i]);
        if (file.exists())
            assert U.delete(file);
    }
    try {
        for (int i = 0; i < workDirs.length; i++) {
            workDir = workDirs[i];
            startGrid(i);
        }
        Marshaller marsh = ignite(0).configuration().getMarshaller();
        TestClass1 obj = new TestClass1();
        obj.val = 111;
        byte[] bytes = marsh.marshal(obj);
        stopAllGrids();
        for (int i = 0; i < workDirs.length; i++) {
            workDir = workDirs[i];
            startGrid(i);
        }
        for (int i = 0; i < 3; i++) {
            marsh = ignite(i).configuration().getMarshaller();
            TestClass1 obj0 = marsh.unmarshal(bytes, null);
            assertEquals(111, obj0.val);
        }
    } finally {
        for (String dir : workDirs) assert U.delete(new File(dir));
    }
}
Also used : Marshaller(org.apache.ignite.marshaller.Marshaller) OptimizedMarshaller(org.apache.ignite.internal.marshaller.optimized.OptimizedMarshaller) File(java.io.File)

Example 30 with Marshaller

use of org.apache.ignite.marshaller.Marshaller in project ignite by apache.

the class OptimizedMarshallerTest method testSerializableAfterChangingValue.

/**
 * @throws IgniteCheckedException If failed.
 */
public void testSerializableAfterChangingValue() throws IgniteCheckedException {
    Marshaller marsh = marshaller();
    SomeSimpleSerializable newObj = new SomeSimpleSerializable();
    assert (newObj.flag);
    newObj.setFlagValue(false);
    assert (!newObj.flag);
    SomeSimpleSerializable outObj = marsh.unmarshal(marsh.marshal(newObj), null);
    assert (!outObj.flag);
}
Also used : Marshaller(org.apache.ignite.marshaller.Marshaller)

Aggregations

Marshaller (org.apache.ignite.marshaller.Marshaller)46 Externalizable (java.io.Externalizable)8 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)8 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 HttpURLConnection (java.net.HttpURLConnection)5 URL (java.net.URL)5 URLConnection (java.net.URLConnection)5 ArrayList (java.util.ArrayList)5 HttpSession (javax.servlet.http.HttpSession)5 IgniteException (org.apache.ignite.IgniteException)5 JdkMarshaller (org.apache.ignite.marshaller.jdk.JdkMarshaller)5 Ignite (org.apache.ignite.Ignite)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)4 Server (org.eclipse.jetty.server.Server)4 File (java.io.File)2 OutputStream (java.io.OutputStream)2 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)2 IgniteClientDisconnectedCheckedException (org.apache.ignite.internal.IgniteClientDisconnectedCheckedException)2 BinaryContext (org.apache.ignite.internal.binary.BinaryContext)2 ClusterTopologyCheckedException (org.apache.ignite.internal.cluster.ClusterTopologyCheckedException)2