This change fixes the sporadic connection refused errors after managix starts up an Asterix instance. This can mostly be seen during asterix-installer tests.
The fix basically lets managix wait and listens through zookeeper for a signal from the cluster controller. Once the cluster controller sends the signal, Managix can proceed.
Change-Id: I0975308e1dc2650d8c2e50d58ff2c696b22eaaa4
Reviewed-on: https://asterix-gerrit.ics.uci.edu/365
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplicationEntryPoint.java b/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplicationEntryPoint.java
index e47b550..1903a4b 100644
--- a/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplicationEntryPoint.java
+++ b/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/application/ICCApplicationEntryPoint.java
@@ -22,4 +22,6 @@
public void start(ICCApplicationContext ccAppCtx, String[] args) throws Exception;
public void stop() throws Exception;
+
+ void startupCompleted() throws Exception;
}
\ No newline at end of file
diff --git a/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/ClusterControllerService.java b/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/ClusterControllerService.java
index f2f450d..e311903 100644
--- a/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/ClusterControllerService.java
+++ b/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/ClusterControllerService.java
@@ -153,6 +153,8 @@
private ShutdownRun shutdownCallback;
+ private ICCApplicationEntryPoint aep;
+
public ClusterControllerService(final CCConfig ccConfig) throws Exception {
this.ccConfig = ccConfig;
File jobLogFolder = new File(ccConfig.ccRoot, "logs/jobs");
@@ -243,6 +245,10 @@
datasetDirectoryService.init(executor);
workQueue.start();
LOGGER.log(Level.INFO, "Started ClusterControllerService");
+ if (aep != null) {
+ // Sometimes, there is no application entry point. Check hyracks-client project
+ aep.startupCompleted();
+ }
}
private void startApplication() throws Exception {
@@ -251,7 +257,7 @@
String className = ccConfig.appCCMainClass;
if (className != null) {
Class<?> c = Class.forName(className);
- ICCApplicationEntryPoint aep = (ICCApplicationEntryPoint) c.newInstance();
+ aep = (ICCApplicationEntryPoint) c.newInstance();
String[] args = ccConfig.appArgs == null ? null : ccConfig.appArgs.toArray(new String[ccConfig.appArgs
.size()]);
aep.start(appCtx, args);