Merge "Add SO Catalog DB tables related to WFD"
[so.git] / so-monitoring / so-monitoring-handler / src / main / java / org / onap / so / monitoring / configuration / rest / HttpClientConnectionConfiguration.java
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.so.monitoring.configuration.rest;
21
22 import java.util.concurrent.TimeUnit;
23
24 import org.springframework.beans.factory.annotation.Value;
25 import org.springframework.stereotype.Service;
26
27 @Service
28 public class HttpClientConnectionConfiguration {
29
30     @Value(value = "${rest.http.client.configuration.connTimeOutInSec:10}")
31     private int connectionTimeOutInSeconds;
32
33     @Value(value = "${rest.http.client.configuration.socketTimeOutInSec:180}")
34     private int socketTimeOutInSeconds;
35
36     @Value(value = "${rest.http.client.configuration.socketTimeOutInSec:600}")
37     private int timeToLiveInSeconds;
38
39     @Value(value = "${rest.http.client.configuration.maxConnections:10}")
40     private int maxConnections;
41
42     @Value(value = "${rest.http.client.configuration.maxConnectionsPerRoute:2}")
43     private int maxConnectionsPerRoute;
44
45     /**
46      * @return the socketTimeOut
47      */
48     public int getSocketTimeOutInMiliSeconds() {
49         return (int) TimeUnit.SECONDS.toMillis(socketTimeOutInSeconds);
50     }
51
52     /**
53      * @return the maxConnections
54      */
55     public int getMaxConnections() {
56         return maxConnections;
57     }
58
59     /**
60      * @return the maxConnectionsPerRoute
61      */
62     public int getMaxConnectionsPerRoute() {
63         return maxConnectionsPerRoute;
64     }
65
66     /**
67      * @return the connectionTimeOut
68      */
69     public int getConnectionTimeOutInMilliSeconds() {
70         return (int) TimeUnit.SECONDS.toMillis(connectionTimeOutInSeconds);
71     }
72
73     /**
74      * @return the timeToLive
75      */
76     public int getTimeToLiveInMins() {
77         return (int) TimeUnit.SECONDS.toMinutes(timeToLiveInSeconds);
78     }
79
80     @Override
81     public String toString() {
82         return "HttpClientConnectionConfiguration [connectionTimeOutInSeconds=" + connectionTimeOutInSeconds
83                 + ", socketTimeOutInSeconds=" + socketTimeOutInSeconds + ", timeToLiveInSeconds=" + timeToLiveInSeconds
84                 + ", maxConnections=" + maxConnections + ", maxConnectionsPerRoute=" + maxConnectionsPerRoute + "]";
85     }
86
87 }