Search in sources :

Example 1 with ClusterGetSettingsRequest

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

the class ClusterRequestConvertersTests method testClusterGetSettings.

public void testClusterGetSettings() throws IOException {
    ClusterGetSettingsRequest request = new ClusterGetSettingsRequest();
    Map<String, String> expectedParams = new HashMap<>();
    RequestConvertersTests.setRandomMasterTimeout(request, expectedParams);
    request.includeDefaults(OpenSearchTestCase.randomBoolean());
    if (request.includeDefaults()) {
        expectedParams.put("include_defaults", String.valueOf(true));
    }
    Request expectedRequest = ClusterRequestConverters.clusterGetSettings(request);
    Assert.assertEquals("/_cluster/settings", expectedRequest.getEndpoint());
    Assert.assertEquals(HttpGet.METHOD_NAME, expectedRequest.getMethod());
    Assert.assertEquals(expectedParams, expectedRequest.getParameters());
}
Also used : HashMap(java.util.HashMap) AcknowledgedRequest(org.opensearch.action.support.master.AcknowledgedRequest) ClusterUpdateSettingsRequest(org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest) ClusterGetSettingsRequest(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsRequest) RemoteInfoRequest(org.opensearch.client.cluster.RemoteInfoRequest) ClusterHealthRequest(org.opensearch.action.admin.cluster.health.ClusterHealthRequest) ClusterGetSettingsRequest(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsRequest)

Example 2 with ClusterGetSettingsRequest

use of org.opensearch.action.admin.cluster.settings.ClusterGetSettingsRequest 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 3 with ClusterGetSettingsRequest

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

the class ClusterClientDocumentationIT method testClusterGetSettings.

@SuppressWarnings("unused")
public void testClusterGetSettings() throws IOException {
    RestHighLevelClient client = highLevelClient();
    // tag::get-settings-request
    ClusterGetSettingsRequest request = new ClusterGetSettingsRequest();
    // end::get-settings-request
    // tag::get-settings-request-includeDefaults
    // <1>
    request.includeDefaults(true);
    // end::get-settings-request-includeDefaults
    // tag::get-settings-request-local
    // <1>
    request.local(true);
    // end::get-settings-request-local
    // tag::get-settings-request-masterTimeout
    // <1>
    request.masterNodeTimeout(TimeValue.timeValueMinutes(1));
    // <2>
    request.masterNodeTimeout("1m");
    // end::get-settings-request-masterTimeout
    // tag::get-settings-execute
    // <1>
    ClusterGetSettingsResponse response = client.cluster().getSettings(request, RequestOptions.DEFAULT);
    // end::get-settings-execute
    // tag::get-settings-response
    // <1>
    Settings persistentSettings = response.getPersistentSettings();
    // <2>
    Settings transientSettings = response.getTransientSettings();
    // <3>
    Settings defaultSettings = response.getDefaultSettings();
    // <4>
    String settingValue = response.getSetting("cluster.routing.allocation.enable");
    // end::get-settings-response
    assertThat(defaultSettings.size(), greaterThan(0));
}
Also used : ClusterGetSettingsResponse(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse) ClusterGetSettingsRequest(org.opensearch.action.admin.cluster.settings.ClusterGetSettingsRequest) RestHighLevelClient(org.opensearch.client.RestHighLevelClient) RecoverySettings(org.opensearch.indices.recovery.RecoverySettings) Settings(org.opensearch.common.settings.Settings)

Example 4 with ClusterGetSettingsRequest

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

Example 5 with ClusterGetSettingsRequest

use of org.opensearch.action.admin.cluster.settings.ClusterGetSettingsRequest 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)7 ClusterGetSettingsResponse (org.opensearch.action.admin.cluster.settings.ClusterGetSettingsResponse)5 RemoteInfoRequest (org.opensearch.client.cluster.RemoteInfoRequest)3 Settings (org.opensearch.common.settings.Settings)3 RecoverySettings (org.opensearch.indices.recovery.RecoverySettings)3 ClusterHealthRequest (org.opensearch.action.admin.cluster.health.ClusterHealthRequest)2 ClusterUpdateSettingsRequest (org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest)2 RestHighLevelClient (org.opensearch.client.RestHighLevelClient)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ActionListener (org.opensearch.action.ActionListener)1 LatchedActionListener (org.opensearch.action.LatchedActionListener)1 AcknowledgedRequest (org.opensearch.action.support.master.AcknowledgedRequest)1 RemoteConnectionInfo (org.opensearch.client.cluster.RemoteConnectionInfo)1 RemoteInfoResponse (org.opensearch.client.cluster.RemoteInfoResponse)1 SniffModeInfo (org.opensearch.client.cluster.SniffModeInfo)1 ComponentTemplatesExistRequest (org.opensearch.client.indices.ComponentTemplatesExistRequest)1 DeleteComponentTemplateRequest (org.opensearch.client.indices.DeleteComponentTemplateRequest)1 GetComponentTemplatesRequest (org.opensearch.client.indices.GetComponentTemplatesRequest)1