All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nepxion.discovery.plugin.framework.configuration.ZookeeperLoadBalanceConfiguration Maven / Gradle / Ivy

There is a newer version: 6.2.0
Show newest version
package com.nepxion.discovery.plugin.framework.configuration;

/**
 * 

Title: Nepxion Discovery

*

Description: Nepxion Discovery

*

Copyright: Copyright (c) 2017-2050

*

Company: Nepxion

* @author Haojun Ren * @version 1.0 */ import org.apache.curator.x.discovery.ServiceDiscovery; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.cloud.zookeeper.discovery.ZookeeperInstance; import org.springframework.cloud.zookeeper.discovery.ZookeeperRibbonClientConfiguration; import org.springframework.cloud.zookeeper.discovery.dependency.ConditionalOnDependenciesNotPassed; import org.springframework.cloud.zookeeper.discovery.dependency.ConditionalOnDependenciesPassed; import org.springframework.cloud.zookeeper.discovery.dependency.ZookeeperDependencies; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.ConfigurableEnvironment; import com.nepxion.discovery.plugin.framework.decorator.ZookeeperServerListDecorator; import com.nepxion.discovery.plugin.framework.listener.loadbalance.LoadBalanceListenerExecutor; import com.netflix.client.config.IClientConfig; import com.netflix.loadbalancer.ServerList; @Configuration @AutoConfigureAfter(ZookeeperRibbonClientConfiguration.class) public class ZookeeperLoadBalanceConfiguration { @Autowired private ConfigurableEnvironment environment; @Autowired private LoadBalanceListenerExecutor loadBalanceListenerExecutor; @Bean @ConditionalOnDependenciesPassed public ServerList ribbonServerListFromDependencies(IClientConfig config, ZookeeperDependencies zookeeperDependencies, ServiceDiscovery serviceDiscovery) { ZookeeperServerListDecorator serverList = new ZookeeperServerListDecorator(serviceDiscovery); serverList.initFromDependencies(config, zookeeperDependencies); serverList.setEnvironment(environment); serverList.setLoadBalanceListenerExecutor(loadBalanceListenerExecutor); serverList.setServiceId(config.getClientName()); return serverList; } @Bean @ConditionalOnDependenciesNotPassed public ServerList ribbonServerList(IClientConfig config, ServiceDiscovery serviceDiscovery) { ZookeeperServerListDecorator serverList = new ZookeeperServerListDecorator(serviceDiscovery); serverList.initWithNiwsConfig(config); serverList.setEnvironment(environment); serverList.setLoadBalanceListenerExecutor(loadBalanceListenerExecutor); serverList.setServiceId(config.getClientName()); return serverList; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy