Search in sources :

Example 6 with SupervisorAssignments

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

Example 7 with SupervisorAssignments

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;
}
Also used : TException(org.apache.storm.thrift.TException) SupervisorAssignments(org.apache.storm.generated.SupervisorAssignments) WrappedAuthorizationException(org.apache.storm.utils.WrappedAuthorizationException) IOException(java.io.IOException) IllegalStateException(org.apache.storm.generated.IllegalStateException) AlreadyAliveException(org.apache.storm.generated.AlreadyAliveException) WrappedNotAliveException(org.apache.storm.utils.WrappedNotAliveException) WrappedInvalidTopologyException(org.apache.storm.utils.WrappedInvalidTopologyException) AuthorizationException(org.apache.storm.generated.AuthorizationException) NotAliveException(org.apache.storm.generated.NotAliveException) WrappedAlreadyAliveException(org.apache.storm.utils.WrappedAlreadyAliveException) InterruptedIOException(java.io.InterruptedIOException) KeyAlreadyExistsException(org.apache.storm.generated.KeyAlreadyExistsException) TException(org.apache.storm.thrift.TException) WrappedIllegalStateException(org.apache.storm.utils.WrappedIllegalStateException) KeyNotFoundException(org.apache.storm.generated.KeyNotFoundException) InvalidTopologyException(org.apache.storm.generated.InvalidTopologyException) BindException(java.net.BindException)

Aggregations

SupervisorAssignments (org.apache.storm.generated.SupervisorAssignments)7 HashMap (java.util.HashMap)3 Map (java.util.Map)3 TException (org.apache.storm.thrift.TException)3 IOException (java.io.IOException)2 Assignment (org.apache.storm.generated.Assignment)2 NimbusClient (org.apache.storm.utils.NimbusClient)2 WrappedNotAliveException (org.apache.storm.utils.WrappedNotAliveException)2 InterruptedIOException (java.io.InterruptedIOException)1 BindException (java.net.BindException)1 ArrayList (java.util.ArrayList)1 NavigableMap (java.util.NavigableMap)1 SynchronizeAssignments (org.apache.storm.daemon.supervisor.timer.SynchronizeAssignments)1 AlreadyAliveException (org.apache.storm.generated.AlreadyAliveException)1 AuthorizationException (org.apache.storm.generated.AuthorizationException)1 IllegalStateException (org.apache.storm.generated.IllegalStateException)1 InvalidTopologyException (org.apache.storm.generated.InvalidTopologyException)1 KeyAlreadyExistsException (org.apache.storm.generated.KeyAlreadyExistsException)1 KeyNotFoundException (org.apache.storm.generated.KeyNotFoundException)1 LocalAssignment (org.apache.storm.generated.LocalAssignment)1