Search in sources :

Example 1 with SupervisorWorkerHeartbeat

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;
}
Also used : ExecutorInfo(org.apache.storm.generated.ExecutorInfo) SupervisorWorkerHeartbeat(org.apache.storm.generated.SupervisorWorkerHeartbeat)

Example 2 with 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());
    }
}
Also used : SupervisorWorkerHeartbeat(org.apache.storm.generated.SupervisorWorkerHeartbeat) WorkerMetricPoint(org.apache.storm.generated.WorkerMetricPoint) DataPoint(org.apache.storm.metric.api.DataPoint)

Example 3 with SupervisorWorkerHeartbeat

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");
        }
    };
}
Also used : Assignment(org.apache.storm.generated.Assignment) LocalAssignment(org.apache.storm.generated.LocalAssignment) SynchronizeAssignments(org.apache.storm.daemon.supervisor.timer.SynchronizeAssignments) SupervisorWorkerHeartbeat(org.apache.storm.generated.SupervisorWorkerHeartbeat) IOException(java.io.IOException) SupervisorAssignments(org.apache.storm.generated.SupervisorAssignments) WrappedNotAliveException(org.apache.storm.utils.WrappedNotAliveException)

Example 4 with SupervisorWorkerHeartbeat

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;
}
Also used : LSWorkerHeartbeat(org.apache.storm.generated.LSWorkerHeartbeat) SupervisorWorkerHeartbeats(org.apache.storm.generated.SupervisorWorkerHeartbeats) SupervisorWorkerHeartbeat(org.apache.storm.generated.SupervisorWorkerHeartbeat) ArrayList(java.util.ArrayList)

Aggregations

SupervisorWorkerHeartbeat (org.apache.storm.generated.SupervisorWorkerHeartbeat)4 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 SynchronizeAssignments (org.apache.storm.daemon.supervisor.timer.SynchronizeAssignments)1 Assignment (org.apache.storm.generated.Assignment)1 ExecutorInfo (org.apache.storm.generated.ExecutorInfo)1 LSWorkerHeartbeat (org.apache.storm.generated.LSWorkerHeartbeat)1 LocalAssignment (org.apache.storm.generated.LocalAssignment)1 SupervisorAssignments (org.apache.storm.generated.SupervisorAssignments)1 SupervisorWorkerHeartbeats (org.apache.storm.generated.SupervisorWorkerHeartbeats)1 WorkerMetricPoint (org.apache.storm.generated.WorkerMetricPoint)1 DataPoint (org.apache.storm.metric.api.DataPoint)1 WrappedNotAliveException (org.apache.storm.utils.WrappedNotAliveException)1