Search in sources :

Example 1 with SynchronizeAssignments

use of org.apache.storm.daemon.supervisor.timer.SynchronizeAssignments 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 2 with SynchronizeAssignments

use of org.apache.storm.daemon.supervisor.timer.SynchronizeAssignments in project storm by apache.

the class Supervisor method sendSupervisorAssignments.

/**
 * Used for local cluster assignments distribution.
 *
 * @param assignments {@link SupervisorAssignments}
 */
public void sendSupervisorAssignments(SupervisorAssignments assignments) {
    // for local test
    if (Time.isSimulating() && !(Boolean) conf.get(DaemonConfig.SUPERVISOR_ENABLE)) {
        return;
    }
    SynchronizeAssignments syn = new SynchronizeAssignments(this, assignments, readState);
    eventManager.add(syn);
}
Also used : SynchronizeAssignments(org.apache.storm.daemon.supervisor.timer.SynchronizeAssignments)

Example 3 with SynchronizeAssignments

use of org.apache.storm.daemon.supervisor.timer.SynchronizeAssignments in project storm by apache.

the class Supervisor method launch.

/**
 * Launch the supervisor.
 */
public void launch() throws Exception {
    LOG.info("Starting Supervisor with conf {}", ConfigUtils.maskPasswords(conf));
    String path = ServerConfigUtils.supervisorTmpDir(conf);
    FileUtils.cleanDirectory(new File(path));
    SupervisorHeartbeat hb = new SupervisorHeartbeat(conf, this);
    hb.run();
    // should synchronize supervisor so it doesn't launch anything after being down (optimization)
    Integer heartbeatFrequency = ObjectReader.getInt(conf.get(DaemonConfig.SUPERVISOR_HEARTBEAT_FREQUENCY_SECS));
    heartbeatTimer.scheduleRecurring(0, heartbeatFrequency, hb);
    this.eventManager = new EventManagerImp(false);
    this.readState = new ReadClusterState(this);
    asyncLocalizer.start();
    if ((Boolean) conf.get(DaemonConfig.SUPERVISOR_ENABLE)) {
        // This isn't strictly necessary, but it doesn't hurt and ensures that the machine stays up
        // to date even if callbacks don't all work exactly right
        eventTimer.scheduleRecurring(0, 10, new EventManagerPushCallback(new SynchronizeAssignments(this, null, readState), eventManager));
        // supervisor health check
        eventTimer.scheduleRecurring(30, 30, new SupervisorHealthCheck(this));
    }
    ReportWorkerHeartbeats reportWorkerHeartbeats = new ReportWorkerHeartbeats(conf, this);
    Integer workerHeartbeatFrequency = ObjectReader.getInt(conf.get(Config.WORKER_HEARTBEAT_FREQUENCY_SECS));
    workerHeartbeatTimer.scheduleRecurring(0, workerHeartbeatFrequency, reportWorkerHeartbeats);
    LOG.info("Starting supervisor with id {} at host {}.", getId(), getHostName());
}
Also used : ReportWorkerHeartbeats(org.apache.storm.daemon.supervisor.timer.ReportWorkerHeartbeats) SynchronizeAssignments(org.apache.storm.daemon.supervisor.timer.SynchronizeAssignments) SupervisorHeartbeat(org.apache.storm.daemon.supervisor.timer.SupervisorHeartbeat) EventManagerImp(org.apache.storm.event.EventManagerImp) SupervisorHealthCheck(org.apache.storm.daemon.supervisor.timer.SupervisorHealthCheck) File(java.io.File)

Aggregations

SynchronizeAssignments (org.apache.storm.daemon.supervisor.timer.SynchronizeAssignments)3 File (java.io.File)1 IOException (java.io.IOException)1 ReportWorkerHeartbeats (org.apache.storm.daemon.supervisor.timer.ReportWorkerHeartbeats)1 SupervisorHealthCheck (org.apache.storm.daemon.supervisor.timer.SupervisorHealthCheck)1 SupervisorHeartbeat (org.apache.storm.daemon.supervisor.timer.SupervisorHeartbeat)1 EventManagerImp (org.apache.storm.event.EventManagerImp)1 Assignment (org.apache.storm.generated.Assignment)1 LocalAssignment (org.apache.storm.generated.LocalAssignment)1 SupervisorAssignments (org.apache.storm.generated.SupervisorAssignments)1 SupervisorWorkerHeartbeat (org.apache.storm.generated.SupervisorWorkerHeartbeat)1 WrappedNotAliveException (org.apache.storm.utils.WrappedNotAliveException)1