Class PolicyMonitorImpl

  • All Implemented Interfaces:
    PolicyMonitor

    @Singleton
    public class PolicyMonitorImpl
    extends Object
    implements PolicyMonitor
    Singleton through which all access to the policy monitoring stores is achieved. This singleton has its own ExecutorService which it uses to ensure that updates (which may block) to the policy's statistics are done in a separate thread. It has one set of stores for each of the two modes that policy can be queried by - Self and Subtree, it also contains a store for the internal (individual privilege) evaluation timings.
    • Constructor Detail

      • PolicyMonitorImpl

        @Inject
        public PolicyMonitorImpl​(@Named("amEntitlements")
                                 Debug debug,
                                 @Named("POLICY_MONITORING_EXECUTOR")
                                 ExecutorService executorService,
                                 org.forgerock.openam.entitlement.monitoring.EvaluationMonitoringStore selfEvaluationMonitoringStore,
                                 EvaluationTimingStore selfEvaluationTimingStore,
                                 org.forgerock.openam.entitlement.monitoring.EvaluationMonitoringStore subtreeEvaluationMonitoringStore,
                                 EvaluationTimingStore subtreeEvaluationTimingStore,
                                 InternalEvaluationTimingStore internalEvaluationTimingStore)
        Guice-powered constructor.
        Parameters:
        debug - Debug instance to use
        executorService - The executor service this module should use when passing off the adding of new data
        selfEvaluationMonitoringStore - Store for the SELF mode evaluation monitoring
        selfEvaluationTimingStore - Store for the SELF mode timing monitoring
        subtreeEvaluationMonitoringStore - Store for the SUBTREE mode evaluation monitoring
        subtreeEvaluationTimingStore - Store for the SELF mode timing monitoring
        internalEvaluationTimingStore - Store for the internal privilege evaluation monitoring
    • Method Detail

      • addEvaluation

        public void addEvaluation​(long duration,
                                  String realm,
                                  String applicationName,
                                  String resourceName,
                                  Subject subject,
                                  PolicyMonitoringType monitoringType)
        Adds an evaluation which should be recorded by the PolicyMonitor. This relates to all policies being applied to a request.
        Specified by:
        addEvaluation in interface PolicyMonitor
        Parameters:
        duration - Total length of time in ms the evaluation took to complete
        realm - Realm in which the evaluation took place
        applicationName - Application name against which the evaluation was made
        resourceName - Resource against which the evaluation was made
        subject - The subject making the evaluation
        monitoringType - Whether the evaluation was of SUBTREE or SELF mode
      • addEvaluation

        public void addEvaluation​(String policyName,
                                  long duration,
                                  String realm,
                                  String applicationName,
                                  String resourceName,
                                  Subject subject)
        Adds an individual, internal evaluation which should be recorded by the PolicyMonitor. This relates to the specific policy being evaluated, and not to all the policies being applied to a request.
        Specified by:
        addEvaluation in interface PolicyMonitor
        duration - Total length of time in ms the evaluation took to complete
        realm - Realm in which the evaluation took place
        applicationName - Application name against which the evaluation was made
        resourceName - Resource against which the evaluation was made
        subject - The subject making the evaluation
      • getEvaluationCumulativeCount

        public long getEvaluationCumulativeCount​(PolicyMonitoringType monitoringType)
        Total number of evaluations which have taken place.
        Specified by:
        getEvaluationCumulativeCount in interface PolicyMonitor
        Parameters:
        monitoringType - SUBTREE or SELF
        Returns:
        The total number of evaluations which have occured
      • getEvaluationMaxRate

        public long getEvaluationMaxRate​(PolicyMonitoringType monitoringType)
        The maximum rate at which evaluations have taken place.
        Specified by:
        getEvaluationMaxRate in interface PolicyMonitor
        Parameters:
        monitoringType - SUBTREE or SELF
        Returns:
        The maximum rate at which evaluations have been performed
      • getEvaluationMinRate

        public long getEvaluationMinRate​(PolicyMonitoringType monitoringType)
        The minimum rate at which evaluations have taken place.
        Specified by:
        getEvaluationMinRate in interface PolicyMonitor
        Parameters:
        monitoringType - SUBTREE or SELF
        Returns:
        The minimum rate at which evaluations have been performed
      • getEvaluationAvgRate

        public long getEvaluationAvgRate​(PolicyMonitoringType monitoringType)
        The average rate at which evaluations have taken place.
        Specified by:
        getEvaluationAvgRate in interface PolicyMonitor
        Parameters:
        monitoringType - SUBTREE or SELF
        Returns:
        The average rate at which evaluations have been performed
      • getSlowestEvaluation

        public String getSlowestEvaluation​(PolicyMonitoringType monitoringType)
        Returns information on the slowest performing evaluation.
        Specified by:
        getSlowestEvaluation in interface PolicyMonitor
        Parameters:
        monitoringType - SUBTREE or SELF
        Returns:
        information on the slowest performing evaluation
      • getAverageEvaluationTime

        public long getAverageEvaluationTime​(PolicyMonitoringType monitoringType)
        Average length of time an evaluation takes to complete.
        Specified by:
        getAverageEvaluationTime in interface PolicyMonitor
        Parameters:
        monitoringType - SUBTREE or SELF
        Returns:
        The average length of time it takes to complete an evaluation in ms
      • getSlowestInternalEvaluation

        public String getSlowestInternalEvaluation()
        Returns the slowest individual policy evaluation.
        Specified by:
        getSlowestInternalEvaluation in interface PolicyMonitor
        Returns:
        information on the slowest performing policy evaluation
      • getSlowestEvaluationDuration

        protected long getSlowestEvaluationDuration​(PolicyMonitoringType monitoringType)
        Exposed for ease-of-testing.
        Parameters:
        monitoringType - Mode of operation to return duration for
        Returns:
        duration of the longest operation, in ms