use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest in project graylog2-server by Graylog2.
the class ClientES7 method resetIndexBlock.
@Override
public void resetIndexBlock(String index) {
final UpdateSettingsRequest request = new UpdateSettingsRequest(index).settings(Collections.singletonMap("index.blocks.read_only_allow_delete", null));
client.execute((c, requestOptions) -> c.indices().putSettings(request, requestOptions), "Unable to reset index block for " + index);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest in project snow-owl by b2ihealthcare.
the class EsIndexAdmin method updateSettings.
@Override
public void updateSettings(Map<String, Object> newSettings) {
if (CompareUtils.isEmpty(newSettings)) {
return;
}
// ignore local and/or dynamic settings
final Set<String> unsupportedDynamicSettings = Sets.difference(Sets.difference(newSettings.keySet(), DYNAMIC_SETTINGS), LOCAL_SETTINGS);
if (!unsupportedDynamicSettings.isEmpty()) {
throw new IndexException(String.format("Settings [%s] are not dynamically updateable settings.", unsupportedDynamicSettings), null);
}
boolean shouldUpdate = false;
for (String settingKey : newSettings.keySet()) {
Object currentValue = settings.get(settingKey);
Object newValue = newSettings.get(settingKey);
if (!Objects.equals(currentValue, newValue)) {
shouldUpdate = true;
}
}
if (!shouldUpdate) {
return;
}
Map<String, Object> esSettings = new HashMap<>(newSettings);
// remove any local settings from esSettings
esSettings.keySet().removeAll(LOCAL_SETTINGS);
for (DocumentMapping mapping : mappings.getMappings()) {
final String index = getTypeIndex(mapping);
// if any index exists, then update the settings based on the new settings
if (exists(mapping)) {
try {
log.info("Applying settings '{}' changes in index {}...", esSettings, index);
AcknowledgedResponse response = client.indices().updateSettings(new UpdateSettingsRequest().indices(index).settings(esSettings));
checkState(response.isAcknowledged(), "Failed to update index settings '%s'.", index);
} catch (IOException e) {
throw new IndexException(String.format("Couldn't update settings of index '%s'", index), e);
}
}
}
// update both local and es settings
settings.putAll(newSettings);
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest in project sonarqube by SonarSource.
the class EsTester method setIndexSettings.
private void setIndexSettings(String index, Map<String, Object> settings) {
AcknowledgedResponse response = null;
try {
response = ES_REST_CLIENT.nativeClient().indices().putSettings(new UpdateSettingsRequest(index).settings(settings), RequestOptions.DEFAULT);
} catch (IOException e) {
throw new IllegalStateException("Could not update index settings", e);
}
checkState(response.isAcknowledged());
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest in project sonarqube by SonarSource.
the class IndexCreator method removeReadOnly.
private void removeReadOnly(IndexType.IndexMainType mainType) {
LOGGER.info("Index [{}] is read-only. Making it writable...", mainType.getIndex().getName());
String indexName = mainType.getIndex().getName();
Settings.Builder builder = Settings.builder();
builder.putNull("index.blocks.read_only_allow_delete");
client.putSettings(new UpdateSettingsRequest().indices(indexName).settings(builder.build()));
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest in project elasticsearch by elastic.
the class IndicesRequestIT method testUpdateSettings.
public void testUpdateSettings() {
interceptTransportActions(UpdateSettingsAction.NAME);
UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(randomIndicesOrAliases()).settings(Settings.builder().put("refresh_interval", -1));
internalCluster().coordOnlyNodeClient().admin().indices().updateSettings(updateSettingsRequest).actionGet();
clearInterceptedActions();
assertSameIndices(updateSettingsRequest, UpdateSettingsAction.NAME);
}
Aggregations