Search in sources :

Example 6 with BinarySerializer

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

the class GridCacheBinaryObjectUserClassloaderSelfTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(disco);
    cfg.setCacheConfiguration(cacheConfiguration(igniteInstanceName));
    cfg.setMarshaller(new BinaryMarshaller());
    cfg.setClassLoader(useWrappingLoader ? new WrappingClassLoader(getExternalClassLoader()) : getExternalClassLoader());
    if (customBinaryConf) {
        BinarySerializer bs = new BinarySerializer() {

            /** {@inheritDoc} */
            @Override
            public void writeBinary(Object obj, BinaryWriter writer) throws BinaryObjectException {
            //No-op.
            }

            /** {@inheritDoc} */
            @Override
            public void readBinary(Object obj, BinaryReader reader) throws BinaryObjectException {
                deserialized = true;
            }
        };
        BinaryTypeConfiguration btcfg1 = new BinaryTypeConfiguration();
        btcfg1.setTypeName("org.apache.ignite.tests.p2p.CacheDeploymentTestValue");
        btcfg1.setSerializer(bs);
        BinaryTypeConfiguration btcfg2 = new BinaryTypeConfiguration();
        btcfg2.setTypeName("org.apache.ignite.internal.processors.cache.binary." + "GridCacheBinaryObjectUserClassloaderSelfTest$TestValue1");
        btcfg2.setSerializer(bs);
        BinaryConfiguration bcfg = new BinaryConfiguration();
        Set<BinaryTypeConfiguration> set = new HashSet<>();
        set.add(btcfg1);
        set.add(btcfg2);
        bcfg.setTypeConfigurations(set);
        cfg.setBinaryConfiguration(bcfg);
    }
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) BinaryWriter(org.apache.ignite.binary.BinaryWriter) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) BinaryReader(org.apache.ignite.binary.BinaryReader) BinarySerializer(org.apache.ignite.binary.BinarySerializer) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) HashSet(java.util.HashSet)

Aggregations

BinarySerializer (org.apache.ignite.binary.BinarySerializer)6 BinaryObjectException (org.apache.ignite.binary.BinaryObjectException)4 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 BinaryReader (org.apache.ignite.binary.BinaryReader)2 BinaryWriter (org.apache.ignite.binary.BinaryWriter)2 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 BinaryBasicIdMapper (org.apache.ignite.binary.BinaryBasicIdMapper)1 BinaryIdMapper (org.apache.ignite.binary.BinaryIdMapper)1 BinaryNameMapper (org.apache.ignite.binary.BinaryNameMapper)1 BinaryReflectiveSerializer (org.apache.ignite.binary.BinaryReflectiveSerializer)1 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)1