Skip to content

Commit 0d65260

Browse files
authored
Change index setting from read_only_allow_delete to write (#311)
read_only_allow_delete does not block write to an index. The disk-based shard allocator may add and remove this block automatically. Therefore, use index.blocks.write instead. Signed-off-by: Heemin Kim <heemin@amazon.com>
1 parent ca86afd commit 0d65260

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/main/java/org/opensearch/geospatial/ip2geo/common/GeoIpDataFacade.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ public class GeoIpDataFacade {
7070
private static final Tuple<String, Integer> INDEX_SETTING_REFRESH_INTERVAL = new Tuple<>("index.refresh_interval", -1);
7171
private static final Tuple<String, String> INDEX_SETTING_AUTO_EXPAND_REPLICAS = new Tuple<>("index.auto_expand_replicas", "0-all");
7272
private static final Tuple<String, Boolean> INDEX_SETTING_HIDDEN = new Tuple<>("index.hidden", true);
73-
private static final Tuple<String, Boolean> INDEX_SETTING_READ_ONLY_ALLOW_DELETE = new Tuple<>(
74-
"index.blocks.read_only_allow_delete",
75-
true
76-
);
73+
private static final Tuple<String, Boolean> INDEX_SETTING_BLOCKS_WRITE = new Tuple<>("index.blocks.write", true);
7774
private final ClusterService clusterService;
7875
private final ClusterSettings clusterSettings;
7976
private final Client client;
@@ -116,8 +113,7 @@ private void freezeIndex(final String indexName) {
116113
client.admin().indices().prepareRefresh(indexName).execute().actionGet(timeout);
117114
client.admin().indices().prepareForceMerge(indexName).setMaxNumSegments(1).execute().actionGet(timeout);
118115
Map<String, Object> settings = new HashMap<>();
119-
settings.put(INDEX_SETTING_READ_ONLY_ALLOW_DELETE.v1(), INDEX_SETTING_READ_ONLY_ALLOW_DELETE.v2());
120-
settings.put(INDEX_SETTING_NUM_OF_REPLICAS.v1(), null);
116+
settings.put(INDEX_SETTING_BLOCKS_WRITE.v1(), INDEX_SETTING_BLOCKS_WRITE.v2());
121117
settings.put(INDEX_SETTING_AUTO_EXPAND_REPLICAS.v1(), INDEX_SETTING_AUTO_EXPAND_REPLICAS.v2());
122118
client.admin()
123119
.indices()

src/test/java/org/opensearch/geospatial/ip2geo/common/GeoIpDataFacadeTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public void testPutGeoIpData_whenValidInput_thenSucceed() {
210210
UpdateSettingsRequest request = (UpdateSettingsRequest) actionRequest;
211211
assertEquals(1, request.indices().length);
212212
assertEquals(index, request.indices()[0]);
213-
assertEquals(true, request.settings().getAsBoolean("index.blocks.read_only_allow_delete", false));
213+
assertEquals(true, request.settings().getAsBoolean("index.blocks.write", false));
214214
assertNull(request.settings().get("index.num_of_replica"));
215215
assertEquals("0-all", request.settings().get("index.auto_expand_replicas"));
216216
return null;

0 commit comments

Comments
 (0)