Search in sources :

Example 26 with LocalState

use of org.apache.storm.utils.LocalState in project storm by apache.

the class Nimbus method readTopologyHistory.

private List<String> readTopologyHistory(String user, Collection<String> adminUsers) throws IOException {
    LocalState state = topologyHistoryState;
    List<LSTopoHistory> topoHistoryList = state.getTopoHistoryList();
    if (topoHistoryList == null || topoHistoryList.isEmpty()) {
        return Collections.emptyList();
    }
    List<String> ret = new ArrayList<>();
    for (LSTopoHistory history : topoHistoryList) {
        if (// Security off
        user == null || // is admin
        adminUsers.contains(user) || // is in allowed group
        isUserPartOf(user, history.get_groups()) || history.get_users().contains(user)) {
            // is an allowed user
            ret.add(history.get_topology_id());
        }
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) LocalState(org.apache.storm.utils.LocalState) LSTopoHistory(org.apache.storm.generated.LSTopoHistory)

Example 27 with LocalState

use of org.apache.storm.utils.LocalState in project storm by apache.

the class Nimbus method addTopoToHistoryLog.

private void addTopoToHistoryLog(String topoId, Map<String, Object> topoConf) {
    LOG.info("Adding topo to history log: {}", topoId);
    LocalState state = topologyHistoryState;
    List<String> users = ServerConfigUtils.getTopoLogsUsers(topoConf);
    List<String> groups = ServerConfigUtils.getTopoLogsGroups(topoConf);
    synchronized (topologyHistoryLock) {
        state.addTopologyHistory(new LSTopoHistory(topoId, Time.currentTimeSecs(), users, groups));
    }
}
Also used : LocalState(org.apache.storm.utils.LocalState) LSTopoHistory(org.apache.storm.generated.LSTopoHistory)

Aggregations

LocalState (org.apache.storm.utils.LocalState)27 Test (org.junit.Test)20 StormMetricsRegistry (org.apache.storm.metric.StormMetricsRegistry)17 LocalAssignment (org.apache.storm.generated.LocalAssignment)16 HashMap (java.util.HashMap)10 LSWorkerHeartbeat (org.apache.storm.generated.LSWorkerHeartbeat)9 DynamicState (org.apache.storm.daemon.supervisor.Slot.DynamicState)8 StaticState (org.apache.storm.daemon.supervisor.Slot.StaticState)8 ExecutorInfo (org.apache.storm.generated.ExecutorInfo)8 AsyncLocalizer (org.apache.storm.localizer.AsyncLocalizer)8 BlobChangingCallback (org.apache.storm.localizer.BlobChangingCallback)8 ISupervisor (org.apache.storm.scheduler.ISupervisor)8 SimulatedTime (org.apache.storm.utils.Time.SimulatedTime)8 File (java.io.File)6 ResourceIsolationInterface (org.apache.storm.container.ResourceIsolationInterface)4 MockResourceIsolationManager (org.apache.storm.daemon.supervisor.ContainerTest.MockResourceIsolationManager)4 GlobalStreamId (org.apache.storm.generated.GlobalStreamId)3 StormTopology (org.apache.storm.generated.StormTopology)3 TmpPath (org.apache.storm.testing.TmpPath)3 IOException (java.io.IOException)2