use of com.linkedin.d2.balancer.zkfs.ZKFSComponentFactory in project rest.li by linkedin.
the class ZKFSLoadBalancerWithFacilitiesFactory method createLoadBalancerFactory.
private ZKFSLoadBalancer.TogglingLoadBalancerFactory createLoadBalancerFactory(D2ClientConfig config) {
final ZKFSTogglingLoadBalancerFactoryImpl.ComponentFactory loadBalancerComponentFactory;
if (config.componentFactory == null) {
loadBalancerComponentFactory = new ZKFSComponentFactory();
} else {
loadBalancerComponentFactory = config.componentFactory;
}
D2ClientJmxManager d2ClientJmxManager = new D2ClientJmxManager(config.d2JmxManagerPrefix, config.jmxManager);
return new ZKFSTogglingLoadBalancerFactoryImpl(loadBalancerComponentFactory, config.lbWaitTimeout, config.lbWaitUnit, config.basePath, config.fsBasePath, config.clientFactories, config.loadBalancerStrategyFactories, config.d2ServicePath, config.sslContext, config.sslParameters, config.isSSLEnabled, config.clientServicesConfig, config.useNewEphemeralStoreWatcher, config.partitionAccessorRegistry, config.enableSaveUriDataOnDisk, config.sslSessionValidatorFactory, d2ClientJmxManager, config.zookeeperReadWindowMs, config.deterministicSubsettingMetadataProvider);
}
use of com.linkedin.d2.balancer.zkfs.ZKFSComponentFactory in project rest.li by linkedin.
the class LoadBalancerClientCli method getZKFSLoadBalancer.
public ZKFSLoadBalancer getZKFSLoadBalancer(String zkConnectString, String d2path, String d2ServicePath) throws Exception {
_tmpDir = createTempDirectory(_tmpdirName);
ZKFSComponentFactory componentFactory = new ZKFSComponentFactory();
if (d2ServicePath == null || d2ServicePath.isEmpty()) {
d2ServicePath = "services";
}
Map<String, TransportClientFactory> clientFactories = new HashMap<>();
clientFactories.put("http", new HttpClientFactory.Builder().build());
Map<String, LoadBalancerStrategyFactory<? extends LoadBalancerStrategy>> loadBalancerStrategyFactories = new HashMap<>();
loadBalancerStrategyFactories.put("random", new RandomLoadBalancerStrategyFactory());
loadBalancerStrategyFactories.put("degrader", new DegraderLoadBalancerStrategyFactoryV3());
loadBalancerStrategyFactories.put("degraderV2", new DegraderLoadBalancerStrategyFactoryV3());
loadBalancerStrategyFactories.put("degraderV3", new DegraderLoadBalancerStrategyFactoryV3());
loadBalancerStrategyFactories.put("degraderV2_1", new DegraderLoadBalancerStrategyFactoryV3());
ZKFSTogglingLoadBalancerFactoryImpl factory = new ZKFSTogglingLoadBalancerFactoryImpl(componentFactory, TIMEOUT, TimeUnit.MILLISECONDS, d2path, _tmpDir.getAbsolutePath(), clientFactories, loadBalancerStrategyFactories, d2ServicePath, null, null, false);
return new ZKFSLoadBalancer(zkConnectString, SESSION_TIMEOUT, (int) TIMEOUT, factory, null, d2path);
}
use of com.linkedin.d2.balancer.zkfs.ZKFSComponentFactory in project rest.li by linkedin.
the class ZKFSTest method getBalancer.
private ZKFSLoadBalancer getBalancer() {
ZKFSComponentFactory f = new ZKFSComponentFactory();
Map<String, LoadBalancerStrategyFactory<? extends LoadBalancerStrategy>> loadBalancerStrategyFactories = new HashMap<>();
loadBalancerStrategyFactories.put("degrader", new DegraderLoadBalancerStrategyFactoryV3());
Map<String, TransportClientFactory> clientFactories = new HashMap<>();
clientFactories.put("http", new HttpClientFactory.Builder().build());
// We rely on _tmpdir below being fresh for each test case. Otherwise, leftover files in
// _tmpdir from a previous test could affect another test. This is accomplished with the
// @BeforeMethod and @AfterMethod annotations.
ZKFSTogglingLoadBalancerFactoryImpl f2 = new ZKFSTogglingLoadBalancerFactoryImpl(f, 5, TimeUnit.SECONDS, BASE_PATH, _tmpdir.getAbsolutePath(), clientFactories, loadBalancerStrategyFactories);
ZKFSLoadBalancer balancer = new ZKFSLoadBalancer("localhost:" + PORT, 60000, 5000, f2, null, BASE_PATH);
return balancer;
}
Aggregations