Package org.apache.twill.internal.state

Examples of org.apache.twill.internal.state.StateNode


                               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));
  }
View Full Code Here


    // Create the live node, if succeeded, start the decorated service, otherwise fail out.
    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)
View Full Code Here

    private void saveState(ServiceController.State state) {
      if (zkFailure) {
        return;
      }
      StateNode stateNode = new StateNode(state);
      stopOnFailure(zkClient.setData(getZKPath("state"), encodeStateNode(stateNode)));
    }
View Full Code Here

        byte[] data = result.getData();
        if (data == null) {
          stateNodeUpdated(null);
          return;
        }
        StateNode stateNode = new GsonBuilder().registerTypeAdapter(StateNode.class, new StateNodeCodec())
          .registerTypeAdapter(StackTraceElement.class, new StackTraceElementCodec())
          .create()
          .fromJson(new String(data, Charsets.UTF_8), StateNode.class);

        stateNodeUpdated(stateNode);
View Full Code Here

    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)
View Full Code Here

    private void saveState(ServiceController.State state) {
      if (zkFailure) {
        return;
      }
      StateNode stateNode = new StateNode(state);
      stopOnFailure(zkClient.setData(getZKPath("state"), encodeStateNode(stateNode)));
    }
View Full Code Here

      byte[] data = result.getData();
      if (data == null) {
        stateNodeUpdated(null);
        return;
      }
      StateNode stateNode = new GsonBuilder().registerTypeAdapter(StateNode.class, new StateNodeCodec())
        .registerTypeAdapter(StackTraceElement.class, new StackTraceElementCodec())
        .create()
        .fromJson(new String(data, Charsets.UTF_8), StateNode.class);

      stateNodeUpdated(stateNode);
View Full Code Here

TOP

Related Classes of org.apache.twill.internal.state.StateNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.