当前位置: 首页>>代码示例>>Java>>正文


Java ClientConfiguration类代码示例

本文整理汇总了Java中org.apache.bookkeeper.conf.ClientConfiguration的典型用法代码示例。如果您正苦于以下问题:Java ClientConfiguration类的具体用法?Java ClientConfiguration怎么用?Java ClientConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ClientConfiguration类属于org.apache.bookkeeper.conf包,在下文中一共展示了ClientConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startBookie

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的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();
    }
 
开发者ID:diennea,项目名称:herddb,代码行数:25,代码来源:ZKTestEnv.java

示例2: getAndSetZkCache

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的package包/类
private ZooKeeperCache getAndSetZkCache(Configuration conf) {
    ZooKeeperCache zkCache = null;
    if (conf.getProperty(ZooKeeperCache.ZK_CACHE_INSTANCE) != null) {
        zkCache = (ZooKeeperCache) conf.getProperty(ZooKeeperCache.ZK_CACHE_INSTANCE);
    } else {
        int zkTimeout;
        String zkServers;
        if (conf instanceof ClientConfiguration) {
            zkTimeout = ((ClientConfiguration) conf).getZkTimeout();
            zkServers = ((ClientConfiguration) conf).getZkServers();
            ZooKeeperWatcherBase w = new ZooKeeperWatcherBase(zkTimeout) {
            };
            try {
                ZooKeeper zkClient = ZkUtils.createConnectedZookeeperClient(zkServers, w);
                zkCache = new ZooKeeperCache(zkClient) {
                };
                conf.addProperty(ZooKeeperCache.ZK_CACHE_INSTANCE, zkCache);
            } catch (Exception e) {
                LOG.error("Error creating zookeeper client", e);
            }
        } else {
            LOG.error("No zk configurations available");
        }
    }
    return zkCache;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:27,代码来源:ZkIsolatedBookieEnsemblePlacementPolicy.java

示例3: testNoIsolationGroup

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的package包/类
@Test
public void testNoIsolationGroup() throws Exception {
    String data = "{\"group1\": {\"" + BOOKIE1
            + "\": {\"rack\": \"rack0\", \"hostname\": \"bookie1.example.com\"}, \"" + BOOKIE2
            + "\": {\"rack\": \"rack1\", \"hostname\": \"bookie2.example.com\"}}, \"group2\": {\"" + BOOKIE3
            + "\": {\"rack\": \"rack0\", \"hostname\": \"bookie3.example.com\"}, \"" + BOOKIE4
            + "\": {\"rack\": \"rack2\", \"hostname\": \"bookie4.example.com\"}}}";

    ZkUtils.createFullPathOptimistic(localZkc, ZkBookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, data.getBytes(),
            ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

    Thread.sleep(100);

    ZkIsolatedBookieEnsemblePlacementPolicy isolationPolicy = new ZkIsolatedBookieEnsemblePlacementPolicy();
    ClientConfiguration bkClientConf = new ClientConfiguration();
    bkClientConf.setProperty(ZooKeeperCache.ZK_CACHE_INSTANCE, new ZooKeeperCache(localZkc) {
    });
    isolationPolicy.initialize(bkClientConf);
    isolationPolicy.onClusterChanged(writableBookies, readOnlyBookies);

    isolationPolicy.newEnsemble(4, 4, new HashSet<>());
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:23,代码来源:ZkIsolatedBookieEnsemblePlacementPolicyTest.java

示例4: ReplicatedCommitLog

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的package包/类
public ReplicatedCommitLog(String zkAddress, int zkTimeout, String zkPath, Path snapshotsDirectory, byte[] localhostdata,
    boolean writeacls, Map<String, String> bookkeeperConfiguration) throws Exception {
    if (localhostdata == null) {
        localhostdata = new byte[0];
    }
    ClientConfiguration config = new ClientConfiguration();
    config.setEnableParallelRecoveryRead(true);
    config.setThrottleValue(0);
    config.setEnableDigestTypeAutodetection(true);
    bookkeeperConfiguration.forEach((k, v) -> {
        LOGGER.log(Level.INFO, "extra bookkeeper client property " + k + "=" + v);
        config.setProperty(k, v);
    });
    try {
        this.zKClusterManager = new ZKClusterManager(zkAddress, zkTimeout, zkPath, leaderShiplistener, localhostdata, writeacls);
        this.zKClusterManager.waitForConnection();
        this.bookKeeper = new BookKeeper(config, zKClusterManager.getZooKeeper());
        this.snapshotsDirectory = snapshotsDirectory;
        this.zKClusterManager.start();
    } catch (Exception t) {
        close();
        throw t;
    }
}
 
开发者ID:diennea,项目名称:majordodo,代码行数:25,代码来源:ReplicatedCommitLog.java

示例5: startBookie

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的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();
    }
 
开发者ID:diennea,项目名称:majordodo,代码行数:26,代码来源:ZKTestEnv.java

示例6: startBookie

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的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();
}
 
开发者ID:diennea,项目名称:majordodo,代码行数:20,代码来源:ZKTestEnv.java

示例7: LogManagerFactoryImpl

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的package包/类
public LogManagerFactoryImpl(ClientConfiguration clientConfiguration, BookKeeperConfig config)
	throws Exception {
	bookKeeperConfig = config;
	checkNotNull(clientConfiguration);
	String servers = clientConfiguration.getZkServers();
	checkNotNull(servers);
	final CountDownLatch countDownLatch = new CountDownLatch(1);

	zooKeeper = new ZooKeeper(servers, clientConfiguration.getZkTimeout(), event -> {
		if (event.getState() == Watcher.Event.KeeperState.SyncConnected) {
			logger.info("Connected to zookeeper ,connectString = {}", servers);
			countDownLatch.countDown();
		} else {
			logger.error("Failed to connect zookeeper,connectString = {}", servers);
		}
	});
	if (!countDownLatch.await(clientConfiguration.getZkTimeout(), TimeUnit.MILLISECONDS)
		|| zooKeeper.getState() != ZooKeeper.States.CONNECTED) {
		throw new LedgerStorageException(
			"Error connecting to zookeeper server ,connectString = " + servers + ".");
	}

	this.bookKeeper = new BookKeeper(clientConfiguration, zooKeeper);
	RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
	CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient(servers, retryPolicy);
	curatorFramework.start();
	asyncCuratorFramework = AsyncCuratorFramework.wrap(curatorFramework);
	logInfoStorage = new LogInfoStorageImpl(asyncCuratorFramework);
	offsetStorage = new ZkOffsetStorageImpl(logInfoStorage, asyncCuratorFramework);
}
 
开发者ID:aCoder2013,项目名称:fastmq,代码行数:31,代码来源:LogManagerFactoryImpl.java

示例8: initialize

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的package包/类
@Override
public EnsemblePlacementPolicy initialize(ClientConfiguration conf,
    Optional<DNSToSwitchMapping> optionalDnsResolver,
    HashedWheelTimer hashedWheelTimer,
    FeatureProvider featureProvider, StatsLogger statsLogger) {
    return this;
}
 
开发者ID:diennea,项目名称:herddb,代码行数:8,代码来源:PreferLocalBookiePlacementPolicy.java

示例9: startBookie

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的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();
    }
 
