use of org.apache.bookkeeper.conf.ServerConfiguration in project distributedlog by twitter.
the class DLMTestUtil method loadTestBkConf.
public static ServerConfiguration loadTestBkConf() {
ServerConfiguration conf = new ServerConfiguration();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
URL confUrl = classLoader.getResource("bk_server.conf");
try {
if (null != confUrl) {
conf.loadConf(confUrl);
LOG.info("loaded bk_server.conf from resources");
}
} catch (org.apache.commons.configuration.ConfigurationException ex) {
LOG.warn("loading conf failed", ex);
}
conf.setAllowLoopback(true);
return conf;
}
use of org.apache.bookkeeper.conf.ServerConfiguration in project distributedlog by twitter.
the class LocalDLMEmulator method newBookie.
public BookieServer newBookie() throws Exception {
ServerConfiguration bookieConf = new ServerConfiguration();
bookieConf.setZkTimeout(zkTimeoutSec * 1000);
bookieConf.setBookiePort(0);
bookieConf.setAllowLoopback(true);
File tmpdir = File.createTempFile("bookie" + UUID.randomUUID() + "_", "test");
if (!tmpdir.delete()) {
LOG.debug("Fail to delete tmpdir " + tmpdir);
}
if (!tmpdir.mkdir()) {
throw new IOException("Fail to create tmpdir " + tmpdir);
}
tmpDirs.add(tmpdir);
bookieConf.setZkServers(zkEnsemble);
bookieConf.setJournalDirName(tmpdir.getPath());
bookieConf.setLedgerDirNames(new String[] { tmpdir.getPath() });
BookieServer b = new BookieServer(bookieConf);
b.start();
for (int i = 0; i < 10 && !b.isRunning(); i++) {
Thread.sleep(10000);
}
if (!b.isRunning()) {
throw new IOException("Bookie would not start");
}
return b;
}
use of org.apache.bookkeeper.conf.ServerConfiguration in project pulsar by yahoo.
the class BookKeeperClusterTestCase method restartBookies.
/**
* Restart bookie servers using new configuration settings. Also restart the respective auto recovery process, if
* isAutoRecoveryEnabled is true.
*
* @param newConf
* New Configuration Settings
* @throws InterruptedException
* @throws IOException
* @throws KeeperException
* @throws BookieException
*/
public void restartBookies(ServerConfiguration newConf) throws Exception {
// shut down bookie server
for (BookieServer server : bs) {
server.shutdown();
stopAutoRecoveryService(server);
}
bs.clear();
Thread.sleep(1000);
// restart them to ensure we can't
List<ServerConfiguration> bsConfsCopy = new ArrayList<ServerConfiguration>(bsConfs);
bsConfs.clear();
for (ServerConfiguration conf : bsConfsCopy) {
if (null != newConf) {
conf.loadConf(newConf);
}
startBookie(conf);
}
}
use of org.apache.bookkeeper.conf.ServerConfiguration 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