Java 类com.mongodb.connection.Cluster 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MongoPropertiesTests.java   
private List<ServerAddress> extractServerAddresses(MongoClient client) {
    Cluster cluster = (Cluster) ReflectionTestUtils.getField(client, "cluster");
    ClusterSettings clusterSettings = (ClusterSettings) ReflectionTestUtils
            .getField(cluster, "settings");
    List<ServerAddress> allAddresses = clusterSettings.getHosts();
    return allAddresses;
}
项目:spring-boot-concourse    文件:MongoPropertiesTests.java   
private List<ServerAddress> extractServerAddresses(MongoClient client) {
    Cluster cluster = (Cluster) ReflectionTestUtils.getField(client, "cluster");
    ClusterSettings clusterSettings = (ClusterSettings) ReflectionTestUtils
            .getField(cluster, "settings");
    List<ServerAddress> allAddresses = clusterSettings.getHosts();
    return allAddresses;
}
项目:incubator-skywalking    文件:MongoDBMethodInterceptor.java   
@Override
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
    Cluster cluster = (Cluster)allArguments[0];
    StringBuilder peers = new StringBuilder();
    for (ServerDescription description : cluster.getDescription().getServerDescriptions()) {
        ServerAddress address = description.getAddress();
        peers.append(address.getHost() + ":" + address.getPort() + ";");
    }

    objInst.setSkyWalkingDynamicField(peers.subSequence(0, peers.length() - 1).toString());
}
项目:java-test-applications    文件:MongoDbUtils.java   
private String extractUrl(MongoDbFactory mongoDbFactory) {
    Cluster cluster = invokeMethod(this.<MongoClient>getField(mongoDbFactory, "mongoClient"), "getCluster");

    return cluster.getSettings().getHosts().stream()
        .map(serverAddress -> String.format("mongodb://%s:%d/%s", serverAddress.getHost(), serverAddress.getPort(), mongoDbFactory.getDb().getName()))
        .collect(Collectors.joining(","));
}