Search in sources :

Example 1 with BinaryReflectiveSerializer

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

the class BinaryContext method registerPredefinedType.

/**
     * @param cls Class.
     * @param id Type ID.
     * @param affFieldName Affinity field name.
     * @return GridBinaryClassDescriptor.
     */
public BinaryClassDescriptor registerPredefinedType(Class<?> cls, int id, String affFieldName, boolean registered) {
    String simpleClsName = SIMPLE_NAME_LOWER_CASE_MAPPER.typeName(cls.getName());
    if (id == 0)
        id = SIMPLE_NAME_LOWER_CASE_MAPPER.typeId(simpleClsName);
    BinaryClassDescriptor desc = new BinaryClassDescriptor(this, cls, false, id, simpleClsName, affFieldName, SIMPLE_NAME_LOWER_CASE_MAPPER, new BinaryReflectiveSerializer(), false, registered);
    predefinedTypeNames.put(simpleClsName, id);
    predefinedTypes.put(id, desc);
    descByCls.put(cls, desc);
    if (affFieldName != null)
        affKeyFieldNames.putIfAbsent(id, affFieldName);
    return desc;
}
Also used : BinaryReflectiveSerializer(org.apache.ignite.binary.BinaryReflectiveSerializer)

Example 2 with BinaryReflectiveSerializer

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

the class BinaryContext method registerClassDescriptor.

/**
     * Creates and registers {@link BinaryClassDescriptor} for the given {@code class}.
     *
     * @param cls Class.
     * @return Class descriptor.
     */
private BinaryClassDescriptor registerClassDescriptor(Class<?> cls, boolean deserialize) {
    BinaryClassDescriptor desc;
    String clsName = cls.getName();
    if (marshCtx.isSystemType(clsName)) {
        BinarySerializer serializer = null;
        if (BINARYLIZABLE_SYS_CLSS.contains(clsName))
            serializer = new BinaryReflectiveSerializer();
        desc = new BinaryClassDescriptor(this, cls, false, clsName.hashCode(), clsName, null, SIMPLE_NAME_LOWER_CASE_MAPPER, serializer, false, true);
        BinaryClassDescriptor old = descByCls.putIfAbsent(cls, desc);
        if (old != null)
            desc = old;
    } else
        desc = registerUserClassDescriptor(cls, deserialize);
    return desc;
}
Also used : BinaryReflectiveSerializer(org.apache.ignite.binary.BinaryReflectiveSerializer) BinarySerializer(org.apache.ignite.binary.BinarySerializer)

Example 3 with BinaryReflectiveSerializer

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

the class BinarySerializationQuerySelfTest method beforeTest.

/** {@inheritDoc} */
@Override
protected void beforeTest() throws Exception {
    IgniteConfiguration cfg = new IgniteConfiguration();
    cfg.setLocalHost("127.0.0.1");
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
    cfg.setDiscoverySpi(discoSpi);
    cfg.setMarshaller(new BinaryMarshaller());
    if (useReflectiveSerializer()) {
        BinaryTypeConfiguration binTypCfg1 = new BinaryTypeConfiguration(EntityPlain.class.getName());
        BinaryTypeConfiguration binTypCfg2 = new BinaryTypeConfiguration(EntitySerializable.class.getName());
        BinaryTypeConfiguration binTypCfg3 = new BinaryTypeConfiguration(EntityExternalizable.class.getName());
        BinaryTypeConfiguration binTypCfg4 = new BinaryTypeConfiguration(EntityBinarylizable.class.getName());
        BinaryTypeConfiguration binTypCfg5 = new BinaryTypeConfiguration(EntityWriteReadObject.class.getName());
        binTypCfg1.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg2.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg3.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg4.setSerializer(new BinaryReflectiveSerializer());
        binTypCfg5.setSerializer(new BinaryReflectiveSerializer());
        List<BinaryTypeConfiguration> binTypCfgs = new ArrayList<>();
        binTypCfgs.add(binTypCfg1);
        binTypCfgs.add(binTypCfg2);
        binTypCfgs.add(binTypCfg3);
        binTypCfgs.add(binTypCfg4);
        binTypCfgs.add(binTypCfg5);
        BinaryConfiguration binCfg = new BinaryConfiguration();
        binCfg.setTypeConfigurations(binTypCfgs);
        cfg.setBinaryConfiguration(binCfg);
    }
    CacheConfiguration cacheCfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    cacheCfg.setCacheMode(CacheMode.PARTITIONED);
    cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
    cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
    cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
    List<QueryEntity> queryEntities = new ArrayList<>();
    queryEntities.add(entityForClass(EntityPlain.class));
    queryEntities.add(entityForClass(EntitySerializable.class));
    queryEntities.add(entityForClass(EntityExternalizable.class));
    queryEntities.add(entityForClass(EntityBinarylizable.class));
    queryEntities.add(entityForClass(EntityWriteReadObject.class));
    cacheCfg.setQueryEntities(queryEntities);
    cfg.setCacheConfiguration(cacheCfg);
    ignite = Ignition.start(cfg);
    cache = ignite.cache(DEFAULT_CACHE_NAME);
}
Also used : BinaryReflectiveSerializer(org.apache.ignite.binary.BinaryReflectiveSerializer) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) ArrayList(java.util.ArrayList) QueryEntity(org.apache.ignite.cache.QueryEntity) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

BinaryReflectiveSerializer (org.apache.ignite.binary.BinaryReflectiveSerializer)3 ArrayList (java.util.ArrayList)1 BinarySerializer (org.apache.ignite.binary.BinarySerializer)1 BinaryTypeConfiguration (org.apache.ignite.binary.BinaryTypeConfiguration)1 QueryEntity (org.apache.ignite.cache.QueryEntity)1 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)1 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)1 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)1