use of com.hazelcast.core.EntryListener in project hazelcast by hazelcast.
the class MapPreconditionsTest method testAddEntryListenerWithEntryListenerAndKey_NullKey.
@Test(expected = NullPointerException.class)
public void testAddEntryListenerWithEntryListenerAndKey_NullKey() throws Exception {
EntryListener entryListener = new TestEntryListener();
map.addEntryListener(entryListener, null, false);
}
use of com.hazelcast.core.EntryListener in project hazelcast by hazelcast.
the class AllTest method loadMapOperations.
private List<Runnable> loadMapOperations() {
ArrayList<Runnable> operations = new ArrayList<Runnable>();
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.evict(random.nextInt(SIZE));
}
}, 5);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
try {
map.getAsync(random.nextInt(SIZE)).get();
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
}
}, 1);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.containsKey(random.nextInt(SIZE));
}
}, 2);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.containsValue(new Customer(random.nextInt(100), String.valueOf(random.nextInt(100000))));
}
}, 2);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
int key = random.nextInt(SIZE);
map.lock(key);
try {
Thread.sleep(1);
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
map.unlock(key);
}
}
}, 1);
// addOperation(operations, new Runnable() {
// public void run() {
// IMap map = hazelcast.getMap("myMap");
// int key = random.nextInt(SIZE);
// map.lockMap(10, TimeUnit.MILLISECONDS);
// try {
// Thread.sleep(1);
// } catch (InterruptedException e) {
// } finally {
// map.unlockMap();
// }
// }
// }, 1);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
int key = random.nextInt(SIZE);
boolean locked = map.tryLock(key);
if (locked) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
map.unlock(key);
}
}
}
}, 1);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
int key = random.nextInt(SIZE);
boolean locked = false;
try {
locked = map.tryLock(key, 10, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if (locked) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
map.unlock(key);
}
}
}
}, 1);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
Iterator it = map.entrySet().iterator();
for (int i = 0; i < 10 && it.hasNext(); i++) {
it.next();
}
}
}, 1);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.getEntryView(random.nextInt(SIZE));
}
}, 2);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.isEmpty();
}
}, 3);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.put(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000))));
}
}, 50);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.tryPut(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000))), 10, TimeUnit.MILLISECONDS);
}
}, 5);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
try {
map.putAsync(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000)))).get();
} catch (InterruptedException e) {
throw new RuntimeException(e);
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
}
}, 5);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.put(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000))), 10, TimeUnit.MILLISECONDS);
}
}, 5);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.putIfAbsent(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000))), 10, TimeUnit.MILLISECONDS);
}
}, 5);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.putIfAbsent(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000))));
}
}, 5);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
Map localMap = new HashMap();
for (int i = 0; i < 10; i++) {
localMap.put(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000))));
}
map.putAll(localMap);
}
}, 1);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.get(random.nextInt(SIZE));
}
}, 100);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.remove(random.nextInt(SIZE));
}
}, 10);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.tryRemove(random.nextInt(SIZE), 10, TimeUnit.MILLISECONDS);
}
}, 10);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.removeAsync(random.nextInt(SIZE));
}
}, 10);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.remove(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000))));
}
}, 10);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.replace(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000))));
}
}, 4);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.replace(random.nextInt(SIZE), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000))), new Customer(random.nextInt(100), String.valueOf(random.nextInt(10000))));
}
}, 5);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.size();
}
}, 4);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
Iterator it = map.entrySet(new SqlPredicate("year=" + random.nextInt(100))).iterator();
while (it.hasNext()) {
it.next();
}
}
}, 1);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
Iterator it = map.entrySet(new SqlPredicate("name=" + random.nextInt(10000))).iterator();
while (it.hasNext()) {
it.next();
}
}
}, 10);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
Iterator it = map.keySet(new SqlPredicate("name=" + random.nextInt(10000))).iterator();
while (it.hasNext()) {
it.next();
}
}
}, 10);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
Iterator it = map.localKeySet().iterator();
while (it.hasNext()) {
it.next();
}
}
}, 10);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
Iterator it = map.localKeySet(new SqlPredicate("name=" + random.nextInt(10000))).iterator();
while (it.hasNext()) {
it.next();
}
}
}, 10);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
final CountDownLatch latch = new CountDownLatch(1);
EntryListener listener = new EntryAdapter() {
@Override
public void onEntryEvent(EntryEvent event) {
latch.countDown();
}
};
String id = map.addEntryListener(listener, true);
try {
latch.await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
map.removeEntryListener(id);
}
}, 1);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
map.addIndex("year", true);
}
}, 1);
addOperation(operations, new Runnable() {
public void run() {
IMap map = hazelcast.getMap("myMap");
final CountDownLatch latch = new CountDownLatch(1);
EntryListener listener = new EntryAdapter() {
@Override
public void onEntryEvent(EntryEvent event) {
latch.countDown();
}
};
String id = map.addLocalEntryListener(listener);
try {
latch.await();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
map.removeEntryListener(id);
}
}, 1);
return operations;
}
use of com.hazelcast.core.EntryListener in project hazelcast by hazelcast.
the class MapPreconditionsTest method testAddEntryListenerWithEntryListenerAndKey_NullListener.
@Test(expected = NullPointerException.class)
public void testAddEntryListenerWithEntryListenerAndKey_NullListener() {
EntryListener entryListener = null;
Integer i = 3;
map.addEntryListener(entryListener, i, false);
}
use of com.hazelcast.core.EntryListener in project hazelcast by hazelcast.
the class MapPreconditionsTest method testAddEntryListenerWithEntryListenerAndPredicate_NullListener.
@Test(expected = NullPointerException.class)
public void testAddEntryListenerWithEntryListenerAndPredicate_NullListener() {
EntryListener entryListener = null;
Predicate predicate = new TruePredicate();
map.addEntryListener(entryListener, predicate, false);
}
use of com.hazelcast.core.EntryListener in project hazelcast by hazelcast.
the class MapPreconditionsTest method testAddEntryListenerWithEntryListenerAndKey_NullKey.
@Test(expected = NullPointerException.class)
public void testAddEntryListenerWithEntryListenerAndKey_NullKey() {
EntryListener entryListener = new TestEntryListener();
map.addEntryListener(entryListener, null, false);
}
Aggregations