Initial OpenECOMP policy/engine commit
[policy/engine.git] / PyPDPServer / src / main / java / org / openecomp / policy / pypdp / jmx / PyPdpMonitor.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.policy.pypdp.jmx;
22
23 import java.util.concurrent.atomic.AtomicLong;
24
25 public class PyPdpMonitor implements PyPdpMonitorMBean {
26         
27         public static PyPdpMonitor singleton = new PyPdpMonitor();
28         
29         private final AtomicLong configCounter;
30         private final AtomicLong eventCounter;
31         private final AtomicLong configPolicyNameCounter;       
32         
33         private PyPdpMonitor() {
34                 this.configCounter = new AtomicLong();
35                 this.eventCounter = new AtomicLong();
36                 this.configPolicyNameCounter = new AtomicLong();
37         }
38         
39         /**
40          * @return the configCounter
41          */
42         public AtomicLong getAtomicConfigCounter() {
43                 return configCounter;
44         }
45         
46         /**
47          * @return the eventCounter
48          */
49         public AtomicLong getAtomicEventCounter() {
50                 return eventCounter;
51         }
52         
53         /**
54          * @return the configPolicyNameCounter
55          */
56         public AtomicLong getAtomicConfigPolicyNameCounter() {
57                 return configPolicyNameCounter;
58         }
59         /**
60          * @return the configCounter
61          */
62         @Override
63         public long getConfigCounter() {
64                 return configCounter.longValue();
65         }
66         
67         /**
68          * @return the eventCounter
69          */
70         @Override
71         public long getEventCounter() {
72                 return eventCounter.longValue();
73         }
74         
75         /**
76          * @return the configPolicyNameCounter
77          */
78         @Override
79         public long getConfigPolicyNameCounter() {
80                 return configPolicyNameCounter.longValue();
81         }
82         
83         @Override
84         public synchronized void resetCounters() {
85                 this.configCounter.set(0);
86                 this.eventCounter.set(0);
87                 this.configPolicyNameCounter.set(0);
88         }
89
90 }