use of org.apache.ignite.cache.CacheMode in project ignite by apache.
the class GridCacheQueryAdapter method nodes.
/**
* @return Nodes to execute on.
*/
private Collection<ClusterNode> nodes() throws IgniteCheckedException {
CacheMode cacheMode = cctx.config().getCacheMode();
Integer part = partition();
switch(cacheMode) {
case LOCAL:
if (prj != null)
U.warn(log, "Ignoring query projection because it's executed over LOCAL cache " + "(only local node will be queried): " + this);
if (type == SCAN && cctx.config().getCacheMode() == LOCAL && part != null && part >= cctx.affinity().partitions())
throw new IgniteCheckedException("Invalid partition number: " + part);
return Collections.singletonList(cctx.localNode());
case REPLICATED:
if (prj != null || part != null)
return nodes(cctx, prj, part);
GridDhtPartitionTopology topology = cctx.topology();
if (cctx.affinityNode() && !topology.localPartitionMap().hasMovingPartitions())
return Collections.singletonList(cctx.localNode());
topology.readLock();
try {
Collection<ClusterNode> affNodes = nodes(cctx, null, null);
List<ClusterNode> nodes = new ArrayList<>(affNodes);
Collections.shuffle(nodes);
for (ClusterNode node : nodes) {
if (!topology.partitions(node.id()).hasMovingPartitions())
return Collections.singletonList(node);
}
return affNodes;
} finally {
topology.readUnlock();
}
case PARTITIONED:
return nodes(cctx, prj, part);
default:
throw new IllegalStateException("Unknown cache distribution mode: " + cacheMode);
}
}
use of org.apache.ignite.cache.CacheMode in project ignite by apache.
the class IgniteDataStructuresTestUtils method getCollectionConfigurations.
/**
* @return All variations of configurations according to atomicity mode, backups, cache mode and collocation flag.
*/
public static Map<String, CollectionConfiguration> getCollectionConfigurations() {
Map<String, CollectionConfiguration> configs = new HashMap<>();
for (boolean collocated : Arrays.asList(true, false)) {
for (CacheAtomicityMode atomicityMode : Arrays.asList(TRANSACTIONAL, ATOMIC)) {
for (int backups : Arrays.asList(0, 1)) {
for (CacheMode cacheMode : CacheMode.values()) {
if (cacheMode == CacheMode.LOCAL) {
// TODO: https://issues.apache.org/jira/browse/IGNITE-13076
continue;
}
CollectionConfiguration cfg = new CollectionConfiguration().setCollocated(collocated).setAtomicityMode(atomicityMode).setBackups(backups).setCacheMode(cacheMode).setGroupName(cacheMode + "-grp-" + backups);
CollectionConfiguration old = configs.put("" + collocated + atomicityMode + backups + cacheMode, cfg);
assert old == null : old;
}
}
}
}
return configs;
}
use of org.apache.ignite.cache.CacheMode in project ignite by apache.
the class JettyRestProcessorAbstractSelfTest method testTopology.
/**
* @throws Exception If failed.
*/
@Test
public void testTopology() throws Exception {
String ret = content(null, GridRestCommand.TOPOLOGY, "attr", "false", "mtr", "false");
info("Topology command result: " + ret);
JsonNode res = validateJsonResponse(ret);
assertEquals(gridCount(), res.size());
for (JsonNode node : res) {
assertTrue(node.get("attributes").isNull());
assertTrue(node.get("metrics").isNull());
JsonNode caches = node.get("caches");
assertFalse(caches.isNull());
Collection<IgniteCacheProxy<?, ?>> publicCaches = grid(0).context().cache().publicCaches();
assertEquals(publicCaches.size(), caches.size());
for (JsonNode cache : caches) {
String cacheName0 = cache.get("name").asText();
final String cacheName = cacheName0.isEmpty() ? null : cacheName0;
IgniteCacheProxy<?, ?> publicCache = F.find(publicCaches, null, new P1<IgniteCacheProxy<?, ?>>() {
@Override
public boolean apply(IgniteCacheProxy<?, ?> c) {
return F.eq(c.getName(), cacheName);
}
});
assertNotNull(publicCache);
CacheMode cacheMode = CacheMode.valueOf(cache.get("mode").asText());
assertEquals(publicCache.getConfiguration(CacheConfiguration.class).getCacheMode(), cacheMode);
}
}
// Test that caches not included.
ret = content(null, GridRestCommand.TOPOLOGY, "attr", "false", "mtr", "false", "caches", "false");
info("Topology command result: " + ret);
res = validateJsonResponse(ret);
assertEquals(gridCount(), res.size());
for (JsonNode node : res) {
assertTrue(node.get("attributes").isNull());
assertTrue(node.get("metrics").isNull());
assertTrue(node.get("caches").isNull());
}
}
use of org.apache.ignite.cache.CacheMode in project ignite by apache.
the class AbstractDataTypesCoverageTest method parameters.
/**
* @return Test parameters.
*/
@Parameterized.Parameters(name = "atomicityMode={1}, cacheMode={2}, ttlFactory={3}, backups={4}," + " evictionFactory={5}, onheapCacheEnabled={6}, writeSyncMode={7}, persistenceEnabled={8}, useBinaryArrays={9}")
public static Collection parameters() {
Set<Object[]> params = new HashSet<>();
Object[] baseParamLine = { null, CacheAtomicityMode.ATOMIC, CacheMode.PARTITIONED, null, 2, null, false, CacheWriteSynchronizationMode.FULL_SYNC, false, DFLT_IGNITE_USE_BINARY_ARRAYS };
Object[] paramLine = null;
for (CacheAtomicityMode atomicityMode : CacheAtomicityMode.values()) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[1] = atomicityMode;
params.add(paramLine);
}
for (CacheMode cacheMode : CacheMode.values()) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[2] = cacheMode;
params.add(paramLine);
}
assert paramLine != null;
if ((paramLine[1]) != CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT) {
for (Factory ttlFactory : TTL_FACTORIES) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[3] = ttlFactory;
params.add(paramLine);
}
}
for (int backups : new int[] { 0, 1, 2 }) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[4] = backups;
params.add(paramLine);
}
for (Factory evictionFactory : EVICTION_FACTORIES) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[5] = evictionFactory;
params.add(paramLine);
}
for (Boolean onheapCacheEnabled : BOOLEANS) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[6] = onheapCacheEnabled;
params.add(paramLine);
}
for (CacheWriteSynchronizationMode writeSyncMode : CacheWriteSynchronizationMode.values()) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[7] = writeSyncMode;
params.add(paramLine);
}
for (boolean persistenceEnabled : BOOLEANS) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[8] = persistenceEnabled;
params.add(paramLine);
}
for (boolean useTypedArrays : BOOLEANS) {
paramLine = Arrays.copyOf(baseParamLine, baseParamLine.length);
paramLine[9] = useTypedArrays;
params.add(paramLine);
}
for (Object[] pLine : params) pLine[0] = UUID.randomUUID();
return params;
}
use of org.apache.ignite.cache.CacheMode in project ignite by apache.
the class IgniteCacheCrossCacheJoinRandomTest method checkJoin.
/**
* @param cachesData Caches data.
* @param allModes Modes to test.
* @param modes Select modes.
* @param caches Caches number.
* @throws Exception If failed.
*/
private void checkJoin(List<Map<Integer, Integer>> cachesData, List<T2<CacheMode, Integer>> allModes, Stack<T2<CacheMode, Integer>> modes, int caches) throws Exception {
if (modes.size() == caches) {
List<CacheConfiguration> ccfgs = new ArrayList<>();
for (int i = 0; i < modes.size(); i++) {
T2<CacheMode, Integer> mode = modes.get(i);
CacheConfiguration ccfg = configuration("cache" + i, mode.get1(), mode.get2());
ccfgs.add(ccfg);
}
log.info("Check configurations: " + modes);
checkJoinQueries(ccfgs, cachesData);
} else {
for (T2<CacheMode, Integer> mode : allModes) {
modes.push(mode);
checkJoin(cachesData, allModes, modes, caches);
modes.pop();
}
}
}
Aggregations