Search in sources :

Example 1 with GetClusterSettingsResponse

use of org.opensearch.client.opensearch.cluster.GetClusterSettingsResponse in project opensearch-java by opensearch-project.

the class ClusterClientIT method testClusterGetSettings.

public void testClusterGetSettings() throws IOException {
    OpenSearchClient openSearchClient = highLevelClient();
    final String transientSettingKey = RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey();
    final String transientSettingValue = "10b";
    final String persistentSettingKey = EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey();
    final String persistentSettingValue = EnableAllocationDecider.Allocation.NONE.name();
    Map<String, JsonData> transientSettingsMap = new HashMap<>();
    Map<String, JsonData> persistentSettingsMap = new HashMap<>();
    transientSettingsMap.put(transientSettingKey, JsonData.of(transientSettingValue));
    persistentSettingsMap.put(persistentSettingKey, JsonData.of(persistentSettingValue));
    PutClusterSettingsRequest request = new PutClusterSettingsRequest.Builder().persistent(persistentSettingsMap).transient_(transientSettingsMap).build();
    openSearchClient.cluster().putSettings(request);
    GetClusterSettingsResponse getSettingsResponse = openSearchClient.cluster().getSettings(new GetClusterSettingsRequest.Builder().build());
    assertEquals(1, getSettingsResponse.persistent().size());
    assertEquals(1, getSettingsResponse.transient_().size());
    assertEquals(0, getSettingsResponse.defaults().size());
}
Also used : GetClusterSettingsResponse(org.opensearch.client.opensearch.cluster.GetClusterSettingsResponse) HashMap(java.util.HashMap) PutClusterSettingsRequest(org.opensearch.client.opensearch.cluster.PutClusterSettingsRequest) OpenSearchClient(org.opensearch.client.opensearch.OpenSearchClient) JsonData(org.opensearch.client.json.JsonData)

Example 2 with GetClusterSettingsResponse

use of org.opensearch.client.opensearch.cluster.GetClusterSettingsResponse in project opensearch-java by opensearch-project.

the class ClusterClientIT method testClusterGetSettingsWithDefault.

public void testClusterGetSettingsWithDefault() throws IOException {
    OpenSearchClient openSearchClient = highLevelClient();
    final String transientSettingKey = RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING.getKey();
    final String transientSettingValue = "10b";
    final String persistentSettingKey = EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey();
    final String persistentSettingValue = EnableAllocationDecider.Allocation.NONE.name();
    Map<String, JsonData> transientSettingsMap = new HashMap<>();
    Map<String, JsonData> persistentSettingsMap = new HashMap<>();
    transientSettingsMap.put(transientSettingKey, JsonData.of(transientSettingValue));
    persistentSettingsMap.put(persistentSettingKey, JsonData.of(persistentSettingValue));
    PutClusterSettingsRequest request = new PutClusterSettingsRequest.Builder().persistent(persistentSettingsMap).transient_(transientSettingsMap).build();
    openSearchClient.cluster().putSettings(request);
    GetClusterSettingsResponse getSettingsResponse = openSearchClient.cluster().getSettings(new GetClusterSettingsRequest.Builder().includeDefaults(true).build());
    assertEquals(1, getSettingsResponse.persistent().size());
    assertEquals(1, getSettingsResponse.transient_().size());
    assertTrue(getSettingsResponse.defaults().size() > 0);
}
Also used : GetClusterSettingsResponse(org.opensearch.client.opensearch.cluster.GetClusterSettingsResponse) HashMap(java.util.HashMap) GetClusterSettingsRequest(org.opensearch.client.opensearch.cluster.GetClusterSettingsRequest) PutClusterSettingsRequest(org.opensearch.client.opensearch.cluster.PutClusterSettingsRequest) OpenSearchClient(org.opensearch.client.opensearch.OpenSearchClient) JsonData(org.opensearch.client.json.JsonData)

Aggregations

HashMap (java.util.HashMap)2 JsonData (org.opensearch.client.json.JsonData)2 OpenSearchClient (org.opensearch.client.opensearch.OpenSearchClient)2 GetClusterSettingsResponse (org.opensearch.client.opensearch.cluster.GetClusterSettingsResponse)2 PutClusterSettingsRequest (org.opensearch.client.opensearch.cluster.PutClusterSettingsRequest)2 GetClusterSettingsRequest (org.opensearch.client.opensearch.cluster.GetClusterSettingsRequest)1