public Representation get()

in uReplicator-Controller/src/main/java/com/uber/stream/kafka/mirrormaker/controller/rest/resources/NoProgressTopicPartitionRestletResource.java [46:77]


  public Representation get() {
    JSONObject responseJson = new JSONObject();
    List<TopicAndPartition> noProgressTopicPartition = _helixMirrorMakerManager.getOffsetMonitor().getNoProgessTopicPartitions();
    if (noProgressTopicPartition == null || noProgressTopicPartition.size() == 0) {
      return new StringRepresentation(responseJson.toJSONString());
    }
    JSONArray jsonArray = new JSONArray();
    for (TopicAndPartition info : noProgressTopicPartition) {

      JSONObject node = new JSONObject();
      node.put("topic", info.topic());
      node.put("partition", info.partition());

      IdealState idealStateForTopic =
          _helixMirrorMakerManager.getIdealStateForTopic(info.topic());
      Map<String, String> idealStateMap = idealStateForTopic.getInstanceStateMap(String.valueOf(info.partition()));
      ExternalView externalViewForTopic =
          _helixMirrorMakerManager.getExternalViewForTopic(info.topic());
      Map<String, String> stateMap = externalViewForTopic.getStateMap(String.valueOf(info.partition()));
      if (idealStateMap != null && idealStateMap.keySet().size() != 0) {
        node.put("idealWorker", idealStateMap.keySet().iterator().next());
      }
      if (stateMap != null && stateMap.keySet().size() != 0) {
        node.put("actualWorker", stateMap.keySet().iterator().next());
      }
      jsonArray.add(node);

    }
    responseJson.put("topics", jsonArray);

    return new StringRepresentation(responseJson.toJSONString());
  }