use of org.apache.storm.utils.NimbusClient 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);
}
}
}
}
Aggregations