2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.policy.drools.apps.controlloop.feature.trans;
 
  23 import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
 
  24 import org.onap.policy.controlloop.VirtualControlLoopNotification;
 
  25 import org.onap.policy.drools.features.PolicyControllerFeatureApi;
 
  26 import org.onap.policy.drools.system.PolicyController;
 
  29  * Feature that tracks Transactions by observing Notification Patterns.
 
  31 public class ControlLoopMetricsFeature implements PolicyControllerFeatureApi {
 
  34      * Feature Sequence Priority.
 
  36     public static final int FEATURE_SEQUENCE_PRIORITY = 100000;
 
  39      * Properties Configuration Name.
 
  41     public static final String CONFIGURATION_PROPERTIES_NAME = "feature-controlloop-trans";
 
  44      * Maximum number of transaction cache entries.
 
  46     public static final String CL_CACHE_TRANS_SIZE_PROPERTY = "controlloop.cache.transactions.size";
 
  47     public static final int CL_CACHE_TRANS_SIZE_DEFAULT = 100;
 
  50      * Transaction timeout in minutes.
 
  52     public static final String CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY =
 
  53             "controllop.cache.transactions.timeout.seconds";
 
  54     public static final long CL_CACHE_TRANS_TIMEOUT_SECONDS_DEFAULT = 1L * 60 * 60;
 
  57     public boolean afterShutdown(PolicyController controller) {
 
  62      * Intercept Control Loop Notifications.
 
  64      * @param controller - controller
 
  65      * @param protocol - protocol
 
  66      * @param topic - topic
 
  67      * @param event - event object
 
  68      * @return false do not take ownership else true
 
  71     public boolean beforeDeliver(PolicyController controller, CommInfrastructure protocol, String topic, Object event) {
 
  72         if (event instanceof VirtualControlLoopNotification) {
 
  73             ControlLoopMetricsManager.getManager().transactionEvent(controller, (VirtualControlLoopNotification) event);
 
  76         /* do not take ownership */
 
  81     public int getSequenceNumber() {
 
  82         return FEATURE_SEQUENCE_PRIORITY;