20
20
21
21
package com .arangodb .internal .net ;
22
22
23
+ import java .util .Arrays ;
23
24
import java .util .Collection ;
24
25
import java .util .List ;
25
26
27
+ import org .slf4j .Logger ;
28
+ import org .slf4j .LoggerFactory ;
29
+
26
30
import com .arangodb .internal .util .HostUtils ;
27
31
28
32
/**
29
33
* @author Mark Vollmary
30
34
*
31
35
*/
32
36
public class ExtendedHostResolver implements HostResolver {
37
+
38
+ private static final Logger LOGGER = LoggerFactory .getLogger (ExtendedHostResolver .class );
33
39
34
40
private static final long MAX_CACHE_TIME = 60 * 60 * 1000 ;
35
41
private EndpointResolver resolver ;
@@ -54,22 +60,39 @@ public void init(final EndpointResolver resolver) {
54
60
55
61
@ Override
56
62
public List <Host > resolve (final boolean initial , final boolean closeConnections ) {
63
+
57
64
if (!initial && isExpired ()) {
65
+
58
66
lastUpdate = System .currentTimeMillis ();
67
+
59
68
final Collection <String > endpoints = resolver .resolve (closeConnections );
69
+ LOGGER .info ("Resolve " + endpoints .size () + " Endpoints" );
70
+ LOGGER .debug ("Endpoints " + Arrays .deepToString (endpoints .toArray ()));
71
+
72
+
60
73
if (!endpoints .isEmpty ()) {
61
74
hosts .clear ();
62
75
}
76
+
63
77
for (final String endpoint : endpoints ) {
78
+ LOGGER .debug ("Create HOST from " + endpoint );
79
+
64
80
if (endpoint .matches (".*://.+:[0-9]+" )) {
81
+
65
82
final String [] s = endpoint .replaceAll (".*://" , "" ).split (":" );
66
83
if (s .length == 2 ) {
67
84
final HostDescription description = new HostDescription (s [0 ], Integer .valueOf (s [1 ]));
68
85
hosts .add (HostUtils .createHost (description , maxConnections , connectionFactory ));
86
+ } else {
87
+ LOGGER .warn ("Skip Endpoint (Missung Port)" + endpoint );
69
88
}
89
+
90
+ } else {
91
+ LOGGER .warn ("Skip Endpoint (Format)" + endpoint );
70
92
}
71
93
}
72
94
}
95
+
73
96
return hosts ;
74
97
}
75
98
0 commit comments