From df7fc714e7f1428264731d369723ace5ce1175fa Mon Sep 17 00:00:00 2001 From: Martijn van Groningen Date: Tue, 23 Dec 2014 16:30:04 +0100 Subject: [PATCH] Ensure that the refresh has ran on all shards. Original commit: elastic/x-pack-elasticsearch@62145149563fbb7b2f4490ed0b80c367bcfc3784 --- src/main/java/org/elasticsearch/alerts/AlertsStore.java | 2 +- .../org/elasticsearch/alerts/actions/AlertActionManager.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/elasticsearch/alerts/AlertsStore.java b/src/main/java/org/elasticsearch/alerts/AlertsStore.java index 3ad2aa8fc30..98cc861f9dc 100644 --- a/src/main/java/org/elasticsearch/alerts/AlertsStore.java +++ b/src/main/java/org/elasticsearch/alerts/AlertsStore.java @@ -198,7 +198,7 @@ public class AlertsStore extends AbstractComponent { private void loadAlerts() { assert alertMap.isEmpty() : "No alerts should reside, but there are " + alertMap.size() + " alerts."; RefreshResponse refreshResponse = client.admin().indices().refresh(new RefreshRequest(ALERT_INDEX)).actionGet(); - if (refreshResponse.getSuccessfulShards() != refreshResponse.getSuccessfulShards()) { + if (refreshResponse.getTotalShards() != refreshResponse.getSuccessfulShards()) { throw new ElasticsearchException("Not all shards have been refreshed"); } diff --git a/src/main/java/org/elasticsearch/alerts/actions/AlertActionManager.java b/src/main/java/org/elasticsearch/alerts/actions/AlertActionManager.java index 918a5da1e37..2f502f31865 100644 --- a/src/main/java/org/elasticsearch/alerts/actions/AlertActionManager.java +++ b/src/main/java/org/elasticsearch/alerts/actions/AlertActionManager.java @@ -165,10 +165,10 @@ public class AlertActionManager extends AbstractComponent { return ALERT_HISTORY_INDEX_PREFIX + alertHistoryIndexTimeFormat.print(time); } - public void loadQueue() { + private void loadQueue() { assert actionsToBeProcessed.isEmpty() : "Queue should be empty, but contains " + actionsToBeProcessed.size() + " elements."; RefreshResponse refreshResponse = client.admin().indices().refresh(new RefreshRequest(ALERT_HISTORY_INDEX_PREFIX + "*")).actionGet(); - if (refreshResponse.getSuccessfulShards() != refreshResponse.getSuccessfulShards()) { + if (refreshResponse.getTotalShards() != refreshResponse.getSuccessfulShards()) { throw new ElasticsearchException("Not all shards have been refreshed"); }