private void processPropertyStoreChange(String path) {
    try {
      LOGGER.info("Processing change notification for path:{}", path);
      refreshWatchers(path);

      if (isLeader()) {
        if (path.matches(REALTIME_SEGMENT_PROPERTY_STORE_PATH_PATTERN)) {
          assignRealtimeSegmentsToServerInstancesIfNecessary();
        }
      } else {
        LOGGER.info(
            "Not the leader of this cluster, ignoring realtime segment property store change.");
      }
    } catch (Exception e) {
      LOGGER.error("Caught exception while processing change for path {}", path, e);
      Utils.rethrowException(e);
    }
  }
示例#2
0
  public void start() throws Exception {
    Utils.logVersions();

    LOGGER.info("Network starting !!");
    if (_state.get() != State.INIT) {
      LOGGER.warn("Network already initialized. Skipping !!");
      return;
    }
    _state.set(State.STARTING);
    _connPool.start();
    _routingTable.start();
    _state.set(State.RUNNING);
    if (listener != null) {
      listener.init(_connPool, DEFAULT_BROKER_TIME_OUT);
    }
    LOGGER.info("Network running !!");

    LOGGER.info("Starting Jetty server !!");
    _server.start();
    LOGGER.info("Started Jetty server !!");
  }
  public List<JSONObject> renderGroupByOperators(
      List<Map<String, Serializable>> finalAggregationResult) {
    try {
      if (finalAggregationResult == null
          || finalAggregationResult.size() != _aggregationFunctionList.size()) {
        return null;
      }
      List<JSONObject> retJsonResultList = new ArrayList<JSONObject>();
      for (int i = 0; i < _aggregationFunctionList.size(); ++i) {
        JSONArray groupByResultsArray = new JSONArray();

        int groupSize = _groupByColumns.size();
        Map<String, Serializable> reducedGroupByResult = finalAggregationResult.get(i);
        if (!reducedGroupByResult.isEmpty()) {

          PriorityQueue priorityQueue =
              getPriorityQueue(
                  _aggregationFunctionList.get(i), reducedGroupByResult.values().iterator().next());
          if (priorityQueue != null) {
            for (String groupedKey : reducedGroupByResult.keySet()) {
              priorityQueue.enqueue(new Pair(reducedGroupByResult.get(groupedKey), groupedKey));
              if (priorityQueue.size() == (_groupByTopN + 1)) {
                priorityQueue.dequeue();
              }
            }

            int realGroupSize = _groupByTopN;
            if (priorityQueue.size() < _groupByTopN) {
              realGroupSize = priorityQueue.size();
            }
            for (int j = 0; j < realGroupSize; ++j) {
              JSONObject groupByResultObject = new JSONObject();
              Pair res = (Pair) priorityQueue.dequeue();
              groupByResultObject.put(
                  "group",
                  new JSONArray(
                      ((String) res.getSecond())
                          .split(
                              GroupByConstants.GroupByDelimiter.groupByMultiDelimeter.toString(),
                              groupSize)));
              //          if (res.getFirst() instanceof Number) {
              //            groupByResultObject.put("value", df.format(res.getFirst()));
              //          } else {
              //            groupByResultObject.put("value", res.getFirst());
              //          }
              //          groupByResultsArray.put(realGroupSize - 1 - j, groupByResultObject);
              groupByResultObject.put(
                  "value",
                  _aggregationFunctionList
                      .get(i)
                      .render((Serializable) res.getFirst())
                      .get("value"));
              groupByResultsArray.put(realGroupSize - 1 - j, groupByResultObject);
            }
          }
        }

        JSONObject result = new JSONObject();
        result.put("function", _aggregationFunctionList.get(i).getFunctionName());
        result.put("groupByResult", groupByResultsArray);
        result.put("groupByColumns", new JSONArray(_groupByColumns));
        retJsonResultList.add(result);
      }
      return retJsonResultList;
    } catch (JSONException e) {
      LOGGER.error("Caught exception while processing group by aggregation", e);
      Utils.rethrowException(e);
      throw new AssertionError("Should not reach this");
    }
  }