本文整理汇总了Java中org.apache.bookkeeper.conf.ServerConfiguration.setZkServers方法的典型用法代码示例。如果您正苦于以下问题:Java ServerConfiguration.setZkServers方法的具体用法?Java ServerConfiguration.setZkServers怎么用?Java ServerConfiguration.setZkServers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.bookkeeper.conf.ServerConfiguration
的用法示例。
在下文中一共展示了ServerConfiguration.setZkServers方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newBookie
import org.apache.bookkeeper.conf.ServerConfiguration; //导入方法依赖的package包/类
BookieServer newBookie() throws Exception {
int port = nextPort++;
ServerConfiguration bookieConf = new ServerConfiguration();
bookieConf.setBookiePort(port);
File tmpdir = File.createTempFile("bookie" + Integer.toString(port) + "_",
"test");
tmpdir.delete();
tmpdir.mkdir();
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;
}
示例2: startBookie
import org.apache.bookkeeper.conf.ServerConfiguration; //导入方法依赖的package包/类
public void startBookie() throws Exception {
ServerConfiguration conf = new ServerConfiguration();
conf.setBookiePort(5621);
conf.setUseHostNameAsBookieID(true);
Path targetDir = path.resolve("bookie_data");
conf.setZkServers("localhost:1282");
conf.setLedgerDirNames(new String[]{targetDir.toAbsolutePath().toString()});
conf.setJournalDirName(targetDir.toAbsolutePath().toString());
conf.setFlushInterval(10000);
conf.setGcWaitTime(5);
conf.setJournalFlushWhenQueueEmpty(true);
// conf.setJournalBufferedEntriesThreshold(1);
conf.setAutoRecoveryDaemonEnabled(false);
conf.setEnableLocalTransport(true);
conf.setAllowLoopback(true);
conf.setProperty("journalMaxGroupWaitMSec", 10); // default 200ms
ClientConfiguration adminConf = new ClientConfiguration(conf);
BookKeeperAdmin.format(adminConf, false, true);
this.bookie = new BookieServer(conf);
this.bookie.start();
}
示例3: newServerConfiguration
import org.apache.bookkeeper.conf.ServerConfiguration; //导入方法依赖的package包/类
protected ServerConfiguration newServerConfiguration(int port, String zkServers, File journalDir,
File[] ledgerDirs) {
ServerConfiguration conf = new ServerConfiguration(baseConf);
conf.setBookiePort(port);
conf.setZkServers(zkServers);
conf.setJournalDirName(journalDir.getPath());
conf.setAllowLoopback(true);
conf.setFlushInterval(60 * 1000);
conf.setGcWaitTime(60 * 1000);
String[] ledgerDirNames = new String[ledgerDirs.length];
for (int i = 0; i < ledgerDirs.length; i++) {
ledgerDirNames[i] = ledgerDirs[i].getPath();
}
conf.setLedgerDirNames(ledgerDirNames);
conf.setLedgerStorageClass("org.apache.bookkeeper.bookie.storage.ldb.DbLedgerStorage");
return conf;
}
示例4: EmbeddedBookie
import org.apache.bookkeeper.conf.ServerConfiguration; //导入方法依赖的package包/类
/**
* Create an empty data directory for the Bookie server and configure
* the Bookie server.
* @param baseConf Base Bookie server configuration
* @param zkConnect ZooKeeper quorum specification (e.g., "host:port" or a
* list of "host:port" pairs)
* @param bookieId Unique identifier for this bookie
* @throws IOException If unable to create the data directory.
*/
EmbeddedBookie(ServerConfiguration baseConf, String zkConnect, int bookieId)
throws IOException {
this.bookieId = bookieId;
File bkTmpDir = new File(TEST_DIR) ;
bkTmpDir.mkdirs();
tmpDir = new File(BK_BOOKIE_DATA_DIR_PREFIX + bookieId);
FileUtil.fullyDelete(tmpDir);
if (!tmpDir.mkdirs()) {
throw new IOException("Unable to create bookie dir " + tmpDir);
}
bookieConf = new ServerConfiguration(baseConf);
bookieConf.setBookiePort(MiniDFSCluster.getFreePort());
bookieConf.setZkServers(zkConnect);
bookieConf.setJournalDirName(tmpDir.getPath());
bookieConf.setLedgerDirNames(new String[] { tmpDir.getPath() });
bookieConf.setLogger(LogFactory.getLog(this.getClass().toString()));
bookieRef = new AtomicReference<BookieServer>(null);
}
示例5: startBookie
import org.apache.bookkeeper.conf.ServerConfiguration; //导入方法依赖的package包/类
public void startBookie() throws Exception {
ServerConfiguration conf = new ServerConfiguration();
conf.setBookiePort(5621);
conf.setUseHostNameAsBookieID(true);
Path targetDir = path.resolve("bookie_data");
conf.setZkServers("localhost:1282");
conf.setLedgerDirNames(new String[]{targetDir.toAbsolutePath().toString()});
conf.setJournalDirName(targetDir.toAbsolutePath().toString());
conf.setFlushInterval(1000);
conf.setJournalFlushWhenQueueEmpty(true);
conf.setGcWaitTime(10);
conf.setAutoRecoveryDaemonEnabled(false);
// in unit tests we do not need real network for bookies
conf.setEnableLocalTransport(true);
// conf.setDisableServerSocketBind(true);
conf.setAllowLoopback(true);
ClientConfiguration adminConf = new ClientConfiguration(conf);
BookKeeperAdmin.format(adminConf, false, true);
this.bookie = new BookieServer(conf);
this.bookie.start();
}
示例6: startBookie
import org.apache.bookkeeper.conf.ServerConfiguration; //导入方法依赖的package包/类
public void startBookie() throws Exception {
ServerConfiguration conf = new ServerConfiguration();
conf.setBookiePort(5621);
conf.setUseHostNameAsBookieID(true);
Path targetDir = path.resolve("bookie_data");
conf.setZkServers("localhost:1282");
conf.setLedgerDirNames(new String[]{targetDir.toAbsolutePath().toString()});
conf.setJournalDirName(targetDir.toAbsolutePath().toString());
conf.setFlushInterval(1000);
conf.setAutoRecoveryDaemonEnabled(false);
conf.setAllowLoopback(true);
ClientConfiguration adminConf = new ClientConfiguration(conf);
BookKeeperAdmin.format(adminConf, false, true);
this.bookie = new BookieServer(conf);
this.bookie.start();
}
示例7: startBookie
import org.apache.bookkeeper.conf.ServerConfiguration; //导入方法依赖的package包/类
public void startBookie(boolean format) throws Exception {
if (bookie != null) {
throw new Exception("bookie already started");
}
ServerConfiguration conf = new ServerConfiguration();
conf.setBookiePort(5621);
conf.setUseHostNameAsBookieID(true);
Path targetDir = path.resolve("bookie_data");
conf.setZkServers("localhost:1282");
conf.setLedgerDirNames(new String[]{targetDir.toAbsolutePath().toString()});
conf.setJournalDirName(targetDir.toAbsolutePath().toString());
conf.setFlushInterval(10000);
conf.setGcWaitTime(5);
conf.setJournalFlushWhenQueueEmpty(true);
// conf.setJournalBufferedEntriesThreshold(1);
conf.setAutoRecoveryDaemonEnabled(false);
conf.setEnableLocalTransport(true);
conf.setAllowLoopback(true);
conf.setProperty("journalMaxGroupWaitMSec", 10); // default 200ms
if (format) {
ClientConfiguration adminConf = new ClientConfiguration(conf);
BookKeeperAdmin.format(adminConf, false, true);
}
this.bookie = new BookieServer(conf);
this.bookie.start();
}
示例8: newBookie
import org.apache.bookkeeper.conf.ServerConfiguration; //导入方法依赖的package包/类
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;
}