use of com.nokia.dempsy.Dempsy in project Dempsy by Dempsy.
the class RunNode method run.
public static void run(String[] args) throws Throwable {
//======================================================
// Handle all of the options.
String application = System.getProperty(applicationParam);
if (application == null || application.length() == 0)
usage("the java vm option \"-D" + applicationParam + "\" wasn't specified.");
String[] clusterIdParts = application.split(":");
if (clusterIdParts.length != 2)
usage("invalid format for the -Dcluster option. It should be a clusterid of the form \"applicationName:clusterName.\"");
System.setProperty("application", clusterIdParts[0]);
System.setProperty("cluster", clusterIdParts[1]);
String appCtxFilename = System.getProperty(appdefParam);
if (appCtxFilename == null || appCtxFilename.length() == 0) {
// usage("the java vm option \"-D" + appdefParam + "\" wasn't specified.");
appCtxFilename = "DempsyApplicationContext-" + clusterIdParts[0] + ".xml";
}
String zkConnect = System.getProperty(zk_connectParam);
if (zkConnect == null || zkConnect.length() == 0)
usage("the java vm option \"-D" + zk_connectParam + "\" wasn't specified.");
String zkTimeout = System.getProperty(zk_timeoutParam);
if (zkTimeout == null || zkTimeout.length() == 0)
System.setProperty(zk_timeoutParam, zk_timeoutDefault);
String totalSlots = System.getProperty(total_slots_per_clusterParam);
if (totalSlots == null || totalSlots.length() == 0)
System.setProperty(total_slots_per_clusterParam, total_slots_per_clusterDefault);
String minNodes = System.getProperty(min_num_nodes_per_clusterParam);
if (minNodes == null || minNodes.length() == 0)
System.setProperty(min_num_nodes_per_clusterParam, min_num_nodes_per_clusterDefault);
//======================================================
String contextFile = "classpath:Dempsy-distributed.xml";
ClassPathXmlApplicationContext context = null;
try {
// Initialize Spring
context = new ClassPathXmlApplicationContext(new String[] { appCtxFilename, contextFile });
context.registerShutdownHook();
} catch (Throwable e) {
logger.error(MarkerFactory.getMarker("FATAL"), "Failed to start the application ", e);
throw e;
}
if (context != null) {
try {
context.getBean(Dempsy.class).waitToBeStopped();
} catch (InterruptedException e) {
logger.error("Interrupted . . . ", e);
} finally {
context.stop();
}
logger.info("Shut down dempsy appliction " + appCtxFilename + "-" + application + ", bye!");
}
}
Aggregations