use of org.apache.bookkeeper.proto.BookieServer in project pulsar by yahoo.
the class BookKeeperClusterTestCase method stopBKCluster.
/**
* Stop cluster. Also, stops all the auto recovery processes for the bookie cluster, if isAutoRecoveryEnabled is
* true.
*
* @throws Exception
*/
protected void stopBKCluster() throws Exception {
if (bkc != null) {
bkc.close();
}
for (BookieServer server : bs) {
server.shutdown();
AutoRecoveryMain autoRecovery = autoRecoveryProcesses.get(server);
if (autoRecovery != null && isAutoRecoveryEnabled()) {
autoRecovery.shutdown();
LOG.debug("Shutdown auto recovery for bookieserver:" + server.getLocalAddress());
}
}
bs.clear();
for (File f : tmpDirs) {
FileUtils.deleteDirectory(f);
}
}
use of org.apache.bookkeeper.proto.BookieServer in project pulsar by yahoo.
the class BookKeeperClusterTestCase method startBookie.
/**
* Helper method to startup a bookie server using a configuration object. Also, starts the auto recovery process if
* isAutoRecoveryEnabled is true.
*
* @param conf
* Server Configuration Object
*
*/
protected BookieServer startBookie(ServerConfiguration conf) throws Exception {
BookieServer server = new BookieServer(conf);
bsConfs.add(conf);
bs.add(server);
server.start();
if (bkc == null) {
bkc = new BookKeeperTestClient(baseClientConf);
}
int port = conf.getBookiePort();
while (bkc.getZkHandle().exists("/ledgers/available/" + InetAddress.getLocalHost().getHostAddress() + ":" + port, false) == null) {
Thread.sleep(500);
}
bkc.readBookiesBlocking();
LOG.info("New bookie on port " + port + " has been created.");
return server;
}
use of org.apache.bookkeeper.proto.BookieServer in project pulsar by yahoo.
the class BookKeeperClusterTestCase method sleepBookie.
/**
* Sleep a bookie until I count down the latch
*
* @param addr
* Socket Address
* @param latch
* Latch to wait on
* @throws InterruptedException
* @throws IOException
*/
public void sleepBookie(InetSocketAddress addr, final CountDownLatch l) throws Exception {
for (final BookieServer bookie : bs) {
if (bookie.getLocalAddress().equals(addr)) {
Thread sleeper = new Thread() {
@Override
public void run() {
try {
bookie.suspendProcessing();
l.await();
bookie.resumeProcessing();
} catch (Exception e) {
LOG.error("Error suspending bookie", e);
}
}
};
sleeper.start();
return;
}
}
throw new IOException("Bookie not found");
}
use of org.apache.bookkeeper.proto.BookieServer in project pravega by pravega.
the class BookKeeperServiceRunner method runBookie.
private BookieServer runBookie(int bkPort) throws Exception {
// Attempt to reuse an existing data directory. This is useful in case of stops & restarts, when we want to perserve
// already committed data.
File tmpDir = this.tempDirs.getOrDefault(bkPort, null);
if (tmpDir == null) {
tmpDir = IOUtils.createTempDir("bookie_" + bkPort, "test");
tmpDir.deleteOnExit();
this.tempDirs.put(bkPort, tmpDir);
log.info("Created " + tmpDir);
if (!tmpDir.delete() || !tmpDir.mkdir()) {
throw new IOException("Couldn't create bookie dir " + tmpDir);
}
}
val conf = new ServerConfiguration();
conf.setBookiePort(bkPort);
conf.setZkServers(LOOPBACK_ADDRESS.getHostAddress() + ":" + this.zkPort);
conf.setJournalDirName(tmpDir.getPath());
conf.setLedgerDirNames(new String[] { tmpDir.getPath() });
conf.setAllowLoopback(true);
conf.setJournalAdaptiveGroupWrites(false);
conf.setZkLedgersRootPath(ledgersPath);
if (secureBK) {
conf.setTLSProvider("OpenSSL");
conf.setTLSProviderFactoryClass("org.apache.bookkeeper.tls.TLSContextFactory");
conf.setTLSKeyStore(this.tLSKeyStore);
conf.setTLSKeyStorePasswordPath(this.tLSKeyStorePasswordPath);
}
log.info("Starting Bookie at port " + bkPort);
val bs = new BookieServer(conf);
bs.start();
return bs;
}
Aggregations