use of org.apache.bookkeeper.net.DNSToSwitchMapping in project distributedlog by twitter.
the class BookKeeperClient method commonInitialization.
@SuppressWarnings("deprecation")
private synchronized void commonInitialization(DistributedLogConfiguration conf, String ledgersPath, ClientSocketChannelFactory channelFactory, StatsLogger statsLogger, HashedWheelTimer requestTimer, boolean registerExpirationHandler) throws IOException, InterruptedException, KeeperException {
ClientConfiguration bkConfig = new ClientConfiguration();
bkConfig.setAddEntryTimeout(conf.getBKClientWriteTimeout());
bkConfig.setReadTimeout(conf.getBKClientReadTimeout());
bkConfig.setZkLedgersRootPath(ledgersPath);
bkConfig.setZkTimeout(conf.getBKClientZKSessionTimeoutMilliSeconds());
bkConfig.setNumWorkerThreads(conf.getBKClientNumberWorkerThreads());
bkConfig.setEnsemblePlacementPolicy(RegionAwareEnsemblePlacementPolicy.class);
bkConfig.setZkRequestRateLimit(conf.getBKClientZKRequestRateLimit());
bkConfig.setProperty(RegionAwareEnsemblePlacementPolicy.REPP_DISALLOW_BOOKIE_PLACEMENT_IN_REGION_FEATURE_NAME, DistributedLogConstants.DISALLOW_PLACEMENT_IN_REGION_FEATURE_NAME);
// reload configuration from dl configuration with settings prefixed with 'bkc.'
ConfUtils.loadConfiguration(bkConfig, conf, "bkc.");
Class<? extends DNSToSwitchMapping> dnsResolverCls;
try {
dnsResolverCls = conf.getEnsemblePlacementDnsResolverClass();
} catch (ConfigurationException e) {
LOG.error("Failed to load bk dns resolver : ", e);
throw new IOException("Failed to load bk dns resolver : ", e);
}
final DNSToSwitchMapping dnsResolver = NetUtils.getDNSResolver(dnsResolverCls, conf.getBkDNSResolverOverrides());
this.bkc = BookKeeper.newBuilder().config(bkConfig).zk(zkc.get()).channelFactory(channelFactory).statsLogger(statsLogger).dnsResolver(dnsResolver).requestTimer(requestTimer).featureProvider(featureProvider.orNull()).build();
if (registerExpirationHandler) {
sessionExpireWatcher = this.zkc.registerExpirationHandler(this);
}
}
use of org.apache.bookkeeper.net.DNSToSwitchMapping in project distributedlog by twitter.
the class TestNetUtils method testGetDNSResolverWithOverrides.
@Test(timeout = 20000)
public void testGetDNSResolverWithOverrides() throws Exception {
DNSToSwitchMapping dnsResolver = NetUtils.getDNSResolver(DNSResolverForRacks.class, "");
assertEquals("Should succeed to load " + DNSResolverForRacks.class, dnsResolver.getClass(), DNSResolverForRacks.class);
}
use of org.apache.bookkeeper.net.DNSToSwitchMapping in project distributedlog by twitter.
the class TestNetUtils method testGetDNSResolverWithDefaultConstructor.
@Test(timeout = 20000)
public void testGetDNSResolverWithDefaultConstructor() throws Exception {
DNSToSwitchMapping dnsResolver = NetUtils.getDNSResolver(DNSResolverWithDefaultConstructor.class, "");
assertEquals("Should succeed to load " + DNSResolverWithDefaultConstructor.class, dnsResolver.getClass(), DNSResolverWithDefaultConstructor.class);
}
Aggregations