}
}
for (Entry<String, String> serviceParam : serviceParams.entrySet()) {
builder.setServiceConfig(serviceParam.getKey(), serviceParam.getValue());
}
final MiniCluster miniCluster = builder.build();
// Create an exit thread that listens for a kill command, and notifies the
// main thread to exit.
final CountDownLatch doneSignal = new CountDownLatch(1);
Thread exitThread = new Thread() {
@Override
public void run() {
try {
miniCluster.stop();
} catch (Throwable e) {
console.error("Error stopping mini cluster. Exiting anyways...", e);
}
doneSignal.countDown();
}
};
Runtime.getRuntime().addShutdownHook(exitThread);
// Start the mini cluster, and wait for the exit notification.
try {
miniCluster.start();
doneSignal.await();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return 1;
}