protected Map<String, Assignment> getAssignmentsSnapshot(IStormClusterState stormClusterState) throws Exception { return stormClusterState.assignmentsInfo(); }
/** * Decide if the heartbeats is recovered for a master, will wait for all the assignments nodes to recovery, every node will take care * its node heartbeats reporting. * * @return true if all nodes have reported heartbeats or exceeds max-time-out */ private boolean isHeartbeatsRecovered() { if (heartbeatsReadyFlag.get()) { return true; } Set<String> allNodes = new HashSet<>(); for (Map.Entry<String, Assignment> assignmentEntry : stormClusterState.assignmentsInfo().entrySet()) { allNodes.addAll(assignmentEntry.getValue().get_node_host().keySet()); } boolean isReady = heartbeatsRecoveryStrategy.isReady(allNodes); if (isReady) { heartbeatsReadyFlag.getAndSet(true); } return isReady; }
@Override public void run(String[] args, Map<String, Object> conf, String command) throws Exception { IStormClusterState stormClusterState = ClusterUtils.mkStormClusterState(conf, new ClusterStateContext(DaemonType.NIMBUS, conf)); stormClusterState.syncRemoteAssignments(null); stormClusterState.syncRemoteIds(null); stormClusterState.setAssignmentsBackendSynchronized(); Map<String, Assignment> infos = stormClusterState.assignmentsInfo(); if (args.length <= 0) { for (Map.Entry<String, Assignment> entry: infos.entrySet()) { System.out.println(entry.getKey() + ":"); System.out.println(prettyPrint(entry.getValue())); } } else { for (String arg : args) { System.out.println(arg + ":"); System.out.println(prettyPrint(infos.get(arg))); } } }
private static void notifySupervisorsAsKilled(IStormClusterState clusterState, Assignment oldAss, AssignmentDistributionService service) { Map<String, String> nodeHost = assignmentChangedNodes(oldAss, null); notifySupervisorsAssignments(clusterState.assignmentsInfo(), service, nodeHost, basicSupervisorDetailsMap(clusterState)); }
Map<String, Assignment> topoToAssignment = state.assignmentsInfo(); for (String sid : supervisorIds) { SupervisorInfo info = superInfos.get(sid);
@Override public SupervisorAssignments getSupervisorAssignments(String node) throws AuthorizationException, TException { checkAuthorization(null, null, "getSupervisorAssignments"); try { if (isLeader() && isAssignmentsRecovered()) { SupervisorAssignments supervisorAssignments = new SupervisorAssignments(); supervisorAssignments.set_storm_assignment(assignmentsForNode(stormClusterState.assignmentsInfo(), node)); return supervisorAssignments; } } catch (Exception e) { LOG.debug("Exception when node {} fetching assignments", node); 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", node); } return null; }
checkAuthorization(null, null, "getOwnerResourceSummaries"); IStormClusterState state = stormClusterState; Map<String, Assignment> topoIdToAssignments = state.assignmentsInfo(); Map<String, StormBase> topoIdToBases = state.topologyBases(); Map<String, Number> clusterSchedulerConfig = scheduler.config();