Exemplo n.º 1
0
  /** This contacts the master to find if any of the pending acks are completed, */
  public synchronized void checkAcks() {
    LOG.debug("agent acks waiting for master: " + pending);

    // TODO (make this a batch operation with only one RPC call)
    List<String> done = new ArrayList<String>();
    for (String k : pending.keySet()) {
      try {
        boolean acked = client.checkAck(k);
        if (acked) {
          done.add(k);
        }
      } catch (IOException e) {
        // TODO (jon) there is a potential inconsistency here if master comms
        // fail (but this is recovered when retry happens).
        LOG.error("Master connection exception", e);
      }
    }

    for (String k : done) {
      try {
        listener.end(k);
        pending.remove(k);
        LOG.debug("removed ack tag from agent's ack queue: " + k);
      } catch (IOException e) {
        LOG.error("problem notifying agent pending ack queue", e);
      }
    }
  }
Exemplo n.º 2
0
  @Override
  public void addPendingQ(String tagId, Map<String, Long> fileOffsets) throws IOException {
    // TODO 해당 tagId가 들어오면 fileOffsets을 합쳐야 한다.
    // 이 때 같은 파일이 들어오면 더 높은 offset으로 update를 하면 되고
    // 새로운 파일이 들어오면 맵에 추가 하면 된다.
    // 이 때 언제 저 맵을 clear해 줄 것인가? 체크포인트 파일로 쓸때? 아니면
    // 삭제를 하면 안되나? ==> Master에서 정보를 확인하고 삭제 해야 할거 같은데

    // TODO IOException 처리
    log.info("add pending : " + tagId + " , " + fileOffsets);
    pending.add(new CheckpointData(tagId, fileOffsets));
    listener.end(tagId);
  }
Exemplo n.º 3
0
  @Override
  public void append(Event e) throws IOException, InterruptedException {
    byte[] btyp = e.get(CheckpointDeco.ATTR_CK_TYPE);

    if (btyp == null) {
      super.append(e);
      return;
    }

    byte[] btag = e.get(CheckpointDeco.ATTR_CK_TAG);
    String k = new String(btag);

    if (Arrays.equals(btyp, CheckpointDeco.CK_START)) {
      listener.start(k);
      return;
    } else if (Arrays.equals(btyp, CheckpointDeco.CK_END)) {
      listener.end(k);
      return;
    }
    super.append(e);
  }