use of org.apache.storm.generated.SupervisorAssignments in project storm by apache.
the class SynchronizeAssignments method getAssignmentsFromMasterUntilSuccess.
/**
* Used by {@link Supervisor} to fetch assignments when start up.
* @param supervisor {@link Supervisor}
*/
public void getAssignmentsFromMasterUntilSuccess(Supervisor supervisor) {
boolean success = false;
while (!success) {
try (NimbusClient master = NimbusClient.getConfiguredClient(supervisor.getConf())) {
SupervisorAssignments assignments = master.getClient().getSupervisorAssignments(supervisor.getAssignmentId());
assignedAssignmentsToLocal(supervisor.getStormClusterState(), Collections.singletonList(assignments));
success = true;
} catch (Exception t) {
// just ignore the exception
}
if (!success) {
LOG.info("Waiting for a success sync of assignments from master...");
try {
Time.sleep(5000L);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
}
use of org.apache.storm.generated.SupervisorAssignments in project storm by apache.
the class Nimbus method getSupervisorAssignments.
@Override
public SupervisorAssignments getSupervisorAssignments(String nodeId) throws AuthorizationException, TException {
checkAuthorization(null, null, "getSupervisorAssignments");
try {
if (isLeader() && isAssignmentsRecovered()) {
SupervisorAssignments supervisorAssignments = new SupervisorAssignments();
supervisorAssignments.set_storm_assignment(assignmentsForNodeId(stormClusterState.assignmentsInfo(), nodeId));
return supervisorAssignments;
}
} catch (Exception e) {
LOG.debug("Exception when node {} fetching assignments", nodeId);
if (e instanceof TException) {
throw (TException) e;
}
// When this master is not leader and get a sync request from node,
// just return nil which will cause client/node to get an unknown error,
// the node/supervisor will sync it as a timer task.
LOG.debug("Exception when node {} fetching assignments", nodeId);
}
return null;
}
Aggregations