Class MonitoringTree

  • All Implemented Interfaces:
    JsonMonitorable

    public class MonitoringTree
    extends Object
    implements JsonMonitorable
    A hierarchy of JsonMonitorable objects. Allows retrieving the global json representation, or a json representation for a specific entity in the tree. Thread safe.
    Author:
    Eyal Schneider
    • Constructor Detail

      • MonitoringTree

        public MonitoringTree()
    • Method Detail

      • addRoot

        public void addRoot​(String id,
                            JsonMonitorable monitorable)
        Registers a new top level monitored entity.
        Parameters:
        id - The identifier of the monitorable entity. Must not include the following chars: '.', '+', '*', since they have a speciall role in the lookup method.
        monitorable - The monitorable object. The contents of monitorable.getChildren() determines the sub-tree being added.
      • get

        public net.minidev.json.JSONObject get​(String path,
                                               Set<String> excludeSet)
        Parameters:
        path - A path, composed of zero or more dot separated tokens (empty string refers to the root entity), and possibly ending with "!". A token may be simple or special. A simple token is an identifier of a nested monitored entity. A special token is one of "*", "*+" or "{id}+". When these forms are used, the returned json object will maintain the full tree structure, including the root. "*" is used for including all children in some level in the output. "+" is used for including the monitorable's own metrics in that level of the output. When the path ends with "!", it truncates all child nodes of the nodes represented by the last token of the path.
        excludeSet - A set of node names to exclude completely from the output (including their descendants)
        Returns:
        The json representation of the selected entity set. Note that the method is tolerant to non existing paths, and collects only the data that could be found. Null is never returned.
      • get

        public net.minidev.json.JSONObject get​(String path)
        Parameters:
        path - A path, composed of zero or more dot separated tokens (empty string refers to the root entity), and possibly ending with "!". A token may be simple or special. A simple token is an identifier of a nested monitored entity. A special token is one of "*", "*+" or "{id}+". When these forms are used, the returned json object will maintain the full tree structure, including the root. "*" is used for including all children in some level in the output. "+" is used for including the monitorable's own metrics in that level of the output. When the path ends with "!", it truncates all child nodes of the nodes represented by the last token of the path.
        Returns:
        The json representation of the selected entity set. Note that the method is tolerant to non existing paths, and collects only the data that could be found. Null is never returned.
      • getAll

        public net.minidev.json.JSONObject getAll()
        Returns:
        The json representation of the complete tree
      • getInventory

        public net.minidev.json.JSONObject getInventory()
        Returns:
        A json tree with null values as leaves, that represents the structure that can be queried. Any path in this tree can be queried using get(path).
      • getAsJson

        public static net.minidev.json.JSONObject getAsJson​(JsonMonitorable monitorable)
        Parameters:
        monitorable - A monitorable entity
        Returns:
        The full json representation of the entity (including all descendants)
      • getInventory

        public static net.minidev.json.JSONObject getInventory​(JsonMonitorable monitorable)
        Parameters:
        monitorable - A monitorable entity
        Returns:
        A json tree with null values as leaves, that represents the structure that can be queried. Any path in this tree can be queried using get(path).
      • getOwnMetrics

        public net.minidev.json.JSONObject getOwnMetrics()
        Specified by:
        getOwnMetrics in interface JsonMonitorable
        Returns:
        The json string describing the entity, not including the child entities.
      • getChildren

        public Map<String,​JsonMonitorable> getChildren()
        Specified by:
        getChildren in interface JsonMonitorable
        Returns:
        The monitorable children of this entity, as [id, JsonExportable] pairs. Using this method, the framework can manage a complete tree to be monitored, where every entity has a unique path.