Search in sources :

Example 1 with LSTopoHistory

use of org.apache.storm.generated.LSTopoHistory 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 = ConfigUtils.getTopoLogsUsers(topoConf);
    List<String> groups = ConfigUtils.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)

Example 2 with LSTopoHistory

use of org.apache.storm.generated.LSTopoHistory 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<String> ret = new ArrayList<>();
    for (LSTopoHistory history : state.getTopoHistoryList()) {
        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 3 with LSTopoHistory

use of org.apache.storm.generated.LSTopoHistory in project storm by apache.

the class LocalState method addTopologyHistory.

public void addTopologyHistory(LSTopoHistory lsTopoHistory) {
    LSTopoHistoryList lsTopoHistoryListWrapper = (LSTopoHistoryList) get(LS_TOPO_HISTORY);
    List<LSTopoHistory> currentTopoHistoryList = new ArrayList<>();
    if (null != lsTopoHistoryListWrapper) {
        currentTopoHistoryList.addAll(lsTopoHistoryListWrapper.get_topo_history());
    }
    currentTopoHistoryList.add(lsTopoHistory);
    put(LS_TOPO_HISTORY, new LSTopoHistoryList(currentTopoHistoryList));
}
Also used : ArrayList(java.util.ArrayList) LSTopoHistoryList(org.apache.storm.generated.LSTopoHistoryList) LSTopoHistory(org.apache.storm.generated.LSTopoHistory)

Example 4 with LSTopoHistory

use of org.apache.storm.generated.LSTopoHistory in project storm by apache.

the class LocalState method filterOldTopologies.

/**
     * Remove topologies from local state which are older than cutOffAge.
     * @param cutOffAge
     */
public void filterOldTopologies(long cutOffAge) {
    LSTopoHistoryList lsTopoHistoryListWrapper = (LSTopoHistoryList) get(LS_TOPO_HISTORY);
    List<LSTopoHistory> filteredTopoHistoryList = new ArrayList<>();
    if (null != lsTopoHistoryListWrapper) {
        for (LSTopoHistory topoHistory : lsTopoHistoryListWrapper.get_topo_history()) {
            if (topoHistory.get_time_stamp() > cutOffAge) {
                filteredTopoHistoryList.add(topoHistory);
            }
        }
    }
    put(LS_TOPO_HISTORY, new LSTopoHistoryList(filteredTopoHistoryList));
}
Also used : ArrayList(java.util.ArrayList) LSTopoHistoryList(org.apache.storm.generated.LSTopoHistoryList) LSTopoHistory(org.apache.storm.generated.LSTopoHistory)

Aggregations

LSTopoHistory (org.apache.storm.generated.LSTopoHistory)4 ArrayList (java.util.ArrayList)3 LSTopoHistoryList (org.apache.storm.generated.LSTopoHistoryList)2 LocalState (org.apache.storm.utils.LocalState)2