use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class ClientTxnMapTest method txn_map_containsKey_skips_server_side_near_cache.
@Test
public void txn_map_containsKey_skips_server_side_near_cache() {
String mapName = "test";
int keyInServerNearCache = 1;
IMap serverMap = prepareServerAndGetServerMap(mapName, keyInServerNearCache);
TransactionalMap clientTxnMap = getClientTransactionalMap(mapName);
assertTrue(clientTxnMap.containsKey(keyInServerNearCache));
assertEquals(0, serverMap.getLocalMapStats().getNearCacheStats().getHits());
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class ClientTxnMapTest method txn_map_get_skips_server_side_near_cache.
@Test
public void txn_map_get_skips_server_side_near_cache() {
String mapName = "test";
int keyInServerNearCache = 1;
IMap serverMap = prepareServerAndGetServerMap(mapName, keyInServerNearCache);
TransactionalMap clientTxnMap = getClientTransactionalMap(mapName);
assertNotNull(clientTxnMap.get(keyInServerNearCache));
assertEquals(0, serverMap.getLocalMapStats().getNearCacheStats().getHits());
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class ClientTxnMapTest method testTnxMapDelete.
@Test
public void testTnxMapDelete() throws Exception {
final String mapName = randomString();
final String key = "key1";
final String value = "old1";
IMap map = client.getMap(mapName);
map.put(key, value);
final TransactionContext context = client.newTransactionContext();
context.beginTransaction();
final TransactionalMap txMap = context.getMap(mapName);
txMap.delete(key);
context.commitTransaction();
assertNull(map.get(key));
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class ClientTxnMapTest method testKeysetAndValuesWithPredicates.
@Test
public void testKeysetAndValuesWithPredicates() throws Exception {
final String mapName = randomString();
IMap map = client.getMap(mapName);
final SampleTestObjects.Employee emp1 = new SampleTestObjects.Employee("abc-123-xvz", 34, true, 10D);
final SampleTestObjects.Employee emp2 = new SampleTestObjects.Employee("abc-123-xvz", 20, true, 10D);
map.put(emp1, emp1);
final TransactionContext context = client.newTransactionContext();
context.beginTransaction();
final TransactionalMap txMap = context.getMap(mapName);
assertNull(txMap.put(emp2, emp2));
assertEquals(2, txMap.size());
assertEquals(2, txMap.keySet().size());
assertEquals(0, txMap.keySet(Predicates.sql("age = 10")).size());
assertEquals(0, txMap.values(Predicates.sql("age = 10")).size());
assertEquals(2, txMap.keySet(Predicates.sql("age >= 10")).size());
assertEquals(2, txMap.values(Predicates.sql("age >= 10")).size());
context.commitTransaction();
assertEquals(2, map.size());
assertEquals(2, map.values().size());
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class ClientTxnMapTest method testTnxMapPutIfAbsent.
@Test
public void testTnxMapPutIfAbsent() throws Exception {
final String mapName = randomString();
IMap map = client.getMap(mapName);
final String keyValue1 = "keyValue1";
final String keyValue2 = "keyValue2";
map.put(keyValue1, keyValue1);
final TransactionContext context = client.newTransactionContext();
context.beginTransaction();
final TransactionalMap txMap = context.getMap(mapName);
txMap.putIfAbsent(keyValue1, "NOT_THIS");
txMap.putIfAbsent(keyValue2, keyValue2);
context.commitTransaction();
assertEquals(keyValue1, map.get(keyValue1));
assertEquals(keyValue2, map.get(keyValue2));
}
Aggregations