use of com.hazelcast.internal.serialization.impl.portable.NamedPortable in project hazelcast by hazelcast.
the class ClientMapTest method testPredicateListenerWithPortableKey.
@Test
public void testPredicateListenerWithPortableKey() throws Exception {
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());
}
use of com.hazelcast.internal.serialization.impl.portable.NamedPortable in project hazelcast by hazelcast.
the class AbstractGenericRecordIntegrationTest method testCloneWithGenericBuilderOnEntryProcessor.
@Test
public void testCloneWithGenericBuilderOnEntryProcessor() {
HazelcastInstance[] instances = createCluster();
HazelcastInstance instance = createAccessorInstance(serializationConfig);
IMap<Object, Object> map = instance.getMap("test");
NamedPortable expected = new NamedPortable("foo", 900);
String key = generateKeyOwnedBy(instances[0]);
map.put(key, expected);
Object returnValue = map.executeOnKey(key, (EntryProcessor<Object, Object, Object>) entry -> {
Object value = entry.getValue();
GenericRecord genericRecord = (GenericRecord) value;
GenericRecord modifiedGenericRecord = genericRecord.cloneWithBuilder().setInt32("myint", 4).build();
entry.setValue(modifiedGenericRecord);
return genericRecord.getInt32("myint");
});
assertEquals(expected.myint, returnValue);
NamedPortable actualPortable = (NamedPortable) map.get(key);
assertEquals("foo", actualPortable.name);
assertEquals(4, actualPortable.myint);
}
use of com.hazelcast.internal.serialization.impl.portable.NamedPortable in project hazelcast by hazelcast.
the class AbstractGenericRecordIntegrationTest method testPutGenericRecordBack.
@Test
public void testPutGenericRecordBack() {
HazelcastInstance[] instances = createCluster();
HazelcastInstance instance = createAccessorInstance(serializationConfig);
IMap<Object, Object> map = instance.getMap("test");
NamedPortable expected = new NamedPortable("foo", 900);
map.put(1, expected);
IMap<Object, Object> clusterMap = instances[0].getMap("test");
GenericRecord record = (GenericRecord) clusterMap.get(1);
clusterMap.put(2, record);
// read from the cluster without serialization config
GenericRecord actualRecord = (GenericRecord) clusterMap.get(2);
assertTrue(actualRecord.hasField("name"));
assertTrue(actualRecord.hasField("myint"));
assertEquals(expected.name, actualRecord.getString("name"));
assertEquals(expected.myint, actualRecord.getInt32("myint"));
// read from the instance with serialization config
NamedPortable actualPortable = (NamedPortable) map.get(2);
assertEquals(expected, actualPortable);
}
use of com.hazelcast.internal.serialization.impl.portable.NamedPortable in project hazelcast by hazelcast.
the class AbstractGenericRecordIntegrationTest method testGenericRecordIsReturnedInRemoteLogic.
@Test
public void testGenericRecordIsReturnedInRemoteLogic() throws Exception {
HazelcastInstance[] instances = createCluster();
HazelcastInstance instance = createAccessorInstance(serializationConfig);
IExecutorService service = instance.getExecutorService("test");
IMap<Object, Object> map = instance.getMap("test");
NamedPortable expected = new NamedPortable("foo", 900);
map.put(1, expected);
Future<Integer> actual = service.submitToMember(new GetInt(), instances[0].getCluster().getLocalMember());
assertEquals(expected.myint, actual.get().intValue());
}
Aggregations