use of org.yardstickframework.BenchmarkUtils.ProcessExecutionResult 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();
}
}
Aggregations