This is an automated email from the ASF dual-hosted git repository.
eolivelli pushed a commit to branch branch-4.6
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/branch-4.6 by this push:
new 3370e67 Add descriptive message for TooManyRequestsException
3370e67 is described below
commit 3370e6745dbb48f7200d132b1de005ca20e458e3
Author: Enrico Olivelli <[email protected]>
AuthorDate: Tue Jan 9 10:58:35 2018 +0100
Add descriptive message for TooManyRequestsException
After upgrading from 4.5 to 4.6 I found a lot of "Unexpected condition" in
some benchmarks.
TooManyRequestsException is a new error introduced in 4.6, there is not
description, so the default description is "Unexpected condition", without a
debugger it is not possible to understand the cause of the error.
Author: Enrico Olivelli <[email protected]>
Author: eolivelli <[email protected]>
Reviewers: Sijie Guo <[email protected]>
This closes #921 from eolivelli/toomanyrequests-message
(cherry picked from commit 52f511e1a5cbd136e48528e5ed66630250593198)
Signed-off-by: Enrico Olivelli <[email protected]>
---
.../apache/bookkeeper/client/api/BKException.java | 2 +
.../bookkeeper/client/api/BKExceptionTest.java | 50 ++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/BKException.java
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/BKException.java
index 07bcf0f..6ea9797 100644
---
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/BKException.java
+++
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/BKException.java
@@ -111,6 +111,8 @@ public abstract class BKException extends Exception {
return "Attempting to use an unclosed fragment; This is not safe";
case Code.WriteOnReadOnlyBookieException:
return "Attempting to write on ReadOnly bookie";
+ case Code.TooManyRequestsException:
+ return "Too many requests to the same Bookie";
case Code.LedgerIdOverflowException:
return "Next ledgerID is too large.";
case Code.ReplicationException:
diff --git
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/api/BKExceptionTest.java
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/api/BKExceptionTest.java
new file mode 100644
index 0000000..25f1d8f
--- /dev/null
+++
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/api/BKExceptionTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2017 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.bookkeeper.client.api;
+
+import static
org.apache.bookkeeper.client.api.BKException.Code.UnexpectedConditionException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Field;
+import org.junit.Test;
+
+/**
+ * Tests for BKException methods.
+ */
+public class BKExceptionTest {
+
+ @Test
+ public void testGetMessage() throws Exception {
+ Field[] fields = BKException.Code.class.getFields();
+ int count = 0;
+ for (Field f : fields) {
+ if (f.getType() == Integer.TYPE &&
!f.getName().equals("UNINITIALIZED")) {
+ int code = f.getInt(null);
+ String msg = BKException.getMessage(code);
+ if (code == UnexpectedConditionException) {
+ assertEquals("Unexpected condition", msg);
+ } else {
+ assertNotEquals("failure on code " + f.getName(),
"Unexpected condition", msg);
+ }
+ count++;
+ }
+ }
+ // assert that we found at least 1 code other than
UnexpectedConditionException
+ assertTrue(count > 2);
+ }
+}
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].