Search in sources :

Example 1 with TestPortableFactory

use of com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.TestPortableFactory in project hazelcast by hazelcast.

the class DefaultPortableReaderSpecTest method reader.

//
// Hazelcast init Utilities
//
public PortableReader reader(Portable portable) throws IOException {
    Config config = new Config();
    config.getSerializationConfig().addPortableFactory(TestPortableFactory.ID, new TestPortableFactory());
    HazelcastInstanceProxy hz = (HazelcastInstanceProxy) createHazelcastInstance(config);
    IMap<String, Object> map = hz.getMap("stealingMap");
    // avoid the case where there's no class definition
    if (portable instanceof PrimitivePortable) {
        map.put(P_NON_EMPTY.toString(), P_NON_EMPTY);
    }
    if (portable instanceof GroupPortable) {
        map.put(G_NON_EMPTY.toString(), G_NON_EMPTY);
    }
    if (portable instanceof NestedGroupPortable) {
        map.put(N_NON_EMPTY.toString(), N_NON_EMPTY);
    }
    map.put(portable.toString(), portable);
    EntryStealingProcessor processor = new EntryStealingProcessor(portable.toString());
    map.executeOnEntries(processor);
    SerializationServiceV1 ss = (SerializationServiceV1) hz.getSerializationService();
    return ss.createPortableReader(processor.stolenEntryData);
}
Also used : TestPortableFactory(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.TestPortableFactory) Config(com.hazelcast.config.Config) PrimitivePortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.PrimitivePortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable) SerializationServiceV1(com.hazelcast.internal.serialization.impl.SerializationServiceV1) HazelcastInstanceProxy(com.hazelcast.instance.HazelcastInstanceProxy) GroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable) NestedGroupPortable(com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable)

Aggregations

Config (com.hazelcast.config.Config)1 HazelcastInstanceProxy (com.hazelcast.instance.HazelcastInstanceProxy)1 SerializationServiceV1 (com.hazelcast.internal.serialization.impl.SerializationServiceV1)1 GroupPortable (com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.GroupPortable)1 NestedGroupPortable (com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.NestedGroupPortable)1 PrimitivePortable (com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.PrimitivePortable)1 TestPortableFactory (com.hazelcast.nio.serialization.impl.DefaultPortableReaderTestStructure.TestPortableFactory)1