LOGGER.info("Process[{}]::start START", name);
if (this.port != null) {
lastPing = System.currentTimeMillis();
- pingTask = monitor.scheduleWithFixedDelay(breakOnMissingPing, 0, 3, TimeUnit.SECONDS);
+ pingTask = monitor.scheduleWithFixedDelay(breakOnMissingPing, 5, 5, TimeUnit.SECONDS);
}
this.onStart();
LOGGER.info("Process[{}]::start END", name);
import java.net.MalformedURLException;
import java.net.UnknownHostException;
import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
public class ProcessWrapper {
private StreamGobbler outputGobbler;
+ private ScheduledFuture<?> pingTask = null;
+ final ScheduledExecutorService monitor = Executors.newScheduledThreadPool(1);
+ final Runnable pinging = new Runnable() {
+ public void run() {
+ processMXBean.ping();
+ }
+ };
+
+
+
public ProcessWrapper(String className, Map<String, String> properties, final String name, Integer port, String... classPath) {
LOGGER.info("Creating Process for '{}' with monitoring port: {}", name, port);
this.name = name;
throw new IllegalStateException("Could not connect to JMX service", e);
}
- //TODO Register Scheduled timer to ping the Mbean
+ pingTask = monitor.scheduleWithFixedDelay(pinging, 0, 3, TimeUnit.SECONDS);
}
public boolean isReady() {
}
public void stop() {
+ pingTask.cancel(true);
processMXBean.stop();
}
- public void ping() {
- processMXBean.ping();
- }
-
public String getName() {
return name;
}
- public ProcessMXBean getProcessMXBean() {
- return processMXBean;
- }
-
public java.lang.Process executeProcess() {
ProcessBuilder processBuilder =
new ProcessBuilder("java",
.put("path.home", home);
// if (props.booleanOf(ES_DEBUG_PROPERTY, false)) {
- esSettings
- .put("http.enabled", true)
- .put("http.port", 9200);
+ esSettings
+ .put("http.enabled", true)
+ .put("http.port", 9200);
// } else {
// esSettings.put("http.enabled", false);
// }
@Override
public boolean isReady() {
- ClusterHealthStatus status = node.client().admin().cluster().prepareClusterStats()
- .get().getStatus();
- return status != null && status == ClusterHealthStatus.GREEN;
+ try {
+ ClusterHealthStatus status = node.client().admin().cluster().prepareClusterStats()
+ .get().getStatus();
+ return status != null && status == ClusterHealthStatus.GREEN;
+ } catch (Exception e) {
+ return false;
+ }
}
@Override