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());
}
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"));
}
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));
}
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));
}
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));
}
Aggregations