2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 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;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
31 * Feature that tracks Transactions by observing Notification Patterns.
33 public class ControlLoopMetricsFeature implements PolicyControllerFeatureAPI {
36 * Feature Sequence Priority
38 public final static int FEATURE_SEQUENCE_PRIORITY = 100000;
41 * Properties Configuration Name
43 public static final String CONFIGURATION_PROPERTIES_NAME = "feature-controlloop-trans";
46 * maximum number of transaction cache entries
48 public static final String CL_CACHE_TRANS_SIZE_PROPERTY = "controlloop.cache.transactions.size";
49 public static final int CL_CACHE_TRANS_SIZE_DEFAULT = 100;
52 * transaction timeout in minutes
54 public static final String CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY =
55 "controllop.cache.transactions.timeout.seconds";
56 public static final long CL_CACHE_TRANS_TIMEOUT_SECONDS_DEFAULT = 1L * 60 * 60;
59 public boolean afterShutdown(PolicyController controller) {
66 private static Logger logger = LoggerFactory.getLogger(ControlLoopMetricsFeature.class);
69 * Intercept Control Loop Notifications
71 * @param controller - controller
72 * @param protocol - protocol
73 * @param topic - topic
74 * @param event - event object
78 public boolean beforeDeliver(PolicyController controller, CommInfrastructure protocol, String topic, Object event) {
79 if (event instanceof VirtualControlLoopNotification) {
80 ControlLoopMetrics.manager.transactionEvent(controller, (VirtualControlLoopNotification) event);
83 /* do not take ownership */
88 public int getSequenceNumber() {
89 return FEATURE_SEQUENCE_PRIORITY;