Package com.alipay.bluewhale.core.work.refresh

Examples of com.alipay.bluewhale.core.work.refresh.WorkerHeartbeat


  @SuppressWarnings("rawtypes")
  public static void doHeartbeat(Map conf, String worker_id, int port,
      String storm_id, Set<Integer> task_ids) throws IOException {

    int currtime = TimeUtils.current_time_secs();
    WorkerHeartbeat hb = new WorkerHeartbeat(currtime, storm_id, task_ids,
        port);

    LOG.debug("Doing heartbeat:" + worker_id + ",port:" + port + ",hb"
        + hb.toString());

    LocalState state = StormConfig.worker_state(conf, worker_id);
    state.put(Common.LS_WORKER_HEARTBEAT, hb);

  }
View Full Code Here


    LocalState ls = StormConfig.worker_state(conf, workerId);

    while (true) {

      WorkerHeartbeat whb = (WorkerHeartbeat) ls
          .get(Common.LS_WORKER_HEARTBEAT);
      if (whb == null
          && ((TimeUtils.current_time_secs() - startTime) < (Integer) conf
              .get(Config.SUPERVISOR_WORKER_START_TIMEOUT_SECS))) {
        LOG.info(workerId + "still hasn't started");
        Time.sleep(500);
      } else {
        // whb is valid or timeout
        break;
      }
    }

    WorkerHeartbeat whb = (WorkerHeartbeat) ls
        .get(Common.LS_WORKER_HEARTBEAT);
    if (whb == null) {
      LOG.info("Worker " + workerId + "failed to start");
    }
  }
View Full Code Here

        Map.Entry<String, WorkerHeartbeat> entry = it.next();

        String workerid = entry.getKey().toString();

        WorkerHeartbeat whb = entry.getValue();

        State state = null;

        if (whb == null) {

          state = State.notStarted;

        } else if (approvedIds == null
            || approvedIds.containsKey(workerid) == false
            || matchesAssignment(whb, assignedTasks) == false) {

          // workerId isn't approved or
          // isn't assigned task
          state = State.disallowed;

        } else if ((now - whb.getTimeSecs()) > (Integer) conf
            .get(Config.SUPERVISOR_WORKER_TIMEOUT_SECS)) {//

          state = State.timedOut;
        } else {
          state = State.valid;
View Full Code Here

    if (workerIds != null) {
      workerHeartbeats = new HashMap<String, WorkerHeartbeat>();

      for (String workerId : workerIds) {

        WorkerHeartbeat whb = readWorkerHeartbeat(conf, workerId);
        // this place whb can be null
        workerHeartbeats.put(workerId, whb);
      }
    }
    return workerHeartbeats;
View Full Code Here

TOP

Related Classes of com.alipay.bluewhale.core.work.refresh.WorkerHeartbeat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.