Пример #1
0
  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;
  }
Пример #2
0
 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();
   }
 }
Пример #3
0
 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;
 }