Merge "add unit test for pdpstatistics provider"
[policy/models.git] / models-pdp / src / main / java / org / onap / policy / models / pdp / concepts / PdpStatistics.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2019 Nordix Foundation.
4  *  Modifications Copyright (C) 2019 AT&T Intellectual Property.
5  *  Modifications Copyright (C) 2020 Nordix Foundation.
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  *
19  * SPDX-License-Identifier: Apache-2.0
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.policy.models.pdp.concepts;
24
25 import java.util.Date;
26 import java.util.List;
27 import lombok.Data;
28 import lombok.NoArgsConstructor;
29 import lombok.NonNull;
30 import org.onap.policy.models.base.PfUtils;
31
32 /**
33  * Class to represent statistics of a running PDP.
34  *
35  * @author Ram Krishna Verma (ram.krishna.verma@est.tech)
36  */
37 @Data
38 @NoArgsConstructor
39 public class PdpStatistics {
40
41     private String pdpInstanceId;
42     private Date timeStamp;
43     private String pdpGroupName;
44     private String pdpSubGroupName;
45     private long policyDeployCount;
46     private long policyDeploySuccessCount;
47     private long policyDeployFailCount;
48     private long policyExecutedCount;
49     private long policyExecutedSuccessCount;
50     private long policyExecutedFailCount;
51     private List<PdpEngineWorkerStatistics> engineStats;
52
53     /**
54      * Constructs the object, making a deep copy.
55      *
56      * @param source source from which to copy
57      */
58     public PdpStatistics(@NonNull PdpStatistics source) {
59         this.pdpInstanceId = source.pdpInstanceId;
60         this.timeStamp = source.timeStamp == null ? null : new Date(source.timeStamp.getTime());
61         this.pdpGroupName = source.pdpGroupName;
62         this.pdpSubGroupName = source.pdpSubGroupName;
63         this.policyDeployCount = source.policyDeployCount;
64         this.policyDeployFailCount = source.policyDeployFailCount;
65         this.policyDeploySuccessCount = source.policyDeploySuccessCount;
66         this.policyExecutedCount = source.policyExecutedCount;
67         this.policyExecutedFailCount = source.policyExecutedFailCount;
68         this.policyExecutedSuccessCount = source.policyExecutedSuccessCount;
69         this.engineStats = PfUtils.mapList(source.engineStats, PdpEngineWorkerStatistics::new, null);
70     }
71
72 }