-
Notifications
You must be signed in to change notification settings - Fork 901
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4936d39
commit 70c7c67
Showing
18 changed files
with
6,570 additions
and
6,435 deletions.
There are no files selected for viewing
1,291 changes: 661 additions & 630 deletions
1,291
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperAdminTest.java
Large diffs are not rendered by default.
Oops, something went wrong.
568 changes: 296 additions & 272 deletions
568
...ver/src/test/java/org/apache/bookkeeper/client/BookKeeperClientTestsWithBookieErrors.java
Large diffs are not rendered by default.
Oops, something went wrong.
120 changes: 61 additions & 59 deletions
120
...er-server/src/test/java/org/apache/bookkeeper/client/BookKeeperClientZKSessionExpiry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,85 @@ | ||
/* | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
* | ||
*/ | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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; | ||
|
||
import org.apache.bookkeeper.test.BookKeeperClusterTestCase; | ||
import org.apache.bookkeeper.test.TestCallbacks.AddCallbackFuture; | ||
import org.apache.bookkeeper.zookeeper.ZooKeeperWatcherBase; | ||
import org.apache.zookeeper.ZooKeeper; | ||
import org.junit.Test; | ||
import org.junit.jupiter.api.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Test the bookkeeper client while losing a ZK session. | ||
*/ | ||
public class BookKeeperClientZKSessionExpiry extends BookKeeperClusterTestCase { | ||
private static final Logger LOG = LoggerFactory.getLogger(BookKeeperClientZKSessionExpiry.class); | ||
|
||
public BookKeeperClientZKSessionExpiry() { | ||
super(4); | ||
} | ||
private static final Logger LOG = LoggerFactory.getLogger(BookKeeperClientZKSessionExpiry.class); | ||
|
||
@Test | ||
public void testSessionLossWhileWriting() throws Exception { | ||
public BookKeeperClientZKSessionExpiry() { | ||
super(4); | ||
} | ||
|
||
Thread expiryThread = new Thread() { | ||
@Override | ||
public void run() { | ||
try { | ||
while (true) { | ||
Thread.sleep(5000); | ||
long sessionId = bkc.getZkHandle().getSessionId(); | ||
byte[] sessionPasswd = bkc.getZkHandle().getSessionPasswd(); | ||
@Test | ||
void sessionLossWhileWriting() throws Exception { | ||
|
||
try { | ||
ZooKeeperWatcherBase watcher = new ZooKeeperWatcherBase(10000, false); | ||
ZooKeeper zk = new ZooKeeper(zkUtil.getZooKeeperConnectString(), 10000, | ||
watcher, sessionId, sessionPasswd); | ||
zk.close(); | ||
} catch (Exception e) { | ||
LOG.info("Error killing session", e); | ||
} | ||
} | ||
} catch (InterruptedException ie) { | ||
Thread.currentThread().interrupt(); | ||
return; | ||
} | ||
} | ||
}; | ||
expiryThread.start(); | ||
Thread expiryThread = new Thread() { | ||
@Override | ||
public void run() { | ||
try { | ||
while (true) { | ||
Thread.sleep(5000); | ||
long sessionId = bkc.getZkHandle().getSessionId(); | ||
byte[] sessionPasswd = bkc.getZkHandle().getSessionPasswd(); | ||
|
||
for (int i = 0; i < 3; i++) { | ||
LedgerHandle lh = bkc.createLedger(3, 3, 2, BookKeeper.DigestType.MAC, "foobar".getBytes()); | ||
for (int j = 0; j < 100; j++) { | ||
lh.asyncAddEntry("foobar".getBytes(), new AddCallbackFuture(j), null); | ||
try { | ||
ZooKeeperWatcherBase watcher = new ZooKeeperWatcherBase(10000, true); | ||
ZooKeeper zk = new ZooKeeper(zkUtil.getZooKeeperConnectString(), 10000, watcher, | ||
sessionId, | ||
sessionPasswd); | ||
zk.close(); | ||
} catch (Exception e) { | ||
LOG.info("Error killing session", e); | ||
} | ||
startNewBookie(); | ||
killBookie(0); | ||
} | ||
} catch (InterruptedException ie) { | ||
Thread.currentThread().interrupt(); | ||
return; | ||
} | ||
} | ||
}; | ||
expiryThread.start(); | ||
|
||
lh.addEntry("lastEntry".getBytes()); | ||
for (int i = 0; i < 3; i++) { | ||
LedgerHandle lh = bkc.createLedger(3, 3, 2, BookKeeper.DigestType.MAC, "foobar".getBytes()); | ||
for (int j = 0; j < 100; j++) { | ||
lh.asyncAddEntry("foobar".getBytes(), new AddCallbackFuture(j), null); | ||
} | ||
startNewBookie(); | ||
killBookie(0); | ||
|
||
lh.close(); | ||
} | ||
lh.addEntry("lastEntry".getBytes()); | ||
|
||
lh.close(); | ||
} | ||
} | ||
} |
Oops, something went wrong.