Skip to content

Commit

Permalink
Fix spotless check
Browse files Browse the repository at this point in the history
Signed-off-by: Rishab Nahata <rnnahata@amazon.com>
  • Loading branch information
imRishN committed Dec 22, 2022
1 parent 69e0361 commit 7564cb2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,15 @@ public ActionRequestValidationException validate() {
}
if (countValueWithZeroWeights > weightedRouting.weights().size() / 2) {
validationException = addValidationError(
(String.format(Locale.ROOT, "There are too many attribute values [%s] given zero weight [%d]. Maximum expected number of routing weights having zero weight is [%d]", weightedRouting.weights().toString(), countValueWithZeroWeights, weightedRouting.weights().size() / 2)), null);
(String.format(
Locale.ROOT,
"There are too many attribute values [%s] given zero weight [%d]. Maximum expected number of routing weights having zero weight is [%d]",
weightedRouting.weights().toString(),
countValueWithZeroWeights,
weightedRouting.weights().size() / 2
)),
null
);
}
return validationException;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,15 @@ private void ensureWeightsSetForAllDiscoveredAndForcedAwarenessValues(ClusterSta
// discovered awareness values has weight zero
if (countWithZeroWeight.get() > allAwarenessValues.size() / 2) {
throw addValidationError(
(String.format(Locale.ROOT, "There are too many discovered attribute values [%s] given zero weight [%d]. Maximum expected number of routing weights having zero weight is [%d]", request.getWeightedRouting().weights().toString(), countWithZeroWeight.get(), allAwarenessValues.size() / 2)), null);
(String.format(
Locale.ROOT,
"There are too many discovered attribute values [%s] given zero weight [%d]. Maximum expected number of routing weights having zero weight is [%d]",
request.getWeightedRouting().weights().toString(),
countWithZeroWeight.get(),
allAwarenessValues.size() / 2
)),
null
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public void testValidate_MoreThanHalfWithZeroWeight() {
request.setWeightedRouting(new BytesArray(reqString), XContentType.JSON);
ActionRequestValidationException actionRequestValidationException = request.validate();
assertNotNull(actionRequestValidationException);
assertTrue(actionRequestValidationException.getMessage().contains("Maximum expected number of routing weights having zero weight is [1]"));
assertTrue(
actionRequestValidationException.getMessage().contains("Maximum expected number of routing weights having zero weight is [1]")
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,10 @@ public void onFailure(Exception e) {
assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
MatcherAssert.assertThat("Expected onFailure to be called", exceptionReference.get(), notNullValue());
MatcherAssert.assertThat(exceptionReference.get(), instanceOf(ActionRequestValidationException.class));
MatcherAssert.assertThat(exceptionReference.get().getMessage(), containsString("Maximum expected number of routing weights having zero weight is [1]"));
MatcherAssert.assertThat(
exceptionReference.get().getMessage(),
containsString("Maximum expected number of routing weights having zero weight is [1]")
);
}

public void testAddWeightedRoutingFailsWhenDecommissionOngoing() throws InterruptedException {
Expand Down

0 comments on commit 7564cb2

Please sign in to comment.