use of org.apache.storm.generated.SupervisorWorkerHeartbeat in project storm by apache.
the class StatsUtil method thriftifyRpcWorkerHb.
// =====================================================================================
// thriftify stats methods
// =====================================================================================
/**
* Used for local test.
*/
public static SupervisorWorkerHeartbeat thriftifyRpcWorkerHb(String stormId, List<Long> executorId) {
SupervisorWorkerHeartbeat supervisorWorkerHeartbeat = new SupervisorWorkerHeartbeat();
supervisorWorkerHeartbeat.set_storm_id(stormId);
supervisorWorkerHeartbeat.set_executors(Collections.singletonList(new ExecutorInfo(executorId.get(0).intValue(), executorId.get(1).intValue())));
supervisorWorkerHeartbeat.set_time_secs(Time.currentTimeSecs());
return supervisorWorkerHeartbeat;
}
use of org.apache.storm.generated.SupervisorWorkerHeartbeat in project storm by apache.
the class Nimbus method updateCachedHeartbeatsFromSupervisor.
private void updateCachedHeartbeatsFromSupervisor(SupervisorWorkerHeartbeats workerHeartbeats) {
for (SupervisorWorkerHeartbeat hb : workerHeartbeats.get_worker_heartbeats()) {
String topoId = hb.get_storm_id();
int heartbeatTimeoutSecs = getTopologyHeartbeatTimeoutSecs(topoId);
updateCachedHeartbeatsFromWorker(hb, heartbeatTimeoutSecs);
}
if (!heartbeatsReadyFlag.get() && !Strings.isNullOrEmpty(workerHeartbeats.get_supervisor_id())) {
heartbeatsRecoveryStrategy.reportNodeId(workerHeartbeats.get_supervisor_id());
}
}
use of org.apache.storm.generated.SupervisorWorkerHeartbeat in project storm by apache.
the class Supervisor method createSupervisorIface.
private org.apache.storm.generated.Supervisor.Iface createSupervisorIface() {
return new org.apache.storm.generated.Supervisor.Iface() {
@Override
public void sendSupervisorAssignments(SupervisorAssignments assignments) throws AuthorizationException, TException {
checkAuthorization("sendSupervisorAssignments");
LOG.info("Got an assignments from master, will start to sync with assignments: {}", assignments);
SynchronizeAssignments syn = new SynchronizeAssignments(getSupervisor(), assignments, getReadClusterState());
getEventManger().add(syn);
}
@Override
public Assignment getLocalAssignmentForStorm(String id) throws NotAliveException, AuthorizationException, TException {
Map<String, Object> topoConf = null;
try {
topoConf = ConfigUtils.readSupervisorStormConf(conf, id);
} catch (IOException e) {
LOG.warn("Topology config is not localized yet...");
}
checkAuthorization(id, topoConf, "getLocalAssignmentForStorm");
Assignment assignment = getStormClusterState().assignmentInfo(id, null);
if (null == assignment) {
throw new WrappedNotAliveException("No local assignment assigned for storm: " + id + " for node: " + getHostName());
}
return assignment;
}
@Override
public void sendSupervisorWorkerHeartbeat(SupervisorWorkerHeartbeat heartbeat) throws AuthorizationException, NotAliveException, TException {
// do nothing except validate heartbeat for now.
String id = heartbeat.get_storm_id();
Map<String, Object> topoConf = null;
try {
topoConf = ConfigUtils.readSupervisorStormConf(conf, id);
} catch (IOException e) {
LOG.warn("Topology config is not localized yet...");
throw new WrappedNotAliveException(id + " does not appear to be alive, you should probably exit");
}
checkAuthorization(id, topoConf, "sendSupervisorWorkerHeartbeat");
}
};
}
use of org.apache.storm.generated.SupervisorWorkerHeartbeat in project storm by apache.
the class ReportWorkerHeartbeats method getSupervisorWorkerHeartbeatsFromLocal.
private SupervisorWorkerHeartbeats getSupervisorWorkerHeartbeatsFromLocal(Map<String, LSWorkerHeartbeat> localHeartbeats) {
SupervisorWorkerHeartbeats supervisorWorkerHeartbeats = new SupervisorWorkerHeartbeats();
List<SupervisorWorkerHeartbeat> heartbeatList = new ArrayList<>();
for (LSWorkerHeartbeat lsWorkerHeartbeat : localHeartbeats.values()) {
// local worker heartbeat can be null cause some error/exception
if (null == lsWorkerHeartbeat) {
continue;
}
SupervisorWorkerHeartbeat supervisorWorkerHeartbeat = new SupervisorWorkerHeartbeat();
supervisorWorkerHeartbeat.set_storm_id(lsWorkerHeartbeat.get_topology_id());
supervisorWorkerHeartbeat.set_executors(lsWorkerHeartbeat.get_executors());
supervisorWorkerHeartbeat.set_time_secs(lsWorkerHeartbeat.get_time_secs());
heartbeatList.add(supervisorWorkerHeartbeat);
}
supervisorWorkerHeartbeats.set_supervisor_id(this.supervisor.getId());
supervisorWorkerHeartbeats.set_worker_heartbeats(heartbeatList);
return supervisorWorkerHeartbeats;
}
Aggregations