protected String checkStatus(Tracker tracker, UUID uuid) {
    String state = "UNKNOWN";
    long start = System.currentTimeMillis();
    while (!Thread.interrupted()) {
      TrackerOperationView po = tracker.getTrackerOperation(HiveConfig.PRODUCT_KEY, uuid);
      if (po != null) {
        if (po.getState() != OperationState.RUNNING) {
          if (po.getLog().contains("RunJar") && po.getLog().contains("NetworkServerControl")) {
            state = "RUNNING";
          } else {
            state = "STOPPED";
          }
          break;
        }
      }
      try {
        Thread.sleep(1000);
      } catch (InterruptedException ex) {
        break;
      }
      if (System.currentTimeMillis() - start > (30 + 3) * 1000) {
        break;
      }
    }

    return state;
  }
 private Response createResponse(UUID uuid, OperationState state) {
   TrackerOperationView po = tracker.getTrackerOperation(HiveConfig.PRODUCT_KEY, uuid);
   if (state == OperationState.FAILED) {
     return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
         .entity(JsonUtil.GSON.toJson(po.getLog()))
         .build();
   } else if (state == OperationState.SUCCEEDED) {
     return Response.status(Response.Status.OK).entity(JsonUtil.GSON.toJson(po.getLog())).build();
   } else {
     return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
         .entity(JsonUtil.GSON.toJson("Timeout"))
         .build();
   }
 }
 private OperationState waitUntilOperationFinish(UUID uuid) {
   OperationState state = null;
   long start = System.currentTimeMillis();
   while (!Thread.interrupted()) {
     TrackerOperationView po = tracker.getTrackerOperation(HiveConfig.PRODUCT_KEY, uuid);
     if (po != null) {
       if (po.getState() != OperationState.RUNNING) {
         state = po.getState();
         break;
       }
     }
     try {
       Thread.sleep(1000);
     } catch (InterruptedException ex) {
       break;
     }
     if (System.currentTimeMillis() - start > (90 * 100000)) {
       break;
     }
   }
   return state;
 }