List of usage examples for com.mongodb.connection ServerDescription getAddress
public ServerAddress getAddress()
From source file:com.navercorp.pinpoint.plugin.mongo.interceptor.MongoDriverConnectInterceptor3_0.java
License:Apache License
private List<String> getHostList(Object arg) { if (!(arg instanceof Cluster)) { return Collections.emptyList(); }/*from w w w .ja v a2 s .c o m*/ final Cluster cluster = (Cluster) arg; final List<String> hostList = new ArrayList<String>(); Collection<ServerDescription> serverDescriptions;// = cluster.getDescription().getAll();//.getServerDescriptions(); try { ClusterDescription.class.getDeclaredMethod("getServerDescriptions"); serverDescriptions = cluster.getDescription().getServerDescriptions(); } catch (NoSuchMethodException e) { serverDescriptions = cluster.getDescription().getAll(); } for (ServerDescription serverDescription : serverDescriptions) { ServerAddress serverAddress = serverDescription.getAddress(); final String hostAddress = HostAndPort.toHostAndPortString(serverAddress.getHost(), serverAddress.getPort()); hostList.add(hostAddress); } return hostList; }