use of org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME in project ignite by apache.
the class ScanQueriesTopologyMappingTest method checkQueryWithNodeFilter.
/**
*/
private void checkQueryWithNodeFilter(CacheMode cacheMode) throws Exception {
IgniteEx ign0 = startGrid(0);
String name0 = ign0.name();
IgniteCache<Object, Object> cache0 = ign0.createCache(new CacheConfiguration<>(GridAbstractTest.DEFAULT_CACHE_NAME).setCacheMode(cacheMode).setNodeFilter(node -> name0.equals(node.attribute(ATTR_IGNITE_INSTANCE_NAME))));
cache0.put(1, 2);
startGrid(1);
client = true;
startGrid(10);
int part = ign0.affinity(DEFAULT_CACHE_NAME).partition(1);
for (int i = 0; i < 100; i++) {
for (Ignite ign : G.allGrids()) {
IgniteCache<Object, Object> cache = ign.cache(GridAbstractTest.DEFAULT_CACHE_NAME);
List<Cache.Entry<Object, Object>> res = cache.query(new ScanQuery<>()).getAll();
assertEquals(1, res.size());
assertEquals(1, res.get(0).getKey());
assertEquals(2, res.get(0).getValue());
res = new ArrayList<>();
for (Cache.Entry<Object, Object> entry : cache) {
res.add(entry);
}
assertEquals(1, res.size());
assertEquals(1, res.get(0).getKey());
assertEquals(2, res.get(0).getValue());
res = cache.query(new ScanQuery<>(part)).getAll();
assertEquals(1, res.size());
assertEquals(1, res.get(0).getKey());
assertEquals(2, res.get(0).getValue());
}
ScanQuery<Object, Object> qry = new ScanQuery<>().setLocal(true);
{
List<Cache.Entry<Object, Object>> res0 = grid(0).cache(GridAbstractTest.DEFAULT_CACHE_NAME).query(qry).getAll();
assertEquals(1, res0.size());
assertEquals(1, res0.get(0).getKey());
assertEquals(2, res0.get(0).getValue());
}
{
List<Cache.Entry<Object, Object>> res1 = grid(1).cache(GridAbstractTest.DEFAULT_CACHE_NAME).query(qry).getAll();
assertTrue(res1.isEmpty());
}
{
List<Cache.Entry<Object, Object>> res1 = grid(10).cache(GridAbstractTest.DEFAULT_CACHE_NAME).query(qry).getAll();
assertTrue(res1.isEmpty());
}
}
}
Aggregations