Example usage for com.mongodb MongoClientSettings getClusterSettings

List of usage examples for com.mongodb MongoClientSettings getClusterSettings

Introduction

In this page you can find the example usage for com.mongodb MongoClientSettings getClusterSettings.

Prototype

public ClusterSettings getClusterSettings() 

Source Link

Document

Gets the cluster settings.

Usage

From source file:com.navercorp.pinpoint.plugin.mongo.interceptor.MongoDriverConnectInterceptor3_7.java

License:Apache License

private List<String> getHostList(Object arg) {
    if (!(arg instanceof MongoClientSettings)) {
        return Collections.emptyList();
    }//from   w  w  w  .j  a  va2  s .  c om

    final MongoClientSettings mongoClientSettings = (MongoClientSettings) arg;

    List<ServerAddress> lists = mongoClientSettings.getClusterSettings().getHosts();

    final List<String> hostList = new ArrayList<String>();
    for (ServerAddress sa : lists) {
        final String hostAddress = HostAndPort.toHostAndPortString(sa.getHost(), sa.getPort());
        hostList.add(hostAddress);
    }

    return hostList;
}