Search in sources :

Example 1 with HBNodes

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

the class Pacemaker method getAllNodesForPath.

private HBMessage getAllNodesForPath(String path, boolean authenticated) {
    LOG.debug("List all nodes for path {}", path);
    if (authenticated) {
        Set<String> pulseIds = new HashSet<>();
        for (String key : heartbeats.keySet()) {
            String[] replaceStr = key.replaceFirst(path, "").split("/");
            String trimmed = null;
            for (String str : replaceStr) {
                if (!str.equals("")) {
                    trimmed = str;
                    break;
                }
            }
            if (trimmed != null && key.indexOf(path) == 0) {
                pulseIds.add(trimmed);
            }
        }
        HBMessageData hbMessageData = HBMessageData.nodes(new HBNodes(new ArrayList(pulseIds)));
        return new HBMessage(HBServerMessageType.GET_ALL_NODES_FOR_PATH_RESPONSE, hbMessageData);
    } else {
        return notAuthorized();
    }
}
Also used : HBNodes(org.apache.storm.generated.HBNodes) ArrayList(java.util.ArrayList) HBMessageData(org.apache.storm.generated.HBMessageData) HBMessage(org.apache.storm.generated.HBMessage) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 HBMessage (org.apache.storm.generated.HBMessage)1 HBMessageData (org.apache.storm.generated.HBMessageData)1 HBNodes (org.apache.storm.generated.HBNodes)1