@VisibleForTesting public void checkAuthorization(String topoName, Map<String, Object> topoConf, String operation) throws AuthorizationException { checkAuthorization(topoName, topoConf, operation, null); }
@VisibleForTesting public void checkAuthorization(String operation) throws AuthorizationException { checkAuthorization(null, null, operation, null); }
@Override public void sendSupervisorWorkerHeartbeat(SupervisorWorkerHeartbeat heartbeat) throws AuthorizationException, NotAliveException, TException { // do nothing except validate heartbeat for now. String id = heartbeat.get_storm_id(); Map<String, Object> topoConf = null; try { topoConf = ConfigUtils.readSupervisorStormConf(conf, id); } catch (IOException e) { LOG.warn("Topology config is not localized yet..."); throw new WrappedNotAliveException(id + " does not appear to be alive, you should probably exit"); } checkAuthorization(id, topoConf, "sendSupervisorWorkerHeartbeat"); } });
@Override public void sendSupervisorAssignments(SupervisorAssignments assignments) throws AuthorizationException, TException { checkAuthorization("sendSupervisorAssignments"); LOG.info("Got an assignments from master, will start to sync with assignments: {}", assignments); SynchronizeAssignments syn = new SynchronizeAssignments(getSupervisor(), assignments, getReadClusterState()); getEventManger().add(syn); }
@Override public Assignment getLocalAssignmentForStorm(String id) throws NotAliveException, AuthorizationException, TException { Map<String, Object> topoConf = null; try { topoConf = ConfigUtils.readSupervisorStormConf(conf, id); } catch (IOException e) { LOG.warn("Topology config is not localized yet..."); } checkAuthorization(id, topoConf, "getLocalAssignmentForStorm"); Assignment assignment = getStormClusterState().assignmentInfo(id, null); if (null == assignment) { throw new WrappedNotAliveException("No local assignment assigned for storm: " + id + " for node: " + getHostName()); } return assignment; }