Skip to content

Commit

Permalink
remove delete alias method
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-td committed Feb 17, 2023
1 parent 803767f commit 35f41f3
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ public void reassignAlias(String aliasName, String newIndexName, PluginTask task
List<String> oldIndices = getIndexByAlias(aliasName, task);
assignAlias(newIndexName, aliasName, task);
for (String index : oldIndices) {
deleteAlias(index, aliasName, task);
deleteIndex(index, task);
}
}
Expand Down Expand Up @@ -312,34 +311,6 @@ private void deleteIndex(String indexName, PluginTask task)
}
}

private void deleteAlias(String indexName, String aliasName, PluginTask task)
{
try {
if (isIndexExisting(indexName, task)) {
if (isAliasExisting(aliasName, task)) {
Map<String, String> alias = new HashMap<>();
alias.put("index", indexName);
alias.put("alias", aliasName);

Map<String, Map> remove = new HashMap<>();
remove.put("remove", alias);

List<Map<String, Map>> actions = new ArrayList<>();
actions.add(remove);
Map<String, List> rootTree = new HashMap<>();
rootTree.put("actions", actions);

String content = jsonMapper.writeValueAsString(rootTree);
sendRequest("/_aliases", HttpMethod.POST, task, content);
log.info("Remove alias [{}] to index[{}]", aliasName, indexName);
}
}
}
catch (JsonProcessingException ex) {
throw new ConfigException(String.format("Failed to remove alias[%s] to index[%s]", aliasName, indexName));
}
}

private void waitSnapshot(PluginTask task)
{
int maxSnapshotWaitingMills = task.getMaxSnapshotWaitingSecs() * 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ public void prepareBeforeTest(PluginTask task) throws Exception
Method deleteIndex = ElasticsearchHttpClient.class.getDeclaredMethod("deleteIndex", String.class, PluginTask.class);
deleteIndex.setAccessible(true);

Method deleteAlias = ElasticsearchHttpClient.class.getDeclaredMethod("deleteAlias", String.class, String.class, PluginTask.class);
deleteAlias.setAccessible(true);

// Delete alias
if (client.isAliasExisting(ES_ALIAS, task)) {
deleteAlias.invoke(client, ES_INDEX, ES_ALIAS, task);
}

// Delete index
if (client.isIndexExisting(ES_INDEX, task)) {
deleteIndex.invoke(client, ES_INDEX, task);
Expand Down

0 comments on commit 35f41f3

Please sign in to comment.