Search in sources :

Example 6 with Marshaller

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

the class OptimizedMarshallerTest method testExternalizable.

/**
 * Tests ability to marshal externalizable objects.
 *
 * @throws IgniteCheckedException If marshalling failed.
 */
public void testExternalizable() throws IgniteCheckedException {
    Marshaller marsh = marshaller();
    ExternalizableA outObj = marsh.unmarshal(marsh.marshal(new ExternalizableA(null, true)), null);
    ExternalizableA outObj1 = marsh.unmarshal(marsh.marshal(new ExternalizableA(null, false)), null);
    assertNotNull(outObj);
    assertNotNull(outObj1);
}
Also used : Marshaller(org.apache.ignite.marshaller.Marshaller)

Example 7 with Marshaller

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

the class GridCacheEntryMemorySizeSelfTest method beforeTestsStarted.

/**
 * {@inheritDoc}
 */
@Override
protected void beforeTestsStarted() throws Exception {
    try {
        ENTRY_OVERHEAD = U.<Integer>staticField(GridCacheMapEntry.class, "SIZE_OVERHEAD");
        DHT_ENTRY_OVERHEAD = U.<Integer>staticField(GridDhtCacheEntry.class, "DHT_SIZE_OVERHEAD");
        NEAR_ENTRY_OVERHEAD = U.<Integer>staticField(GridNearCacheEntry.class, "NEAR_SIZE_OVERHEAD");
        REPLICATED_ENTRY_OVERHEAD = DHT_ENTRY_OVERHEAD;
        Marshaller marsh = createMarshaller();
        KEY_SIZE = marsh.marshal(1).length;
        ONE_KB_VAL_SIZE = marsh.marshal(new Value(new byte[1024])).length;
        TWO_KB_VAL_SIZE = marsh.marshal(new Value(new byte[2048])).length;
    } catch (IgniteCheckedException e) {
        throw new IgniteException(e);
    }
    startGrids(2);
}
Also used : GridNearCacheEntry(org.apache.ignite.internal.processors.cache.distributed.near.GridNearCacheEntry) JdkMarshaller(org.apache.ignite.marshaller.jdk.JdkMarshaller) Marshaller(org.apache.ignite.marshaller.Marshaller) GridDhtCacheEntry(org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException)

Example 8 with Marshaller

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

the class GridCacheEntryMemorySizeSelfTest method createMarshaller.

/**
 * Creates an instance of Marshaller that is used by caches during the test run.
 *
 * @return Marshaller.
 */
protected Marshaller createMarshaller() throws IgniteCheckedException {
    Marshaller marsh = createStandaloneBinaryMarshaller();
    marsh.setContext(new MarshallerContext() {

        @Override
        public boolean registerClassName(byte platformId, int typeId, String clsName) {
            return true;
        }

        @Override
        public boolean registerClassNameLocally(byte platformId, int typeId, String clsName) {
            return true;
        }

        @Override
        public Class getClass(int typeId, ClassLoader ldr) {
            throw new UnsupportedOperationException();
        }

        @Override
        public String getClassName(byte platformId, int typeId) {
            throw new UnsupportedOperationException();
        }

        @Override
        public boolean isSystemType(String typeName) {
            return false;
        }

        @Override
        public IgnitePredicate<String> classNameFilter() {
            return null;
        }

        @Override
        public JdkMarshaller jdkMarshaller() {
            return new JdkMarshaller();
        }
    });
    return marsh;
}
Also used : JdkMarshaller(org.apache.ignite.marshaller.jdk.JdkMarshaller) Marshaller(org.apache.ignite.marshaller.Marshaller) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) JdkMarshaller(org.apache.ignite.marshaller.jdk.JdkMarshaller) MarshallerContext(org.apache.ignite.marshaller.MarshallerContext)

Example 9 with Marshaller

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

the class StandaloneGridKernalContext method prepareIgniteConfiguration.

/**
 * @return Ignite configuration which allows to start requied processors for WAL reader
 */
private IgniteConfiguration prepareIgniteConfiguration() {
    IgniteConfiguration cfg = new IgniteConfiguration();
    cfg.setDiscoverySpi(new StandaloneNoopDiscoverySpi());
    cfg.setCommunicationSpi(new StandaloneNoopCommunicationSpi());
    final Marshaller marshaller = new BinaryMarshaller();
    cfg.setMarshaller(marshaller);
    final DataStorageConfiguration pstCfg = new DataStorageConfiguration();
    final DataRegionConfiguration regCfg = new DataRegionConfiguration();
    regCfg.setPersistenceEnabled(true);
    pstCfg.setDefaultDataRegionConfiguration(regCfg);
    cfg.setDataStorageConfiguration(pstCfg);
    marshaller.setContext(marshallerCtx);
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) Marshaller(org.apache.ignite.marshaller.Marshaller) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller)

Example 10 with Marshaller

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

the class GridTopicExternalizableSelfTest method testSerializationTopicCreatedByStringAndIntAndLong.

/**
 * @throws Exception If failed.
 */
public void testSerializationTopicCreatedByStringAndIntAndLong() 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_INT, A_LONG);
            assertEquals(msgOut, GridTestIoUtils.externalize(msgOut, marsh));
        }
    }
}
Also used : Marshaller(org.apache.ignite.marshaller.Marshaller) Externalizable(java.io.Externalizable)

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