You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2020/04/15 07:08:52 UTC
[skywalking] branch master updated: Keep latest index always
present. (#4655)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new 12703fa Keep latest index always present. (#4655)
12703fa is described below
commit 12703fa54edeb55a6f92d123f767461ea62d1df0
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Wed Apr 15 15:08:38 2020 +0800
Keep latest index always present. (#4655)
* Keep latest index always present.
* Avoid TTL timer to remove latest index
* Create a latest index even without any data.
Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
.../plugin/elasticsearch/base/HistoryDeleteEsDAO.java | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/HistoryDeleteEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/HistoryDeleteEsDAO.java
index d86bb43..88ec7f8 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/HistoryDeleteEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/base/HistoryDeleteEsDAO.java
@@ -54,19 +54,21 @@ public class HistoryDeleteEsDAO extends EsDAO implements IHistoryDeleteDAO {
List<String> indexes = client.retrievalIndexByAliases(model.getName());
List<String> prepareDeleteIndexes = new ArrayList<>();
+ List<String> leftIndices = new ArrayList<>();
for (String index : indexes) {
long timeSeries = TimeSeriesUtils.isolateTimeFromIndexName(index);
if (deadline >= timeSeries) {
prepareDeleteIndexes.add(index);
+ } else {
+ leftIndices.add(index);
}
}
-
- if (indexes.size() == prepareDeleteIndexes.size()) {
- client.createIndex(TimeSeriesUtils.latestWriteIndexName(model));
- }
-
for (String prepareDeleteIndex : prepareDeleteIndexes) {
client.deleteByIndexName(prepareDeleteIndex);
}
+ String latestIndex = TimeSeriesUtils.latestWriteIndexName(model);
+ if (!leftIndices.contains(latestIndex)) {
+ client.createIndex(latestIndex);
+ }
}
}