11
11
import java .net .URL ;
12
12
import java .net .URLEncoder ;
13
13
import java .util .Set ;
14
+
14
15
public class DefaultNSQLookup implements NSQLookup {
15
16
Set <String > addresses = Sets .newHashSet ();
16
17
@@ -32,20 +33,20 @@ public Set<ServerAddress> lookup(String topic) {
32
33
ObjectMapper mapper = new ObjectMapper ();
33
34
String topicEncoded = URLEncoder .encode (topic , Charsets .UTF_8 .name ());
34
35
JsonNode jsonNode = mapper .readTree (new URL (addr + "/lookup?topic=" + topicEncoded ));
35
- LogManager .getLogger (this ).debug ("Server connection information: " + jsonNode . toString () );
36
+ LogManager .getLogger (this ).debug ("Server connection information: {}" , jsonNode );
36
37
JsonNode producers = jsonNode .get ("data" ).get ("producers" );
37
38
for (JsonNode node : producers ) {
38
39
String host = node .get ("broadcast_address" ).asText ();
39
40
ServerAddress address = new ServerAddress (host , node .get ("tcp_port" ).asInt ());
40
41
addresses .add (address );
41
42
}
42
43
} catch (IOException e ) {
43
- LogManager .getLogger (this ).warn ("Unable to connect to address {}" , addr );
44
+ LogManager .getLogger (this ).warn ("Unable to connect to address {} for topic {} " , addr , topic );
44
45
LogManager .getLogger (this ).debug (e .getMessage ());
45
46
}
46
47
}
47
48
if (addresses .isEmpty ()) {
48
- LogManager .getLogger (this ).warn ("Unable to connect to any NSQ Lookup servers, servers tried: " + this .addresses . toString () );
49
+ LogManager .getLogger (this ).warn ("Unable to connect to any NSQ Lookup servers, servers tried: {} on topic: {}" , this .addresses , topic );
49
50
}
50
51
return addresses ;
51
52
}
0 commit comments