From e89d6430794598ffaefe534b4f03cbd467d99bb7 Mon Sep 17 00:00:00 2001 From: jowg-amazon Date: Fri, 8 Sep 2023 23:41:20 +0000 Subject: [PATCH] updated timeout errors to request_timeout Signed-off-by: jowg-amazon --- .../securityanalytics/logtype/LogTypeService.java | 2 +- .../transport/TransportCorrelateFindingAction.java | 4 ++-- .../TransportDeleteCorrelationRuleAction.java | 2 +- .../TransportDeleteCustomLogTypeAction.java | 4 ++-- .../transport/TransportDeleteRuleAction.java | 4 ++-- .../transport/TransportIndexCustomLogTypeAction.java | 12 ++++++------ .../transport/TransportIndexRuleAction.java | 2 +- .../securityanalytics/util/RuleIndices.java | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/opensearch/securityanalytics/logtype/LogTypeService.java b/src/main/java/org/opensearch/securityanalytics/logtype/LogTypeService.java index 2be1fce78..488fd14eb 100644 --- a/src/main/java/org/opensearch/securityanalytics/logtype/LogTypeService.java +++ b/src/main/java/org/opensearch/securityanalytics/logtype/LogTypeService.java @@ -276,7 +276,7 @@ private void doIndexLogTypeMetadata(ActionListener listener) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - listener.onFailure(new OpenSearchStatusException("Unknown error", RestStatus.INTERNAL_SERVER_ERROR)); + listener.onFailure(new OpenSearchStatusException("Unknown error", RestStatus.REQUEST_TIMEOUT)); } if (response.getHits().getTotalHits().value > 0) { listener.onResponse(null); diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java index 96b766d17..9ddb74a49 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportCorrelateFindingAction.java @@ -336,7 +336,7 @@ public void onResponse(IndexResponse response) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(response.toString(), RestStatus.INTERNAL_SERVER_ERROR)); + onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); } SearchHit[] hits = response.getHits().getHits(); @@ -392,7 +392,7 @@ public void onFailure(Exception e) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(response.toString(), RestStatus.INTERNAL_SERVER_ERROR)); + onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); } SearchHit[] hits = response.getHits().getHits(); diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCorrelationRuleAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCorrelationRuleAction.java index 1af67bffd..75987d0ce 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCorrelationRuleAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCorrelationRuleAction.java @@ -68,7 +68,7 @@ public void onResponse(BulkByScrollResponse response) { "Correlation Rule with id %s cannot be deleted", correlationRuleId ), - RestStatus.INTERNAL_SERVER_ERROR) + RestStatus.REQUEST_TIMEOUT) ); return; } diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCustomLogTypeAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCustomLogTypeAction.java index 488d8695d..7bb8de981 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCustomLogTypeAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteCustomLogTypeAction.java @@ -174,7 +174,7 @@ private void onGetResponse(CustomLogType logType) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be deleted", logType.getId()), RestStatus.INTERNAL_SERVER_ERROR)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be deleted", logType.getId()), RestStatus.REQUEST_TIMEOUT)); return; } @@ -187,7 +187,7 @@ public void onResponse(SearchResponse response) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be deleted", logType.getId()), RestStatus.INTERNAL_SERVER_ERROR)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be deleted", logType.getId()), RestStatus.REQUEST_TIMEOUT)); return; } diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteRuleAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteRuleAction.java index d5be2a420..15b0c0836 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteRuleAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportDeleteRuleAction.java @@ -152,7 +152,7 @@ private void onGetResponse(Rule rule) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Rule with id %s cannot be deleted", rule.getId()), RestStatus.INTERNAL_SERVER_ERROR)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Rule with id %s cannot be deleted", rule.getId()), RestStatus.REQUEST_TIMEOUT)); return; } @@ -231,7 +231,7 @@ private void deleteRule(String ruleId) { @Override public void onResponse(BulkByScrollResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Rule with id %s cannot be deleted", ruleId), RestStatus.INTERNAL_SERVER_ERROR)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Rule with id %s cannot be deleted", ruleId), RestStatus.REQUEST_TIMEOUT)); return; } diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java index ae5ba9864..961dbb0c0 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexCustomLogTypeAction.java @@ -218,12 +218,12 @@ private void prepareCustomLogTypeIndexing() throws IOException { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be updated", logTypeId), RestStatus.INTERNAL_SERVER_ERROR)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be updated", logTypeId), RestStatus.REQUEST_TIMEOUT)); return; } if (response.getHits().getTotalHits().value != 1) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be updated", logTypeId), RestStatus.INTERNAL_SERVER_ERROR)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be updated", logTypeId), RestStatus.REQUEST_TIMEOUT)); return; } @@ -243,7 +243,7 @@ public void onResponse(SearchResponse response) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be updated", logTypeId), RestStatus.INTERNAL_SERVER_ERROR)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be updated", logTypeId), RestStatus.REQUEST_TIMEOUT)); return; } @@ -256,7 +256,7 @@ public void onResponse(SearchResponse response) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be updated", logTypeId), RestStatus.INTERNAL_SERVER_ERROR)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Log Type with id %s cannot be updated", logTypeId), RestStatus.REQUEST_TIMEOUT)); return; } @@ -379,7 +379,7 @@ public void onResponse(Void unused) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(response.toString(), RestStatus.INTERNAL_SERVER_ERROR)); + onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); return; } @@ -399,7 +399,7 @@ public void onResponse(SearchResponse response) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(response.toString(), RestStatus.INTERNAL_SERVER_ERROR)); + onFailures(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); return; } diff --git a/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexRuleAction.java b/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexRuleAction.java index 60b067011..a092951cf 100644 --- a/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexRuleAction.java +++ b/src/main/java/org/opensearch/securityanalytics/transport/TransportIndexRuleAction.java @@ -237,7 +237,7 @@ void indexRule(Rule rule, Map ruleFieldMappings) throws IOExcept @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Rule with id %s cannot be updated", rule.getId()), RestStatus.INTERNAL_SERVER_ERROR)); + onFailures(new OpenSearchStatusException(String.format(Locale.getDefault(), "Rule with id %s cannot be updated", rule.getId()), RestStatus.REQUEST_TIMEOUT)); return; } diff --git a/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java b/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java index d9569d064..f6ef26e44 100644 --- a/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java +++ b/src/main/java/org/opensearch/securityanalytics/util/RuleIndices.java @@ -328,7 +328,7 @@ public void onResponse(Void unused) { @Override public void onResponse(SearchResponse response) { if (response.isTimedOut()) { - listener.onFailure(new OpenSearchStatusException(response.toString(), RestStatus.INTERNAL_SERVER_ERROR)); + listener.onFailure(new OpenSearchStatusException(response.toString(), RestStatus.REQUEST_TIMEOUT)); } try { SearchHit[] hits = response.getHits().getHits();