use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class GridCacheHashMapPutAllWarningsTest method testHashMapPutAllExplicitOptimistic.
/**
* @throws Exception If failed.
*/
@Test
public void testHashMapPutAllExplicitOptimistic() throws Exception {
if (MvccFeatureChecker.forcedMvcc())
return;
List<String> messages = Collections.synchronizedList(new ArrayList<>());
testLog = new ListeningTestLogger(false, log());
testLog.registerListener((s) -> {
if (s.contains("deadlock"))
messages.add(s);
});
Ignite ignite = startGrid(0);
IgniteCache<Integer, String> c = ignite.getOrCreateCache(new CacheConfiguration<Integer, String>("explicitTx").setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
ignite.transactions().txStart(TransactionConcurrency.OPTIMISTIC, TransactionIsolation.SERIALIZABLE);
HashMap<Integer, String> m = new HashMap<>();
m.put(1, "foo");
m.put(2, "bar");
c.putAllAsync(m);
ignite.transactions().tx().commit();
assertEquals(2, c.size());
for (String message : messages) {
assertFalse(message.contains("Unordered map"));
assertFalse(message.contains("operation on cache"));
}
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class GridCacheHashMapPutAllWarningsTest method testHashSetGetAllReplicated.
/**
* @throws Exception If failed.
*/
@Test
public void testHashSetGetAllReplicated() throws Exception {
List<String> messages = Collections.synchronizedList(new ArrayList<>());
testLog = new ListeningTestLogger(false, log());
testLog.registerListener((s) -> {
if (s.contains("deadlock"))
messages.add(s);
});
Ignite ignite = startGrid(0);
IgniteCache<Integer, String> c = ignite.getOrCreateCache(new CacheConfiguration<Integer, String>("get").setCacheMode(CacheMode.REPLICATED));
c.put(1, "foo");
c.put(2, "bar");
assertEquals(1, c.getAll(new HashSet<>(Arrays.asList(1, 3))).size());
int found = 0;
for (String message : messages) {
if (message.contains("Unordered collection "))
found++;
if (message.contains("operation on cache"))
found++;
}
assertEquals(0, found);
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class GridCacheHashMapPutAllWarningsTest method testTreeMapRemoveAll.
/**
* @throws Exception If failed.
*/
@Test
public void testTreeMapRemoveAll() throws Exception {
List<String> messages = Collections.synchronizedList(new ArrayList<>());
testLog = new ListeningTestLogger(false, log());
testLog.registerListener((s) -> {
if (s.contains("deadlock"))
messages.add(s);
});
Ignite ignite = startGrid(0);
IgniteCache<Integer, String> c = ignite.getOrCreateCache(new CacheConfiguration<Integer, String>("remove").setCacheMode(CacheMode.PARTITIONED));
c.put(1, "foo");
c.put(2, "bar");
c.removeAll(new TreeSet<>(Arrays.asList(1, 3)));
assertEquals(1, c.size());
int found = 0;
for (String message : messages) {
if (message.contains("Unordered collection "))
found++;
if (message.contains("operation on cache"))
found++;
}
assertEquals(0, found);
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class GridCacheHashMapPutAllWarningsTest method testTreeMapRemoveAllEntries.
/**
* @throws Exception If failed.
*/
@Test
public void testTreeMapRemoveAllEntries() throws Exception {
List<String> messages = Collections.synchronizedList(new ArrayList<>());
testLog = new ListeningTestLogger(false, log());
testLog.registerListener((s) -> {
if (s.contains("deadlock"))
messages.add(s);
});
Ignite ignite = startGrid(0);
startGrid(1);
IgniteCache<Integer, String> c = ignite.getOrCreateCache(new CacheConfiguration<Integer, String>("entries").setCacheMode(CacheMode.REPLICATED).setAtomicityMode(CacheAtomicityMode.ATOMIC).setBackups(1));
for (int i = 0; i < 1000; i++) {
c.put(i, "foo");
c.put(i * 2, "bar");
}
c.removeAll();
assertEquals(0, c.size());
for (String message : messages) {
assertFalse(message.contains("Unordered collection "));
assertFalse(message.contains("operation on cache"));
}
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class GridCacheHashMapPutAllWarningsTest method testHashMapAtomic.
/**
* @throws Exception If failed.
*/
@Test
public void testHashMapAtomic() throws Exception {
List<String> messages = Collections.synchronizedList(new ArrayList<>());
testLog = new ListeningTestLogger(log());
testLog.registerListener((s) -> {
if (s.contains("deadlock"))
messages.add(s);
});
Ignite ignite = startGrid(0);
IgniteCache<Integer, String> c = ignite.getOrCreateCache(new CacheConfiguration<Integer, String>("atomic").setAtomicityMode(CacheAtomicityMode.ATOMIC));
HashMap<Integer, String> m = new HashMap<>();
m.put(1, "foo");
m.put(2, "bar");
c.putAll(m);
c.invokeAll(m.keySet(), (k, v) -> v);
c.removeAll(m.keySet());
c.removeAll();
assertEquals(0, c.size());
for (String message : messages) {
assertFalse(message.contains("Unordered "));
assertFalse(message.contains("operation on cache"));
}
}
Aggregations