Search in sources :

Example 1 with NamedPortable

use of com.hazelcast.nio.serialization.NamedPortable in project hazelcast by hazelcast.

the class ClientMapTest method testPredicateListenerWithPortableKey.

@Test
@SuppressWarnings("deprecation")
public void testPredicateListenerWithPortableKey() throws InterruptedException {
    IMap<Portable, Integer> tradeMap = createMap();
    final AtomicInteger atomicInteger = new AtomicInteger(0);
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    EntryListener listener = new EntryAdapter() {

        @Override
        public void entryAdded(EntryEvent event) {
            atomicInteger.incrementAndGet();
            countDownLatch.countDown();
        }
    };
    NamedPortable key = new NamedPortable("a", 1);
    tradeMap.addEntryListener(listener, key, true);
    NamedPortable key2 = new NamedPortable("b", 2);
    tradeMap.put(key2, 1);
    assertFalse(countDownLatch.await(5, TimeUnit.SECONDS));
    assertEquals(0, atomicInteger.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Portable(com.hazelcast.nio.serialization.Portable) NamedPortable(com.hazelcast.nio.serialization.NamedPortable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) EntryAdapter(com.hazelcast.core.EntryAdapter) EntryEvent(com.hazelcast.core.EntryEvent) CountDownLatch(java.util.concurrent.CountDownLatch) EntryListener(com.hazelcast.core.EntryListener) NamedPortable(com.hazelcast.nio.serialization.NamedPortable) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with NamedPortable

use of com.hazelcast.nio.serialization.NamedPortable in project hazelcast by hazelcast.

the class ClientMapTest method setup.

@Before
public void setup() {
    Config config = getConfig();
    config.getMapConfig("flushMap").setMapStoreConfig(new MapStoreConfig().setWriteDelaySeconds(1000).setImplementation(flushMapStore));
    config.getMapConfig("putTransientMap").setMapStoreConfig(new MapStoreConfig().setWriteDelaySeconds(1000).setImplementation(transientMapStore));
    server = hazelcastFactory.newHazelcastInstance(config);
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.getSerializationConfig().addPortableFactory(TestSerializationConstants.PORTABLE_FACTORY_ID, new PortableFactory() {

        public Portable create(int classId) {
            return new NamedPortable();
        }
    });
    client = hazelcastFactory.newHazelcastClient(clientConfig);
}
Also used : Portable(com.hazelcast.nio.serialization.Portable) NamedPortable(com.hazelcast.nio.serialization.NamedPortable) MapStoreConfig(com.hazelcast.config.MapStoreConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) Config(com.hazelcast.config.Config) MapStoreConfig(com.hazelcast.config.MapStoreConfig) ClientConfig(com.hazelcast.client.config.ClientConfig) PortableFactory(com.hazelcast.nio.serialization.PortableFactory) NamedPortable(com.hazelcast.nio.serialization.NamedPortable) Before(org.junit.Before)

Aggregations

NamedPortable (com.hazelcast.nio.serialization.NamedPortable)2 Portable (com.hazelcast.nio.serialization.Portable)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 Config (com.hazelcast.config.Config)1 MapStoreConfig (com.hazelcast.config.MapStoreConfig)1 EntryAdapter (com.hazelcast.core.EntryAdapter)1 EntryEvent (com.hazelcast.core.EntryEvent)1 EntryListener (com.hazelcast.core.EntryListener)1 PortableFactory (com.hazelcast.nio.serialization.PortableFactory)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Before (org.junit.Before)1 Test (org.junit.Test)1