Search in sources :

Example 1 with ClusterGetSettingsResponse

use of org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse in project OpenSearch by opensearch-project.

the class ClusterClientIT method testClusterGetSettings.

public void testClusterGetSettings() throws IOException {
    final String transientSettingKey = RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey();
    final int transientSettingValue = 10;
    final String persistentSettingKey = EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey();
    final String persistentSettingValue = EnableAllocationDecider.Allocation.NONE.name();
    Settings transientSettings = Settings.builder().put(transientSettingKey, transientSettingValue, ByteSizeUnit.BYTES).build();
    Settings persistentSettings = Settings.builder().put(persistentSettingKey, persistentSettingValue).build();
    clusterUpdateSettings(persistentSettings, transientSettings);
    ClusterGetSettingsRequest request = new ClusterGetSettingsRequest();
    ClusterGetSettingsResponse response = execute(request, highLevelClient().cluster()::getSettings, highLevelClient().cluster()::getSettingsAsync);
    assertEquals(persistentSettings, response.getPersistentSettings());
    assertEquals(transientSettings, response.getTransientSettings());
    assertEquals(0, response.getDefaultSettings().size());
}
Also used : ClusterGetSettingsResponse(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse) ClusterGetSettingsRequest(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsRequest) RecoverySettings(org.opensearch.indices.recovery.RecoverySettings) Settings(org.opensearch.common.settings.Settings)

Example 2 with ClusterGetSettingsResponse

use of org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse in project OpenSearch by opensearch-project.

the class RestClusterGetSettingsActionTests method runTestFilterSettingsTest.

private void runTestFilterSettingsTest(final BiConsumer<Metadata.Builder, Settings> md, final Function<ClusterGetSettingsResponse, Settings> s) {
    final Metadata.Builder mdBuilder = new Metadata.Builder();
    final Settings settings = Settings.builder().put("foo.filtered", "bar").put("foo.non_filtered", "baz").build();
    md.accept(mdBuilder, settings);
    final ClusterState.Builder builder = new ClusterState.Builder(ClusterState.EMPTY_STATE).metadata(mdBuilder);
    final SettingsFilter filter = new SettingsFilter(Collections.singleton("foo.filtered"));
    final Setting.Property[] properties = { Setting.Property.Dynamic, Setting.Property.Filtered, Setting.Property.NodeScope };
    final Set<Setting<?>> settingsSet = Stream.concat(ClusterSettings.BUILT_IN_CLUSTER_SETTINGS.stream(), Stream.concat(Stream.of(Setting.simpleString("foo.filtered", properties)), Stream.of(Setting.simpleString("foo.non_filtered", properties)))).collect(Collectors.toSet());
    final ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, settingsSet);
    final ClusterGetSettingsResponse response = RestClusterGetSettingsAction.response(builder.build(), randomBoolean(), filter, clusterSettings, Settings.EMPTY);
    assertFalse(s.apply(response).hasValue("foo.filtered"));
    assertTrue(s.apply(response).hasValue("foo.non_filtered"));
}
Also used : ClusterState(org.opensearch.cluster.ClusterState) ClusterGetSettingsResponse(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse) ClusterSettings(org.opensearch.common.settings.ClusterSettings) Setting(org.opensearch.common.settings.Setting) Metadata(org.opensearch.cluster.metadata.Metadata) SettingsFilter(org.opensearch.common.settings.SettingsFilter) Settings(org.opensearch.common.settings.Settings) ClusterSettings(org.opensearch.common.settings.ClusterSettings)

Example 3 with ClusterGetSettingsResponse

use of org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse in project OpenSearch by opensearch-project.

the class ClusterClientIT method testClusterGetSettingsWithDefault.

public void testClusterGetSettingsWithDefault() throws IOException {
    final String transientSettingKey = RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey();
    final int transientSettingValue = 10;
    final String persistentSettingKey = EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey();
    final String persistentSettingValue = EnableAllocationDecider.Allocation.NONE.name();
    Settings transientSettings = Settings.builder().put(transientSettingKey, transientSettingValue, ByteSizeUnit.BYTES).build();
    Settings persistentSettings = Settings.builder().put(persistentSettingKey, persistentSettingValue).build();
    clusterUpdateSettings(persistentSettings, transientSettings);
    ClusterGetSettingsRequest request = new ClusterGetSettingsRequest().includeDefaults(true);
    ClusterGetSettingsResponse response = execute(request, highLevelClient().cluster()::getSettings, highLevelClient().cluster()::getSettingsAsync);
    assertEquals(persistentSettings, response.getPersistentSettings());
    assertEquals(transientSettings, response.getTransientSettings());
    assertThat(response.getDefaultSettings().size(), greaterThan(0));
}
Also used : ClusterGetSettingsResponse(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse) ClusterGetSettingsRequest(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsRequest) RecoverySettings(org.opensearch.indices.recovery.RecoverySettings) Settings(org.opensearch.common.settings.Settings)

Example 4 with ClusterGetSettingsResponse

use of org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse 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)

Example 5 with ClusterGetSettingsResponse

use of org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse in project OpenSearch by opensearch-project.

the class ClusterClientDocumentationIT method testClusterGetSettingsAsync.

public void testClusterGetSettingsAsync() throws InterruptedException {
    RestHighLevelClient client = highLevelClient();
    ClusterGetSettingsRequest request = new ClusterGetSettingsRequest();
    // tag::get-settings-execute-listener
    ActionListener<ClusterGetSettingsResponse> listener = new ActionListener<ClusterGetSettingsResponse>() {

        @Override
        public void onResponse(ClusterGetSettingsResponse response) {
        // <1>
        }

        @Override
        public void onFailure(Exception e) {
        // <2>
        }
    };
    // end::get-settings-execute-listener
    // Replace the empty listener by a blocking listener in test
    final CountDownLatch latch = new CountDownLatch(1);
    listener = new LatchedActionListener<>(listener, latch);
    // tag::get-settings-execute-async
    // <1>
    client.cluster().getSettingsAsync(request, RequestOptions.DEFAULT, listener);
    // end::get-settings-execute-async
    assertTrue(latch.await(30L, TimeUnit.SECONDS));
}
Also used : ClusterGetSettingsResponse(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse) LatchedActionListener(org.opensearch.action.LatchedActionListener) ActionListener(org.opensearch.action.ActionListener) ClusterGetSettingsRequest(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsRequest) RestHighLevelClient(org.opensearch.client.RestHighLevelClient) CountDownLatch(java.util.concurrent.CountDownLatch) IOException(java.io.IOException)

Aggregations

ClusterGetSettingsResponse (org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse)7 ClusterGetSettingsRequest (org.opensearch.action.admin.cluster.settings.ClusterGetSettingsRequest)6 Settings (org.opensearch.common.settings.Settings)4 RecoverySettings (org.opensearch.indices.recovery.RecoverySettings)3 RestHighLevelClient (org.opensearch.client.RestHighLevelClient)2 IOException (java.io.IOException)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ActionListener (org.opensearch.action.ActionListener)1 LatchedActionListener (org.opensearch.action.LatchedActionListener)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 ClusterState (org.opensearch.cluster.ClusterState)1 Metadata (org.opensearch.cluster.metadata.Metadata)1 ClusterSettings (org.opensearch.common.settings.ClusterSettings)1 Setting (org.opensearch.common.settings.Setting)1 SettingsFilter (org.opensearch.common.settings.SettingsFilter)1 TimeValue (org.opensearch.common.unit.TimeValue)1