Class Tree

  • Direct Known Subclasses:
    Tree.Leaf, Tree.Node

    public abstract class Tree
    extends java.lang.Object
    Represents a decision tree for classifying flows.

    The tree consists of nested nodes that define thresholds for various aspects of flows (e.g. source ports or destination addresses) and leaves that contain an ordered lists of classifiers. When a classification request is processed it is compared to thresholds and traversal continues in subtrees corresponding to the comparison result.

    A special twist is that classification rules and classification requests may not contain a value for certain aspects. For example a classification rule may have no ports being set or a classification request may be missing protocol information. This is handled by having child nodes for 'non-applicable' rules and considering 'non-applicable' orderings when comparing a classification request with thresholds (cf. Threshold.compare(ClassificationRequest)).

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Tree.Info
      Collects statistical information about a decision tree.
      static class  Tree.Leaf  
      static class  Tree.Node  
      static interface  Tree.Visitor<T>  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Tree​(Tree.Info info)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract <T> T accept​(Tree.Visitor<T> visitor)  
      protected abstract org.opennms.netmgt.flows.classification.internal.decision.Tree.Classifiers classifiers​(ClassificationRequest request)  
      java.lang.String classify​(ClassificationRequest request)
      Classifies a flow.
      protected abstract boolean isEmpty()  
      static org.opennms.netmgt.flows.classification.internal.decision.Tree.Classifiers merge​(org.opennms.netmgt.flows.classification.internal.decision.Tree.Classifiers i1, org.opennms.netmgt.flows.classification.internal.decision.Tree.Classifiers i2)  
      static Tree of​(java.util.List<PreprocessedRule> rules, FilterService filterService)
      Recursively constructs a decision tree consisting of nodes that split the given rules by thresholds and leaves that contain the classifiers that were selected by the thresholds of their ancestor nodes.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EMPTY

        public static final Tree EMPTY
    • Constructor Detail

    • Method Detail

      • of

        public static Tree of​(java.util.List<PreprocessedRule> rules,
                              FilterService filterService)
                       throws java.lang.InterruptedException
        Recursively constructs a decision tree consisting of nodes that split the given rules by thresholds and leaves that contain the classifiers that were selected by the thresholds of their ancestor nodes.
        Throws:
        java.lang.InterruptedException
      • classify

        public final java.lang.String classify​(ClassificationRequest request)
        Classifies a flow.

        Recursively traverses the decision tree and collects applicable classifiers. The collected classifiers are sorted by their priorities and the result of the first matching classifier is returned. In case that several classifiers with the maximum priority match more specific classifiers (i.e. classifiers that consider more aspects of flows) are prefered.

        Returns:
        Returns null if the request does not match a rule
      • accept

        public abstract <T> T accept​(Tree.Visitor<T> visitor)
      • isEmpty

        protected abstract boolean isEmpty()
      • classifiers

        protected abstract org.opennms.netmgt.flows.classification.internal.decision.Tree.Classifiers classifiers​(ClassificationRequest request)
        Returns:
        matching classifiers or null
      • merge

        public static org.opennms.netmgt.flows.classification.internal.decision.Tree.Classifiers merge​(org.opennms.netmgt.flows.classification.internal.decision.Tree.Classifiers i1,
                                                                                                       org.opennms.netmgt.flows.classification.internal.decision.Tree.Classifiers i2)