Search in sources :

Example 21 with NimbusClient

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);
            }
        }
    }
}
Also used : NimbusClient(org.apache.storm.utils.NimbusClient) SupervisorAssignments(org.apache.storm.generated.SupervisorAssignments) TException(org.apache.storm.thrift.TException)

Aggregations

NimbusClient (org.apache.storm.utils.NimbusClient)21 HashMap (java.util.HashMap)10 IOException (java.io.IOException)8 Map (java.util.Map)7 Nimbus (org.apache.storm.generated.Nimbus)6 TTransportException (org.apache.storm.thrift.transport.TTransportException)6 AuthorizationException (org.apache.storm.generated.AuthorizationException)5 TException (org.apache.storm.thrift.TException)5 PrivilegedActionException (java.security.PrivilegedActionException)4 CommandLine (org.apache.commons.cli.CommandLine)4 CommandLineParser (org.apache.commons.cli.CommandLineParser)4 DefaultParser (org.apache.commons.cli.DefaultParser)4 HelpFormatter (org.apache.commons.cli.HelpFormatter)4 Options (org.apache.commons.cli.Options)4 ParseException (org.apache.commons.cli.ParseException)4 Config (org.apache.storm.Config)4 IAutoCredentials (org.apache.storm.security.auth.IAutoCredentials)4 TopologySummary (org.apache.storm.generated.TopologySummary)3 Test (org.junit.Test)3 FileNotFoundException (java.io.FileNotFoundException)2