开发者ID:diennea,项目名称:herddb,代码行数:30,代码来源:ZKTestEnv.java

示例10: internalSetup

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的package包/类
protected final void internalSetup() throws Exception {
    init();
    org.apache.pulsar.client.api.ClientConfiguration clientConf = new org.apache.pulsar.client.api.ClientConfiguration();
    clientConf.setStatsInterval(0, TimeUnit.SECONDS);
    lookupUrl = new URI(brokerUrl.toString());
    if (isTcpLookup) {
        lookupUrl = new URI("pulsar://localhost:" + BROKER_PORT);
    }
    pulsarClient = PulsarClient.create(lookupUrl.toString(), clientConf);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:11,代码来源:MockedPulsarServiceBaseTest.java

示例11: internalSetupForStatsTest

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的package包/类
protected final void internalSetupForStatsTest() throws Exception {
    init();
    org.apache.pulsar.client.api.ClientConfiguration clientConf = new org.apache.pulsar.client.api.ClientConfiguration();
    clientConf.setStatsInterval(1, TimeUnit.SECONDS);
    String lookupUrl = brokerUrl.toString();
    if (isTcpLookup) {
        lookupUrl = new URI("pulsar://localhost:" + BROKER_PORT).toString();
    }
    pulsarClient = PulsarClient.create(lookupUrl, clientConf);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:11,代码来源:MockedPulsarServiceBaseTest.java

示例12: getAndSetZkCache

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的package包/类
private ZooKeeperDataCache<Map<String, Map<BookieSocketAddress, BookieInfo>>> getAndSetZkCache(Configuration conf) {
    ZooKeeperCache zkCache = null;
    if (conf.getProperty(ZooKeeperCache.ZK_CACHE_INSTANCE) != null) {
        zkCache = (ZooKeeperCache) conf.getProperty(ZooKeeperCache.ZK_CACHE_INSTANCE);
    } else {
        int zkTimeout;
        String zkServers;
        if (conf instanceof ClientConfiguration) {
            zkTimeout = ((ClientConfiguration) conf).getZkTimeout();
            zkServers = ((ClientConfiguration) conf).getZkServers();
            ZooKeeperWatcherBase w = new ZooKeeperWatcherBase(zkTimeout) {
            };
            try {
                ZooKeeper zkClient = ZkUtils.createConnectedZookeeperClient(zkServers, w);
                zkCache = new ZooKeeperCache(zkClient) {
                };
                conf.addProperty(ZooKeeperCache.ZK_CACHE_INSTANCE, zkCache);
            } catch (Exception e) {
                LOG.error("Error creating zookeeper client", e);
            }
        } else {
            LOG.error("No zk configurations available");
        }
    }
    ZooKeeperDataCache<Map<String, Map<BookieSocketAddress, BookieInfo>>> zkDataCache = getZkBookieRackMappingCache(
            zkCache);
    if (zkDataCache != null) {
        zkDataCache.registerListener(this);
    }
    return zkDataCache;
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:32,代码来源:ZkBookieRackAffinityMapping.java

示例13: testBasic

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的package包/类
@Test
public void testBasic() throws Exception {
    String data = "{\"group1\": {\"" + BOOKIE1
            + "\": {\"rack\": \"/rack0\", \"hostname\": \"bookie1.example.com\"}, \"" + BOOKIE2
            + "\": {\"rack\": \"/rack1\", \"hostname\": \"bookie2.example.com\"}}}";
    ZkUtils.createFullPathOptimistic(localZkc, ZkBookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, data.getBytes(),
            ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

    // Case1: ZKCache is given
    ZkBookieRackAffinityMapping mapping1 = new ZkBookieRackAffinityMapping();
    ClientConfiguration bkClientConf1 = new ClientConfiguration();
    bkClientConf1.setProperty(ZooKeeperCache.ZK_CACHE_INSTANCE, new ZooKeeperCache(localZkc) {
    });
    mapping1.setConf(bkClientConf1);
    List<String> racks1 = mapping1.resolve(Lists.newArrayList(BOOKIE1, BOOKIE2, BOOKIE3));
    assertEquals(racks1.get(0), "/rack0");
    assertEquals(racks1.get(1), "/rack1");
    assertEquals(racks1.get(2), NetworkTopology.DEFAULT_RACK);

    // Case 2: ZkServers and ZkTimeout are given (ZKCache will be constructed in
    // ZkBookieRackAffinityMapping#setConf)
    ZkBookieRackAffinityMapping mapping2 = new ZkBookieRackAffinityMapping();
    ClientConfiguration bkClientConf2 = new ClientConfiguration();
    bkClientConf2.setZkServers("127.0.0.1" + ":" + LOCAL_ZOOKEEPER_PORT);
    bkClientConf2.setZkTimeout(1000);
    mapping2.setConf(bkClientConf2);
    List<String> racks2 = mapping2.resolve(Lists.newArrayList(BOOKIE1, BOOKIE2, BOOKIE3));
    assertEquals(racks2.get(0), "/rack0");
    assertEquals(racks2.get(1), "/rack1");
    assertEquals(racks2.get(2), NetworkTopology.DEFAULT_RACK);

    localZkc.delete(ZkBookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, -1);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:34,代码来源:ZkBookieRackAffinityMappingTest.java

示例14: testNoBookieInfo

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的package包/类
@Test
public void testNoBookieInfo() throws Exception {
    ZkBookieRackAffinityMapping mapping = new ZkBookieRackAffinityMapping();
    ClientConfiguration bkClientConf = new ClientConfiguration();
    bkClientConf.setProperty(ZooKeeperCache.ZK_CACHE_INSTANCE, new ZooKeeperCache(localZkc) {
    });
    mapping.setConf(bkClientConf);
    List<String> racks = mapping.resolve(Lists.newArrayList(BOOKIE1, BOOKIE2, BOOKIE3));
    assertEquals(racks.get(0), NetworkTopology.DEFAULT_RACK);
    assertEquals(racks.get(1), NetworkTopology.DEFAULT_RACK);
    assertEquals(racks.get(2), NetworkTopology.DEFAULT_RACK);

    Map<String, Map<BookieSocketAddress, BookieInfo>> bookieMapping = new HashMap<>();
    Map<BookieSocketAddress, BookieInfo> mainBookieGroup = new HashMap<>();

    BookieInfo bookieInfo0 = new BookieInfo();
    bookieInfo0.setRack("/rack0");
    mainBookieGroup.put(BOOKIE1, bookieInfo0);

    BookieInfo bookieInfo1 = new BookieInfo();
    bookieInfo1.setRack("/rack1");
    mainBookieGroup.put(BOOKIE2, bookieInfo1);

    bookieMapping.put("group1", mainBookieGroup);

    ZkUtils.createFullPathOptimistic(localZkc, ZkBookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH,
            jsonMapper.writeValueAsBytes(bookieMapping), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

    Thread.sleep(100);

    racks = mapping.resolve(Lists.newArrayList(BOOKIE1, BOOKIE2, BOOKIE3));
    assertEquals(racks.get(0), "/rack0");
    assertEquals(racks.get(1), "/rack1");
    assertEquals(racks.get(2), NetworkTopology.DEFAULT_RACK);

    localZkc.delete(ZkBookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, -1);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:38,代码来源:ZkBookieRackAffinityMappingTest.java

示例15: testNoBookieInfo

import org.apache.bookkeeper.conf.ClientConfiguration; //导入依赖的package包/类
@Test
public void testNoBookieInfo() throws Exception {
    ZkIsolatedBookieEnsemblePlacementPolicy isolationPolicy = new ZkIsolatedBookieEnsemblePlacementPolicy();
    ClientConfiguration bkClientConf = new ClientConfiguration();
    bkClientConf.setProperty(ZooKeeperCache.ZK_CACHE_INSTANCE, new ZooKeeperCache(localZkc) {
    });
    bkClientConf.setProperty(ZkIsolatedBookieEnsemblePlacementPolicy.ISOLATION_BOOKIE_GROUPS, isolationGroups);
    isolationPolicy.initialize(bkClientConf);
    isolationPolicy.onClusterChanged(writableBookies, readOnlyBookies);

    isolationPolicy.newEnsemble(4, 4, new HashSet<>());

    String data = "{\"group1\": {\"" + BOOKIE1
            + "\": {\"rack\": \"rack0\", \"hostname\": \"bookie1.example.com\"}, \"" + BOOKIE2
            + "\": {\"rack\": \"rack1\", \"hostname\": \"bookie2.example.com\"}}, \"group2\": {\"" + BOOKIE3
            + "\": {\"rack\": \"rack0\", \"hostname\": \"bookie3.example.com\"}, \"" + BOOKIE4
            + "\": {\"rack\": \"rack2\", \"hostname\": \"bookie4.example.com\"}}}";

    ZkUtils.createFullPathOptimistic(localZkc, ZkBookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, data.getBytes(),
            ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);

    Thread.sleep(100);

    ArrayList<BookieSocketAddress> ensemble = isolationPolicy.newEnsemble(2, 2, new HashSet<>());
    assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE1)));
    assertTrue(ensemble.contains(new BookieSocketAddress(BOOKIE2)));

    try {
        isolationPolicy.newEnsemble(3, 3, new HashSet<>());
        fail("should not pass");
    } catch (BKNotEnoughBookiesException e) {
        // ok
    }

    localZkc.delete(ZkBookieRackAffinityMapping.BOOKIE_INFO_ROOT_PATH, -1);
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:37,代码来源:ZkIsolatedBookieEnsemblePlacementPolicyTest.java


注:本文中的org.apache.bookkeeper.conf.ClientConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。