c93ac8b58b179fb7913ba2bd4c9a5c914494ddd4
[policy/drools-applications.git] / controlloop / common / eventmanager / src / main / java / org / onap / policy / controlloop / ophistory / OperationHistoryDataManagerParams.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2020-2021 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.onap.policy.controlloop.ophistory;
22
23 import lombok.AllArgsConstructor;
24 import lombok.Builder;
25 import lombok.Data;
26 import lombok.NoArgsConstructor;
27 import org.onap.policy.common.parameters.BeanValidator;
28 import org.onap.policy.common.parameters.ValidationResult;
29 import org.onap.policy.common.parameters.annotations.Min;
30 import org.onap.policy.common.parameters.annotations.NotBlank;
31 import org.onap.policy.common.parameters.annotations.NotNull;
32
33 /**
34  * Parameters for a Data Manager.
35  */
36 @NotNull
37 @Data
38 @Builder
39 @NoArgsConstructor
40 @AllArgsConstructor
41 public class OperationHistoryDataManagerParams {
42     public static final String DEFAULT_PU = "OperationsHistoryPU";
43     public static final String DEFAULT_DRIVER = "org.mariadb.jdbc.Driver";
44     public static final String DEFAULT_TYPE = "MySQL";
45
46     @NotBlank
47     private String url;
48     @NotBlank
49     private String userName;
50
51     // may be blank
52     private String password;
53
54     @Builder.Default
55     private String persistenceUnit = DEFAULT_PU;
56
57     @Builder.Default
58     private String driver = DEFAULT_DRIVER;
59
60     @Builder.Default
61     private String dbType = DEFAULT_TYPE;
62
63     /**
64      * Maximum number of records that can be waiting to be inserted into the DB. When the
65      * limit is reached, the oldest records are discarded.
66      */
67     @Min(1)
68     @Builder.Default
69     private int maxQueueLength = 10000;
70
71     /**
72      * Number of records to add the DB in one transaction.
73      */
74     @Min(1)
75     @Builder.Default
76     private int batchSize = 100;
77
78     /**
79      * Validates the parameters.
80      *
81      * @param resultName name of the result
82      *
83      * @return the validation result
84      */
85     public ValidationResult validate(String resultName) {
86         return new BeanValidator().validateTop(resultName, this);
87     }
88 }