Exemplo n.º 1
1
    @Override
    public Response run(JerseyResourceDelegateContext context) {
      JerseyResourceDelegateContextKey<String> queryIdKey =
          JerseyResourceDelegateContextKey.valueOf(queryIdKeyName, String.class);
      String queryId = context.get(queryIdKey);
      JerseyResourceDelegateContextKey<String> printTypeKey =
          JerseyResourceDelegateContextKey.valueOf(printTypeKeyName, String.class);
      String printType = context.get(printTypeKey);
      JerseyResourceDelegateContextKey<MasterContext> masterContextKey =
          JerseyResourceDelegateContextKey.valueOf(
              JerseyResourceDelegateUtil.MasterContextKey, MasterContext.class);
      MasterContext masterContext = context.get(masterContextKey);

      QueryId queryIdObj = TajoIdUtils.parseQueryId(queryId);

      QueryManager queryManager = masterContext.getQueryJobManager();
      QueryInProgress queryInProgress = queryManager.getQueryInProgress(queryIdObj);

      QueryInfo queryInfo = null;
      if (queryInProgress == null) {
        queryInfo = queryManager.getFinishedQuery(queryIdObj);
      } else {
        queryInfo = queryInProgress.getQueryInfo();
      }

      if (queryInfo != null) {
        if (briefPrint.equalsIgnoreCase(printType)) {
          queryInfo = getBriefQueryInfo(queryInfo);
        }
        return Response.ok(queryInfo).build();
      } else {
        return Response.status(Status.NOT_FOUND).build();
      }
    }
Exemplo n.º 2
0
    @Override
    public Response run(JerseyResourceDelegateContext context) {
      JerseyResourceDelegateContextKey<String> stateKey =
          JerseyResourceDelegateContextKey.valueOf(stateKeyName, String.class);
      String state = context.get(stateKey);
      JerseyResourceDelegateContextKey<Long> startTimeKey =
          JerseyResourceDelegateContextKey.valueOf(startTimeKeyName, Long.class);
      long startTime = context.get(startTimeKey);
      JerseyResourceDelegateContextKey<Long> endTimeKey =
          JerseyResourceDelegateContextKey.valueOf(endTimeKeyName, Long.class);
      long endTime = context.get(endTimeKey);
      JerseyResourceDelegateContextKey<MasterContext> masterContextKey =
          JerseyResourceDelegateContextKey.valueOf(
              JerseyResourceDelegateUtil.MasterContextKey, MasterContext.class);
      MasterContext masterContext = context.get(masterContextKey);

      TajoProtos.QueryState queryState = null;
      try {
        if (state != null && !state.isEmpty()) {
          queryState = TajoProtos.QueryState.valueOf(state);
        }
      } catch (Exception e) {
        return ResourcesUtil.createBadRequestResponse(LOG, state + " is not a valid query state.");
      }

      Map<String, List<QueryInfo>> queriesMap = new HashMap<>();
      List<QueryInfo> queriesInfo = new ArrayList<>();

      QueryManager queryManager = masterContext.getQueryJobManager();
      for (QueryInProgress queryInProgress : queryManager.getSubmittedQueries()) {
        queriesInfo.add(queryInProgress.getQueryInfo());
      }

      for (QueryInProgress queryInProgress : queryManager.getRunningQueries()) {
        queriesInfo.add(queryInProgress.getQueryInfo());
      }

      queriesInfo.addAll(queryManager.getFinishedQueries());

      if (state != null) {
        queriesInfo = selectQueriesInfoByState(queriesInfo, queryState);
      }

      if (startTime > 0 || endTime > 0) {
        queriesInfo = selectQueriesInfoByTime(queriesInfo, startTime, endTime);
      }
      queriesMap.put("queries", queriesInfo);

      return Response.ok(queriesMap).build();
    }
Exemplo n.º 3
0
    @Override
    public Response run(JerseyResourceDelegateContext context) {
      JerseyResourceDelegateContextKey<String> queryIdKey =
          JerseyResourceDelegateContextKey.valueOf(queryIdKeyName, String.class);
      String queryId = context.get(queryIdKey);
      JerseyResourceDelegateContextKey<MasterContext> masterContextKey =
          JerseyResourceDelegateContextKey.valueOf(
              JerseyResourceDelegateUtil.MasterContextKey, MasterContext.class);
      MasterContext masterContext = context.get(masterContextKey);

      QueryId queryIdObj = TajoIdUtils.parseQueryId(queryId);

      QueryManager queryManager = masterContext.getQueryJobManager();
      queryManager
          .getEventHandler()
          .handle(new QueryJobEvent(QueryJobEvent.Type.QUERY_JOB_KILL, new QueryInfo(queryIdObj)));
      return Response.ok().build();
    }