Search in sources :

Example 1 with ZKFSComponentFactory

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);
}
Also used : ZKFSTogglingLoadBalancerFactoryImpl(com.linkedin.d2.balancer.zkfs.ZKFSTogglingLoadBalancerFactoryImpl) D2ClientJmxManager(com.linkedin.d2.jmx.D2ClientJmxManager) ZKFSComponentFactory(com.linkedin.d2.balancer.zkfs.ZKFSComponentFactory)

Example 2 with ZKFSComponentFactory

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);
}
Also used : ZKFSTogglingLoadBalancerFactoryImpl(com.linkedin.d2.balancer.zkfs.ZKFSTogglingLoadBalancerFactoryImpl) HashMap(java.util.HashMap) RandomLoadBalancerStrategyFactory(com.linkedin.d2.balancer.strategies.random.RandomLoadBalancerStrategyFactory) LoadBalancerStrategyFactory(com.linkedin.d2.balancer.strategies.LoadBalancerStrategyFactory) DegraderLoadBalancerStrategyFactoryV3(com.linkedin.d2.balancer.strategies.degrader.DegraderLoadBalancerStrategyFactoryV3) RandomLoadBalancerStrategyFactory(com.linkedin.d2.balancer.strategies.random.RandomLoadBalancerStrategyFactory) RestRequestBuilder(com.linkedin.r2.message.rest.RestRequestBuilder) LoadBalancerStrategy(com.linkedin.d2.balancer.strategies.LoadBalancerStrategy) ZKFSComponentFactory(com.linkedin.d2.balancer.zkfs.ZKFSComponentFactory) ZKFSLoadBalancer(com.linkedin.d2.balancer.zkfs.ZKFSLoadBalancer) TransportClientFactory(com.linkedin.r2.transport.common.TransportClientFactory)

Example 3 with ZKFSComponentFactory

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;
}
Also used : LoadBalancerStrategyFactory(com.linkedin.d2.balancer.strategies.LoadBalancerStrategyFactory) HashMap(java.util.HashMap) DegraderLoadBalancerStrategyFactoryV3(com.linkedin.d2.balancer.strategies.degrader.DegraderLoadBalancerStrategyFactoryV3) LoadBalancerStrategy(com.linkedin.d2.balancer.strategies.LoadBalancerStrategy) TransportClientFactory(com.linkedin.r2.transport.common.TransportClientFactory)

Aggregations

LoadBalancerStrategy (com.linkedin.d2.balancer.strategies.LoadBalancerStrategy)2 LoadBalancerStrategyFactory (com.linkedin.d2.balancer.strategies.LoadBalancerStrategyFactory)2 DegraderLoadBalancerStrategyFactoryV3 (com.linkedin.d2.balancer.strategies.degrader.DegraderLoadBalancerStrategyFactoryV3)2 ZKFSComponentFactory (com.linkedin.d2.balancer.zkfs.ZKFSComponentFactory)2 ZKFSTogglingLoadBalancerFactoryImpl (com.linkedin.d2.balancer.zkfs.ZKFSTogglingLoadBalancerFactoryImpl)2 TransportClientFactory (com.linkedin.r2.transport.common.TransportClientFactory)2 HashMap (java.util.HashMap)2 RandomLoadBalancerStrategyFactory (com.linkedin.d2.balancer.strategies.random.RandomLoadBalancerStrategyFactory)1 ZKFSLoadBalancer (com.linkedin.d2.balancer.zkfs.ZKFSLoadBalancer)1 D2ClientJmxManager (com.linkedin.d2.jmx.D2ClientJmxManager)1 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)1