You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by "wenbingshen (via GitHub)" <gi...@apache.org> on 2023/01/30 12:14:13 UTC
[GitHub] [bookkeeper] wenbingshen commented on a diff in pull request #3726: Add parameters check on ledger creation
wenbingshen commented on code in PR #3726:
URL: https://github.com/apache/bookkeeper/pull/3726#discussion_r1090546251
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java:
##########
@@ -1663,4 +1657,17 @@ public ByteBufAllocator getByteBufAllocator() {
public ClientContext getClientCtx() {
return clientCtx;
}
+
+ private void checkLedgerCreationParameters(int ensSize, int writeQuorumSize, int ackQuorumSize) {
+ if (ensSize <= 0
+ || writeQuorumSize <= 0
+ || ackQuorumSize < 0
+ || writeQuorumSize > ensSize
+ || ackQuorumSize > writeQuorumSize) {
+ LOG.error("Illegal parameter: ensembleSize: {}, writeQuorumSize: {}, ackQuorumSize: {}",
Review Comment:
Illegal parameters
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java:
##########
@@ -1058,9 +1056,7 @@ public LedgerHandle createLedgerAdv(int ensSize, int writeQuorumSize, int ackQuo
public void asyncCreateLedgerAdv(final int ensSize, final int writeQuorumSize, final int ackQuorumSize,
final DigestType digestType, final byte[] passwd, final CreateCallback cb, final Object ctx,
final Map<String, byte[]> customMetadata) {
- if (writeQuorumSize < ackQuorumSize) {
- throw new IllegalArgumentException("Write quorum must be larger than ack quorum");
- }
+ checkLedgerCreationParameters(ensSize, writeQuorumSize, ackQuorumSize);
Review Comment:
+1
##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java:
##########
@@ -1127,4 +1127,193 @@ public void testBookieAddressResolverPassedToDNSToSwitchMapping() throws Excepti
}
}
+ @Test
+ public void testCreateLedgerWithIllegalArguments() throws Exception {
Review Comment:
+1
##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java:
##########
@@ -859,9 +859,7 @@ public void asyncCreateLedger(final int ensSize,
public void asyncCreateLedger(final int ensSize, final int writeQuorumSize, final int ackQuorumSize,
final DigestType digestType, final byte[] passwd,
final CreateCallback cb, final Object ctx, final Map<String, byte[]> customMetadata) {
- if (writeQuorumSize < ackQuorumSize) {
- throw new IllegalArgumentException("Write quorum must be larger than ack quorum");
- }
+ checkLedgerCreationParameters(ensSize, writeQuorumSize, ackQuorumSize);
Review Comment:
+1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org