//Starting monitoring thread
this.monitor = new Thread(this);
- this.monitor.start();
}
- public abstract void execute();
+ public abstract void onStart();
+
+ public abstract void onStop();
+
+ public final void start() {
+ this.monitor.start();
+ onStart();
+ }
- public void shutdown() {
+ public final void shutdown() {
this.monitor.interrupt();
+ this.onStop();
}
@Override
node = NodeBuilder.nodeBuilder()
.settings(esSettings)
- .build().start();
+ .build();
}
@Override
- public void execute() {
+ public void onStart() {
+ node.start();
try {
Thread.currentThread().join();
} catch (InterruptedException e) {
}
}
- public void shutdown() {
+ public void onStop() {
if (node != null) {
this.node.close();
}
- super.shutdown();
}
public static void main(String... args) {
Props props = Props.create(System.getProperties());
ElasticSearch elasticSearch = new ElasticSearch(props);
- elasticSearch.execute();
+ elasticSearch.start();
}
}
\ No newline at end of file