use of com.continuuity.weave.internal.state.StateNode in project weave by continuuity.
the class ZKServiceDecorator method doStart.
@Override
protected void doStart() {
callbackExecutor = Executors.newSingleThreadExecutor(Threads.createDaemonThreadFactory("message-callback"));
Futures.addCallback(createLiveNode(), new FutureCallback<String>() {
@Override
public void onSuccess(String result) {
// Create nodes for states and messaging
StateNode stateNode = new StateNode(ServiceController.State.STARTING);
final ListenableFuture<List<String>> createFuture = Futures.allAsList(ZKOperations.ignoreError(zkClient.create(getZKPath("messages"), null, CreateMode.PERSISTENT), KeeperException.NodeExistsException.class, null), zkClient.create(getZKPath("state"), encodeStateNode(stateNode), CreateMode.PERSISTENT));
createFuture.addListener(new Runnable() {
@Override
public void run() {
try {
createFuture.get();
// Starts the decorated service
decoratedService.addListener(createListener(), Threads.SAME_THREAD_EXECUTOR);
decoratedService.start();
} catch (Exception e) {
notifyFailed(e);
}
}
}, Threads.SAME_THREAD_EXECUTOR);
}
@Override
public void onFailure(Throwable t) {
notifyFailed(t);
}
});
}
use of com.continuuity.weave.internal.state.StateNode in project weave by continuuity.
the class StateNodeCodec method deserialize.
@Override
public StateNode deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
JsonObject jsonObj = json.getAsJsonObject();
ServiceController.State state = ServiceController.State.valueOf(jsonObj.get("state").getAsString());
String errorMessage = jsonObj.has("errorMessage") ? jsonObj.get("errorMessage").getAsString() : null;
return new StateNode(state, errorMessage, context.<StackTraceElement[]>deserialize(jsonObj.get("stackTraces"), StackTraceElement[].class));
}
use of com.continuuity.weave.internal.state.StateNode in project weave by continuuity.
the class ControllerTest method getController.
private WeaveController getController(ZKClient zkClient, RunId runId) {
WeaveController controller = new AbstractWeaveController(runId, zkClient, ImmutableList.<LogHandler>of()) {
@Override
public void kill() {
// No-op
}
@Override
protected void instanceNodeUpdated(NodeData nodeData) {
// No-op
}
@Override
protected void stateNodeUpdated(StateNode stateNode) {
// No-op
}
@Override
public ResourceReport getResourceReport() {
return null;
}
};
controller.startAndWait();
return controller;
}
Aggregations