Search in sources :

Example 1 with SniffModeInfo

use of org.opensearch.client.cluster.SniffModeInfo in project OpenSearch by opensearch-project.

the class ClusterClientIT method testRemoteInfo.

public void testRemoteInfo() throws Exception {
    String clusterAlias = "local_cluster";
    setupRemoteClusterConfig(clusterAlias);
    ClusterGetSettingsRequest settingsRequest = new ClusterGetSettingsRequest();
    settingsRequest.includeDefaults(true);
    ClusterGetSettingsResponse settingsResponse = highLevelClient().cluster().getSettings(settingsRequest, RequestOptions.DEFAULT);
    List<String> seeds = SniffConnectionStrategy.REMOTE_CLUSTER_SEEDS.getConcreteSettingForNamespace(clusterAlias).get(settingsResponse.getTransientSettings());
    int connectionsPerCluster = SniffConnectionStrategy.REMOTE_CONNECTIONS_PER_CLUSTER.get(settingsResponse.getTransientSettings());
    TimeValue initialConnectionTimeout = RemoteClusterService.REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING.get(settingsResponse.getTransientSettings());
    boolean skipUnavailable = RemoteClusterService.REMOTE_CLUSTER_SKIP_UNAVAILABLE.getConcreteSettingForNamespace(clusterAlias).get(settingsResponse.getTransientSettings());
    RemoteInfoRequest request = new RemoteInfoRequest();
    RemoteInfoResponse response = execute(request, highLevelClient().cluster()::remoteInfo, highLevelClient().cluster()::remoteInfoAsync);
    assertThat(response, notNullValue());
    assertThat(response.getInfos().size(), equalTo(1));
    RemoteConnectionInfo info = response.getInfos().get(0);
    assertThat(info.getClusterAlias(), equalTo(clusterAlias));
    assertThat(info.getInitialConnectionTimeoutString(), equalTo(initialConnectionTimeout.toString()));
    assertThat(info.isSkipUnavailable(), equalTo(skipUnavailable));
    assertThat(info.getModeInfo().modeName(), equalTo(SniffModeInfo.NAME));
    assertThat(info.getModeInfo().isConnected(), equalTo(true));
    SniffModeInfo sniffModeInfo = (SniffModeInfo) info.getModeInfo();
    assertThat(sniffModeInfo.getMaxConnectionsPerCluster(), equalTo(connectionsPerCluster));
    assertThat(sniffModeInfo.getNumNodesConnected(), equalTo(1));
    assertThat(sniffModeInfo.getSeedNodes(), equalTo(seeds));
}
Also used : ClusterGetSettingsResponse(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse) RemoteConnectionInfo(org.opensearch.client.cluster.RemoteConnectionInfo) SniffModeInfo(org.opensearch.client.cluster.SniffModeInfo) RemoteInfoResponse(org.opensearch.client.cluster.RemoteInfoResponse) ClusterGetSettingsRequest(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsRequest) TimeValue(org.opensearch.common.unit.TimeValue) RemoteInfoRequest(org.opensearch.client.cluster.RemoteInfoRequest)

Aggregations

ClusterGetSettingsRequest (org.opensearch.action.admin.cluster.settings.ClusterGetSettingsRequest)1 ClusterGetSettingsResponse (org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse)1 RemoteConnectionInfo (org.opensearch.client.cluster.RemoteConnectionInfo)1 RemoteInfoRequest (org.opensearch.client.cluster.RemoteInfoRequest)1 RemoteInfoResponse (org.opensearch.client.cluster.RemoteInfoResponse)1 SniffModeInfo (org.opensearch.client.cluster.SniffModeInfo)1 TimeValue (org.opensearch.common.unit.TimeValue)1