use of org.apache.ignite.Ignite in project ignite by apache.
the class IgniteCrossCachesJoinsQueryTest method check.
/**
* @param idx Index flag.
* @param personCacheType Person cache personCacheType.
* @param accCacheType Account cache personCacheType.
* @param orgCacheType Organization cache personCacheType.
* @throws Exception If failed.
*/
private void check(boolean idx, final TestCache personCacheType, final TestCache accCacheType, final TestCache orgCacheType) throws Exception {
info("Checking cross cache joins [accCache=" + accCacheType + ", personCache=" + personCacheType + ", orgCache=" + orgCacheType + "]");
Collection<TestCache> cacheTypes = F.asList(personCacheType, accCacheType, orgCacheType);
for (TestCache cache : cacheTypes) {
CacheConfiguration cc = cacheConfiguration(cache.cacheName, cache.type.cacheMode, cache.type.backups, idx, cache == accCacheType, cache == personCacheType, cache == orgCacheType);
ignite(0).getOrCreateCache(cc);
info("Created cache [name=" + cache.cacheName + ", mode=" + cache.type + "]");
}
initCachesData();
// checkAllDataEquals();
List<String> cacheNames = new ArrayList<>();
cacheNames.add(personCacheType.cacheName);
cacheNames.add(orgCacheType.cacheName);
cacheNames.add(accCacheType.cacheName);
for (int i = 0; i < NODES; i++) {
Ignite testNode = ignite(i);
log.info("Test node [idx=" + i + ", isClient=" + testNode.configuration().isClientMode() + "]");
for (String cacheName : cacheNames) {
cache = testNode.cache(cacheName);
log.info("Use cache: " + cache.getName());
boolean distributeJoins0 = distributedJoins;
if (replicated(cache)) {
// if (!testNode.configuration().isClientMode())
// assertProperException(cache);
boolean all3CachesAreReplicated = replicated(ignite(0).cache(ACC_CACHE_NAME)) && replicated(ignite(0).cache(PERSON_CACHE_NAME)) && replicated(ignite(0).cache(ORG_CACHE_NAME));
// Queries running on replicated cache should not contain JOINs with partitioned tables.
if (distributeJoins0 && !all3CachesAreReplicated)
continue;
else
distributedJoins = false;
}
if (!cache.getName().equals(orgCacheType.cacheName))
checkPersonAccountsJoin(cache, data.accountsPerPerson);
if (!cache.getName().equals(accCacheType.cacheName))
checkOrganizationPersonsJoin(cache);
checkOrganizationPersonAccountJoin(cache);
checkUnion();
checkUnionAll();
if (!cache.getName().equals(orgCacheType.cacheName))
checkPersonAccountCrossJoin(cache);
if (!cache.getName().equals(accCacheType.cacheName))
checkPersonOrganizationGroupBy(cache);
if (!cache.getName().equals(orgCacheType.cacheName))
checkPersonAccountGroupBy(cache);
checkGroupBy();
distributedJoins = distributeJoins0;
}
}
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class IgniteErrorOnRebalanceTest method testErrorOnRebalance.
/**
* @throws Exception If failed.
*/
public void testErrorOnRebalance() throws Exception {
Ignite srv0 = startGrid(0);
srv0.active(true);
{
IgniteCache<Object, Object> cache0 = srv0.cache(DEFAULT_CACHE_NAME);
for (int i = 0; i < 5; i++) cache0.put(i, i);
}
Ignite srv1 = startGrid(1);
U.sleep(3000);
info("Stop node0.");
stopGrid(0);
awaitPartitionMapExchange();
info("Restart node0.");
srv0 = startGrid(0);
awaitPartitionMapExchange();
IgniteCache<Object, Object> cache0 = srv0.cache(DEFAULT_CACHE_NAME);
IgniteCache<Object, Object> cache1 = srv1.cache(DEFAULT_CACHE_NAME);
Map<Object, Object> map0 = new HashMap<>();
Map<Object, Object> map1 = new HashMap<>();
for (int i = 0; i < 5; i++) {
map0.put(i, cache0.localPeek(i));
map1.put(i, cache1.localPeek(i));
}
assertEquals(map0, map1);
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class IgniteFailoverAbstractBenchmark method onWarmupFinished.
/**
* {@inheritDoc}
*/
@Override
public void onWarmupFinished() {
if (cfg.memberId() == 0 && restarterStarted.compareAndSet(false, true)) {
Thread restarterThread = new Thread(new Runnable() {
@Override
public void run() {
try {
println("Servers restarter started on driver: " + IgniteFailoverAbstractBenchmark.this.getClass().getSimpleName());
Ignite ignite = ignite();
// Read servers configs from cache to local map.
IgniteCache<Integer, BenchmarkConfiguration> srvsCfgsCache = ignite.getOrCreateCache(new CacheConfiguration<Integer, BenchmarkConfiguration>().setName("serversConfigs"));
final Map<Integer, BenchmarkConfiguration> srvsCfgs = new HashMap<>();
for (Cache.Entry<Integer, BenchmarkConfiguration> e : srvsCfgsCache) {
println("Read entry from 'serversConfigs' cache : " + e);
srvsCfgs.put(e.getKey(), e.getValue());
}
assert ignite.cluster().forServers().nodes().size() == srvsCfgs.size();
final int backupsCnt = args.backups();
assert backupsCnt >= 1 : "Backups: " + backupsCnt;
final boolean isDebug = ignite.log().isDebugEnabled();
// Main logic.
while (!Thread.currentThread().isInterrupted()) {
Thread.sleep(args.restartDelay() * 1000);
int numNodesToRestart = nextRandom(1, backupsCnt + 1);
List<Integer> ids = new ArrayList<>();
ids.addAll(srvsCfgs.keySet());
Collections.shuffle(ids);
println("Waiting for partitioned map exchage of all nodes");
ignite.compute().broadcastAsync(new AwaitPartitionMapExchangeTask()).get(args.cacheOperationTimeoutMillis());
println("Start servers restarting [numNodesToRestart=" + numNodesToRestart + ", shuffledIds=" + ids + "]");
for (int i = 0; i < numNodesToRestart; i++) {
Integer id = ids.get(i);
BenchmarkConfiguration bc = srvsCfgs.get(id);
ProcessExecutionResult res = BenchmarkUtils.kill9Server(bc, isDebug);
println("Server with id " + id + " has been killed." + (isDebug ? " Process execution result:\n" + res : ""));
}
Thread.sleep(args.restartSleep() * 1000);
for (int i = 0; i < numNodesToRestart; i++) {
Integer id = ids.get(i);
BenchmarkConfiguration bc = srvsCfgs.get(id);
ProcessExecutionResult res = BenchmarkUtils.startServer(bc, isDebug);
println("Server with id " + id + " has been started." + (isDebug ? " Process execution result:\n" + res : ""));
}
}
} catch (Throwable e) {
println("Got exception: " + e);
e.printStackTrace();
U.dumpThreads(null);
if (e instanceof Error)
throw (Error) e;
}
}
}, "servers-restarter");
restarterThread.setDaemon(true);
restarterThread.start();
}
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class IgniteFailoverAbstractBenchmark method onException.
/**
* {@inheritDoc}
*/
@Override
public void onException(Throwable e) {
// Proceess only the first exception to prevent a multiple printing of a full thread dump.
if (firtsExProcessed.compareAndSet(false, true)) {
// Debug info on current client.
println("Full thread dump of the current node below.");
U.dumpThreads(null);
println("");
((IgniteMXBean) ignite()).dumpDebugInfo();
// Debug info on servers.
Ignite ignite = ignite();
ClusterGroup srvs = ignite.cluster().forServers();
ignite.compute(srvs).broadcastAsync(new ThreadDumpPrinterTask(ignite.cluster().localNode().id(), e)).get(10_000);
}
}
use of org.apache.ignite.Ignite in project ignite by apache.
the class IgniteCacheDistributedPartitionQueryNodeRestartsSelfTest method testJoinQueryUnstableTopology.
/**
* Tests join query within region on unstable topology.
*/
public void testJoinQueryUnstableTopology() throws Exception {
final AtomicBoolean stop = new AtomicBoolean();
final AtomicIntegerArray states = new AtomicIntegerArray(GRIDS_COUNT);
final Ignite client = grid("client");
final AtomicInteger cnt = new AtomicInteger();
IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
@Override
public void run() {
while (!stop.get()) {
doTestJoinQuery(client, rnd.nextInt(PARTS_PER_REGION.length) + 1);
int cur = cnt.incrementAndGet();
if (cur % 100 == 0)
log().info("Queries count: " + cur);
}
}
}, QUERY_THREADS_CNT);
final AtomicIntegerArray restartStats = new AtomicIntegerArray(GRIDS_COUNT);
IgniteInternalFuture<?> fut2 = multithreadedAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
while (!stop.get()) {
int grid = rnd.nextInt(GRIDS_COUNT);
String name = getTestIgniteInstanceName(grid);
Integer regionId = regionForGrid(name);
// Restart nodes only from region with enough number of nodes.
if (regionId != 3 && regionId != 4)
continue;
if (states.compareAndSet(grid, 0, 1)) {
restartStats.incrementAndGet(grid);
try {
stopGrid(grid);
Thread.sleep(rnd.nextInt(NODE_RESTART_TIME));
startGrid(grid);
Thread.sleep(rnd.nextInt(NODE_RESTART_TIME));
} finally {
states.set(grid, 0);
}
}
}
return null;
}
}, RESTART_THREADS_CNT);
try {
fut2.get(60, TimeUnit.SECONDS);
} catch (IgniteFutureTimeoutCheckedException ignored) {
stop.set(true);
}
try {
fut.get();
} finally {
log().info("Queries count: " + cnt.get());
for (int i = 0; i < GRIDS_COUNT; i++) log().info("Grid [name = " + getTestIgniteInstanceName(i) + ", idx=" + i + " ] restarts count: " + restartStats.get(i));
}
}
Aggregations