Skip to content

Commit 672fc67

Browse files
zhengkezhou1hanmz
authored andcommitted
[improve][test] Clarify method signatures in Bookkeeper mock client (apache#23598)
1 parent 4303817 commit 672fc67

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

testmocks/src/main/java/org/apache/bookkeeper/client/BookKeeperTestClient.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,38 +71,38 @@ public BookieClient getBookieClient() {
7171
return bookieClient;
7272
}
7373

74-
public Future<?> waitForReadOnlyBookie(BookieId b)
74+
public Future<?> waitForReadOnlyBookie(BookieId id)
7575
throws Exception {
76-
return waitForBookieInSet(b, false);
76+
return waitForBookieInSet(id, false);
7777
}
7878

79-
public Future<?> waitForWritableBookie(BookieId b)
79+
public Future<?> waitForWritableBookie(BookieId id)
8080
throws Exception {
81-
return waitForBookieInSet(b, true);
81+
return waitForBookieInSet(id, true);
8282
}
8383

8484
/**
8585
* Wait for bookie to appear in either the writable set of bookies,
8686
* or the read only set of bookies. Also ensure that it doesn't exist
8787
* in the other set before completing.
8888
*/
89-
private Future<?> waitForBookieInSet(BookieId b,
89+
private Future<?> waitForBookieInSet(BookieId id,
9090
boolean writable) throws Exception {
9191
log.info("Wait for {} to become {}",
92-
b, writable ? "writable" : "readonly");
92+
id, writable ? "writable" : "readonly");
9393

9494
CompletableFuture<Void> readOnlyFuture = new CompletableFuture<>();
9595
CompletableFuture<Void> writableFuture = new CompletableFuture<>();
9696

9797
RegistrationListener readOnlyListener = (bookies) -> {
98-
boolean contains = bookies.getValue().contains(b);
99-
if ((!writable && contains) || (writable && !contains)) {
98+
boolean containsId = bookies.getValue().contains(id);
99+
if ((!writable && containsId) || (writable && !containsId)) {
100100
readOnlyFuture.complete(null);
101101
}
102102
};
103103
RegistrationListener writableListener = (bookies) -> {
104-
boolean contains = bookies.getValue().contains(b);
105-
if ((writable && contains) || (!writable && !contains)) {
104+
boolean containsId = bookies.getValue().contains(id);
105+
if ((writable && containsId) || (!writable && !containsId)) {
106106
writableFuture.complete(null);
107107
}
108108
};
@@ -114,7 +114,7 @@ private Future<?> waitForBookieInSet(BookieId b,
114114
return writableFuture
115115
.thenCompose(ignored -> getMetadataClientDriver().getRegistrationClient().getReadOnlyBookies())
116116
.thenCompose(readonlyBookies -> {
117-
if (readonlyBookies.getValue().contains(b)) {
117+
if (readonlyBookies.getValue().contains(id)) {
118118
// if the bookie still shows up at readonly path, wait for it to disappear
119119
return readOnlyFuture;
120120
} else {
@@ -125,7 +125,7 @@ private Future<?> waitForBookieInSet(BookieId b,
125125
return readOnlyFuture
126126
.thenCompose(ignored -> getMetadataClientDriver().getRegistrationClient().getWritableBookies())
127127
.thenCompose(writableBookies -> {
128-
if (writableBookies.getValue().contains(b)) {
128+
if (writableBookies.getValue().contains(id)) {
129129
// if the bookie still shows up at writable path, wait for it to disappear
130130
return writableFuture;
131131
} else {
@@ -139,7 +139,7 @@ private Future<?> waitForBookieInSet(BookieId b,
139139
* Force a read to zookeeper to get list of bookies.
140140
*
141141
* @throws InterruptedException
142-
* @throws KeeperException
142+
* @throws BKException
143143
*/
144144
public void readBookiesBlocking() throws InterruptedException, BKException {
145145
bookieWatcher.initialBlockingBookieRead();

testmocks/src/main/java/org/apache/bookkeeper/client/PulsarMockBookKeeper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ public OrderedExecutor getMainWorkerPool() {
105105
}
106106

107107
@Override
108-
public LedgerHandle createLedger(DigestType digestType, byte passwd[])
108+
public LedgerHandle createLedger(DigestType digestType, byte[] passwd)
109109
throws BKException, InterruptedException {
110110
return createLedger(3, 2, digestType, passwd);
111111
}
112112

113113
@Override
114-
public LedgerHandle createLedger(int ensSize, int qSize, DigestType digestType, byte passwd[])
114+
public LedgerHandle createLedger(int ensSize, int qSize, DigestType digestType, byte[] passwd)
115115
throws BKException, InterruptedException {
116116
return createLedger(ensSize, qSize, qSize, digestType, passwd);
117117
}

0 commit comments

Comments
 (0)