Beispiel #1
0
  @Override
  public void run() {
    if (logger.isDebugEnabled()) {
      logger.debug("Create task manager thread.");
    }

    do {
      logger.info("TaskManager: current task index: " + Integer.toString(currentTaskIndex));
      try {
        String output = currentTask.Run();
        logger.info("Task {[]} output: {[]}", currentTask.id(), output);
        logger.info("Task [" + currentTask.id() + "] output: " + output);
      } catch (IOException ex) {
        logger.error("TaskManager: IOException");
      } catch (InterruptedException ex) {
        logger.error("TaskManager: Interrupted Exception");
      }

      currentTask = GetNextTask();
    } while (null != currentTask);

    DeleteMappingRequest req = new DeleteMappingRequest("_river");
    req.type(river.riverName().name());
    DeleteMappingResponse resp = client.admin().indices().deleteMapping(req).actionGet();
    logger.info("TaskManager: delete request: " + resp.toString());
  }
Beispiel #2
0
  private void InitTasks() throws Exception {
    QueryBuilder builder = QueryBuilders.boolQuery().must(QueryBuilders.termQuery("_id", "_meta"));

    SearchRequestBuilder search = client.prepareSearch("_river");
    search.setTypes(river.riverName().name());
    search.setQuery(builder);
    SearchResponse resp = search.execute().actionGet();

    int hitCount = 0;
    for (SearchHit hit : resp.hits().getHits()) {
      logger.info(
          "Task Manager: Query response hits[ "
              + Integer.toString(hitCount)
              + "]: "
              + hit.sourceAsString());
      hitCount++;

      Map<String, Object> sourceMap = hit.sourceAsMap();
      Map<String, Object> my = (Map<String, Object>) sourceMap.get("my");
      ArrayList arr = (ArrayList) my.get("tasks");
      for (Object taskObj : arr) {
        Task newTask = new Task((Map<String, String>) taskObj, client, river.riverName().name());
        taskArr.add(newTask);
        taskMap.put(newTask.id(), newTask);
      }
    }

    currentTaskIndex = 0;
    currentTask = (Task) taskArr.get(currentTaskIndex);
  }