1616 * default.
1717 */
1818final class DefaultBuilderConfig {
19+ private static final Config conf = ConfigFactory .load ();
1920
2021 private DefaultBuilderConfig () {}
2122
23+ static boolean isSslDisabled () {
24+ return conf .hasPath ("proteus.client.ssl.disabled" )
25+ && conf .getBoolean ("proteus.client.ssl.disabled" );
26+ }
27+
2228 static boolean getKeepAlive () {
2329 boolean keepalive = false ;
2430 try {
25- keepalive = ConfigHolder . conf .getBoolean ("proteus.client.keepalive.enable" );
31+ keepalive = conf .getBoolean ("proteus.client.keepalive.enable" );
2632 } catch (ConfigException .Missing m ) {
2733
2834 }
@@ -33,7 +39,7 @@ static boolean getKeepAlive() {
3339 static long getTickPeriodSeconds () {
3440 long tickPeriodSeconds = 60 ;
3541 try {
36- tickPeriodSeconds = ConfigHolder . conf .getLong ("proteus.client.keepalive.tickPeriodSeconds" );
42+ tickPeriodSeconds = conf .getLong ("proteus.client.keepalive.tickPeriodSeconds" );
3743 } catch (ConfigException .Missing m ) {
3844
3945 }
@@ -44,7 +50,7 @@ static long getTickPeriodSeconds() {
4450 static long getAckTimeoutSeconds () {
4551 long ackTimeoutSeconds = 120 ;
4652 try {
47- ackTimeoutSeconds = ConfigHolder . conf .getLong ("proteus.client.keepalive.ackTimeoutSeconds" );
53+ ackTimeoutSeconds = conf .getLong ("proteus.client.keepalive.ackTimeoutSeconds" );
4854 } catch (ConfigException .Missing m ) {
4955
5056 }
@@ -55,7 +61,7 @@ static long getAckTimeoutSeconds() {
5561 static int getMissedAcks () {
5662 int missedAcks = 3 ;
5763 try {
58- missedAcks = ConfigHolder . conf .getInt ("proteus.client.keepalive.missedAcks" );
64+ missedAcks = conf .getInt ("proteus.client.keepalive.missedAcks" );
5965 } catch (ConfigException .Missing m ) {
6066 }
6167
@@ -65,7 +71,7 @@ static int getMissedAcks() {
6571 static String getHost () {
6672 String host = null ;
6773 try {
68- host = ConfigHolder . conf .getString ("proteus.client.host" );
74+ host = conf .getString ("proteus.client.host" );
6975 } catch (ConfigException .Missing m ) {
7076
7177 }
@@ -76,7 +82,7 @@ static String getHost() {
7682 static int getPort () {
7783 int port = 8001 ;
7884 try {
79- port = ConfigHolder . conf .getInt ("proteus.client.port" );
85+ port = conf .getInt ("proteus.client.port" );
8086 } catch (ConfigException .Missing m ) {
8187
8288 }
@@ -87,7 +93,7 @@ static int getPort() {
8793 static String getGroup () {
8894 String group = null ;
8995 try {
90- group = ConfigHolder . conf .getString ("proteus.client.group" );
96+ group = conf .getString ("proteus.client.group" );
9197 } catch (ConfigException .Missing m ) {
9298
9399 }
@@ -98,7 +104,7 @@ static String getGroup() {
98104 static String getDestination () {
99105 String destination = null ;
100106 try {
101- destination = ConfigHolder . conf .getString ("proteus.client.destination" );
107+ destination = conf .getString ("proteus.client.destination" );
102108 } catch (ConfigException .Missing m ) {
103109
104110 }
@@ -110,7 +116,7 @@ static Long getAccountId() {
110116 Long accountId = null ;
111117
112118 try {
113- accountId = ConfigHolder . conf .getLong ("proteus.client.accountId" );
119+ accountId = conf .getLong ("proteus.client.accountId" );
114120 } catch (ConfigException .Missing m ) {
115121
116122 }
@@ -122,7 +128,7 @@ static Long getAccessKey() {
122128 Long accessKey = null ;
123129
124130 try {
125- accessKey = ConfigHolder . conf .getLong ("proteus.client.accessKey" );
131+ accessKey = conf .getLong ("proteus.client.accessKey" );
126132 } catch (ConfigException .Missing m ) {
127133
128134 }
@@ -134,7 +140,7 @@ static String getAccessToken() {
134140 String accessToken = null ;
135141
136142 try {
137- accessToken = ConfigHolder . conf .getString ("proteus.client.accessToken" );
143+ accessToken = conf .getString ("proteus.client.accessToken" );
138144 } catch (ConfigException .Missing m ) {
139145
140146 }
@@ -145,7 +151,7 @@ static String getAccessToken() {
145151 static int getPoolSize () {
146152 int poolSize = Math .min (4 , Runtime .getRuntime ().availableProcessors ());
147153 try {
148- poolSize = ConfigHolder . conf .getInt ("proteus.client.poolSize" );
154+ poolSize = conf .getInt ("proteus.client.poolSize" );
149155 } catch (ConfigException .Missing m ) {
150156 }
151157 return poolSize ;
@@ -154,7 +160,7 @@ static int getPoolSize() {
154160 static int getMinHostsAtStartup () {
155161 int minHostsAtStartup = 3 ;
156162 try {
157- minHostsAtStartup = ConfigHolder . conf .getInt ("proteus.client.minHostsAtStartup" );
163+ minHostsAtStartup = conf .getInt ("proteus.client.minHostsAtStartup" );
158164 } catch (ConfigException .Missing m ) {
159165 }
160166 return minHostsAtStartup ;
@@ -165,7 +171,7 @@ static long getMinHostsAtStartupTimeoutSeconds() {
165171
166172 try {
167173 minHostsAtStartupTimeout =
168- ConfigHolder . conf .getLong ("proteus.client.minHostsAtStartupTimeout" );
174+ conf .getLong ("proteus.client.minHostsAtStartupTimeout" );
169175 } catch (ConfigException .Missing m ) {
170176 }
171177 return minHostsAtStartupTimeout ;
@@ -175,7 +181,7 @@ static String getMetricHandlerGroup() {
175181 String metricHandlerGroup = "netifi.metrics" ;
176182 try {
177183 metricHandlerGroup =
178- ConfigHolder . conf .getString ("proteus.client.metrics.group" );
184+ conf .getString ("proteus.client.metrics.group" );
179185 } catch (ConfigException .Missing m ) {
180186 }
181187 return metricHandlerGroup ;
@@ -186,7 +192,7 @@ static int getBatchSize() {
186192
187193 try {
188194 batchSize =
189- ConfigHolder . conf .getInt ("proteus.client.metrics.metricBatchSize" );
195+ conf .getInt ("proteus.client.metrics.metricBatchSize" );
190196 } catch (ConfigException .Missing m ) {
191197 }
192198 return batchSize ;
@@ -197,7 +203,7 @@ static long getExportFrequencySeconds() {
197203
198204 try {
199205 exportFrequencySeconds =
200- ConfigHolder . conf .getLong ("proteus.client.metrics.frequency" );
206+ conf .getLong ("proteus.client.metrics.frequency" );
201207 } catch (ConfigException .Missing m ) {
202208 }
203209 return exportFrequencySeconds ;
@@ -209,7 +215,7 @@ static boolean getExportSystemMetrics() {
209215
210216 try {
211217 exportSystemMetrics =
212- ConfigHolder . conf .getBoolean ("proteus.client.metrics.exportSystemMetrics" );
218+ conf .getBoolean ("proteus.client.metrics.exportSystemMetrics" );
213219 } catch (ConfigException .Missing m ) {
214220 }
215221 return exportSystemMetrics ;
@@ -219,7 +225,7 @@ static boolean getExportSystemMetrics() {
219225 static List <SocketAddress > getSeedAddress () {
220226 List <SocketAddress > seedAddresses = null ;
221227 try {
222- String s = ConfigHolder . conf .getString ("proteus.client.seedAddresses" );
228+ String s = conf .getString ("proteus.client.seedAddresses" );
223229 if (s != null ) {
224230 seedAddresses = new ArrayList <>();
225231 String [] split = s .split ("," );
@@ -244,12 +250,4 @@ static List<SocketAddress> getSeedAddress() {
244250
245251 return seedAddresses ;
246252 }
247-
248- private static class ConfigHolder {
249- private static final Config conf ;
250-
251- static {
252- conf = ConfigFactory .load ();
253- }
254- }
255253}
0 commit comments