diff --git a/docs/pom.xml b/docs/pom.xml
index c8fc900d..a58f32d0 100644
--- a/docs/pom.xml
+++ b/docs/pom.xml
@@ -6,7 +6,7 @@
org.springframework.cloud
spring-cloud-zookeeper
- 2.2.1.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
spring-cloud-zookeeper-docs
pom
diff --git a/pom.xml b/pom.xml
index 51622c5d..456aa5fb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
org.springframework.cloud
spring-cloud-zookeeper
- 2.2.1.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
pom
Spring Cloud Zookeeper
Spring Cloud Zookeeper
@@ -14,7 +14,7 @@
org.springframework.cloud
spring-cloud-build
- 2.2.2.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
@@ -97,19 +97,6 @@
pom
import
-
-
- commons-configuration
- commons-configuration
- 1.8
-
-
- commons-logging
- commons-logging
-
-
-
-
cglib
cglib-nodep
@@ -177,11 +164,11 @@
- 2.2.2.BUILD-SNAPSHOT
- 2.2.2.BUILD-SNAPSHOT
- 2.2.2.BUILD-SNAPSHOT
- 2.2.2.BUILD-SNAPSHOT
- 2.2.2.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
diff --git a/spring-cloud-starter-zookeeper-all/pom.xml b/spring-cloud-starter-zookeeper-all/pom.xml
index 13a75176..e50614b0 100644
--- a/spring-cloud-starter-zookeeper-all/pom.xml
+++ b/spring-cloud-starter-zookeeper-all/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-zookeeper
- 2.2.1.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
..
spring-cloud-starter-zookeeper-all
diff --git a/spring-cloud-starter-zookeeper-config/pom.xml b/spring-cloud-starter-zookeeper-config/pom.xml
index 11ee679c..e70dbd63 100644
--- a/spring-cloud-starter-zookeeper-config/pom.xml
+++ b/spring-cloud-starter-zookeeper-config/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-zookeeper
- 2.2.1.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
..
spring-cloud-starter-zookeeper-config
diff --git a/spring-cloud-starter-zookeeper-discovery/pom.xml b/spring-cloud-starter-zookeeper-discovery/pom.xml
index 120b468d..425f4d0f 100644
--- a/spring-cloud-starter-zookeeper-discovery/pom.xml
+++ b/spring-cloud-starter-zookeeper-discovery/pom.xml
@@ -6,7 +6,7 @@
org.springframework.cloud
spring-cloud-zookeeper
- 2.2.1.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
..
spring-cloud-starter-zookeeper-discovery
@@ -33,18 +33,6 @@
org.apache.curator
curator-x-discovery
-
- org.springframework.cloud
- spring-cloud-netflix-hystrix
-
-
- org.springframework.cloud
- spring-cloud-starter-netflix-archaius
-
-
- org.springframework.cloud
- spring-cloud-starter-netflix-ribbon
-
org.springframework.cloud
spring-cloud-starter-loadbalancer
diff --git a/spring-cloud-starter-zookeeper/pom.xml b/spring-cloud-starter-zookeeper/pom.xml
index bf66fa1a..952fea57 100644
--- a/spring-cloud-starter-zookeeper/pom.xml
+++ b/spring-cloud-starter-zookeeper/pom.xml
@@ -5,7 +5,7 @@
org.springframework.cloud
spring-cloud-zookeeper
- 2.2.1.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
..
spring-cloud-starter-zookeeper
diff --git a/spring-cloud-zookeeper-config/pom.xml b/spring-cloud-zookeeper-config/pom.xml
index 731614d8..f4c665fc 100644
--- a/spring-cloud-zookeeper-config/pom.xml
+++ b/spring-cloud-zookeeper-config/pom.xml
@@ -12,7 +12,7 @@
org.springframework.cloud
spring-cloud-zookeeper
- 2.2.1.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
..
diff --git a/spring-cloud-zookeeper-core/pom.xml b/spring-cloud-zookeeper-core/pom.xml
index 2fa02a06..bc9897f5 100644
--- a/spring-cloud-zookeeper-core/pom.xml
+++ b/spring-cloud-zookeeper-core/pom.xml
@@ -12,7 +12,7 @@
org.springframework.cloud
spring-cloud-zookeeper
- 2.2.1.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
..
@@ -41,6 +41,10 @@
spring-boot-starter-actuator
true
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
org.springframework.cloud
spring-cloud-commons
diff --git a/spring-cloud-zookeeper-dependencies/pom.xml b/spring-cloud-zookeeper-dependencies/pom.xml
index 6a913bba..cda1c7a5 100644
--- a/spring-cloud-zookeeper-dependencies/pom.xml
+++ b/spring-cloud-zookeeper-dependencies/pom.xml
@@ -5,11 +5,11 @@
spring-cloud-dependencies-parent
org.springframework.cloud
- 2.2.1.RELEASE
+ 3.0.0.BUILD-SNAPSHOT
spring-cloud-zookeeper-dependencies
- 2.2.1.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
pom
spring-cloud-zookeeper-dependencies
Spring Cloud Zookeeper Dependencies
diff --git a/spring-cloud-zookeeper-discovery/pom.xml b/spring-cloud-zookeeper-discovery/pom.xml
index ac2c167b..1910ac29 100644
--- a/spring-cloud-zookeeper-discovery/pom.xml
+++ b/spring-cloud-zookeeper-discovery/pom.xml
@@ -12,7 +12,7 @@
org.springframework.cloud
spring-cloud-zookeeper
- 2.2.1.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
..
@@ -68,41 +68,11 @@
curator-x-discovery
true
-
- org.springframework.cloud
- spring-cloud-netflix-hystrix
- true
-
-
- org.springframework.cloud
- spring-cloud-starter-netflix-archaius
- true
-
org.springframework.cloud
spring-cloud-starter-openfeign
true
-
- com.netflix.ribbon
- ribbon
- true
-
-
- com.netflix.ribbon
- ribbon-core
- true
-
-
- com.netflix.ribbon
- ribbon-loadbalancer
- true
-
-
- com.netflix.ribbon
- ribbon-httpclient
- true
-
io.github.openfeign
feign-core
@@ -138,10 +108,6 @@
spring-cloud-test-support
test
-
- commons-configuration
- commons-configuration
-
org.apache.curator
curator-test
diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ConditionalOnRibbonZookeeper.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ConditionalOnRibbonZookeeper.java
deleted file mode 100644
index a1a2cf37..00000000
--- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ConditionalOnRibbonZookeeper.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2015-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.zookeeper.discovery;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-
-/**
- * Wrapper annotation to enable Ribbon for Zookeeper.
- *
- * @author Marcin Grzejszczak
- * * @since 1.0.0
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.TYPE, ElementType.METHOD })
-@ConditionalOnProperty(value = "ribbon.zookeeper.enabled", matchIfMissing = true)
-public @interface ConditionalOnRibbonZookeeper {
-
-}
diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/RibbonZookeeperAutoConfiguration.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/RibbonZookeeperAutoConfiguration.java
deleted file mode 100644
index 0317e0e2..00000000
--- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/RibbonZookeeperAutoConfiguration.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2015-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.zookeeper.discovery;
-
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
-import org.springframework.boot.context.properties.EnableConfigurationProperties;
-import org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration;
-import org.springframework.cloud.netflix.ribbon.RibbonClients;
-import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
-import org.springframework.cloud.zookeeper.ConditionalOnZookeeperEnabled;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration
- * Auto-configuration} that sets up Ribbon for Zookeeper.
- *
- * @author Dave Syer
- * @since 1.0.0
- */
-@Configuration(proxyBeanMethods = false)
-@EnableConfigurationProperties
-@ConditionalOnZookeeperEnabled
-@ConditionalOnBean(SpringClientFactory.class)
-@ConditionalOnRibbonZookeeper
-@AutoConfigureAfter(RibbonAutoConfiguration.class)
-@RibbonClients(defaultConfiguration = ZookeeperRibbonClientConfiguration.class)
-public class RibbonZookeeperAutoConfiguration {
-
-}
diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperRibbonClientConfiguration.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperRibbonClientConfiguration.java
deleted file mode 100644
index 42ddb699..00000000
--- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperRibbonClientConfiguration.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright 2015-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.zookeeper.discovery;
-
-import javax.annotation.PostConstruct;
-
-import com.netflix.client.config.IClientConfig;
-import com.netflix.config.ConfigurationManager;
-import com.netflix.config.DynamicPropertyFactory;
-import com.netflix.config.DynamicStringProperty;
-import com.netflix.loadbalancer.ILoadBalancer;
-import com.netflix.loadbalancer.IPing;
-import com.netflix.loadbalancer.PingUrl;
-import com.netflix.loadbalancer.ServerList;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.curator.x.discovery.ServiceDiscovery;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.cloud.netflix.ribbon.ServerIntrospector;
-import org.springframework.cloud.zookeeper.discovery.dependency.ConditionalOnDependenciesNotPassed;
-import org.springframework.cloud.zookeeper.discovery.dependency.ConditionalOnDependenciesPassed;
-import org.springframework.cloud.zookeeper.discovery.dependency.DependenciesBasedLoadBalancer;
-import org.springframework.cloud.zookeeper.discovery.dependency.ZookeeperDependencies;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import static com.netflix.client.config.CommonClientConfigKey.DeploymentContextBasedVipAddresses;
-import static com.netflix.client.config.CommonClientConfigKey.EnableZoneAffinity;
-
-/**
- * Preprocessor that configures defaults for zookeeper-discovered ribbon clients. Such as:
- * @zone, NIWSServerListClassName, DeploymentContextBasedVipAddresses,
- * NFLoadBalancerRuleClassName, NIWSServerListFilterClassName and more.
- *
- * @author Spencer Gibb
- * @author Dave Syer
- * @author Marcin Grzejszczak
- * @since 1.0.0
- */
-@Configuration(proxyBeanMethods = false)
-public class ZookeeperRibbonClientConfiguration {
-
- private static final Log log = LogFactory
- .getLog(ZookeeperRibbonClientConfiguration.class);
-
- protected static final String VALUE_NOT_SET = "__not__set__";
-
- protected static final String DEFAULT_NAMESPACE = "ribbon";
-
- @Value("${ribbon.client.name}")
- private String serviceId = "client";
-
- public ZookeeperRibbonClientConfiguration() {
- }
-
- @Bean
- @ConditionalOnMissingBean
- @ConditionalOnDependenciesPassed
- public ServerList> ribbonServerListFromDependencies(IClientConfig config,
- ZookeeperDependencies zookeeperDependencies,
- ServiceDiscovery serviceDiscovery) {
- ZookeeperServerList serverList = new ZookeeperServerList(serviceDiscovery);
- serverList.initFromDependencies(config, zookeeperDependencies);
- log.debug(String.format(
- "Server list for Ribbon's dependencies based load balancing is [%s]",
- serverList));
- return serverList;
- }
-
- @Bean
- @ConditionalOnMissingBean
- @ConditionalOnDependenciesPassed
- @ConditionalOnProperty(value = "spring.cloud.zookeeper.dependency.ribbon.loadbalancer", matchIfMissing = true)
- public ILoadBalancer dependenciesBasedLoadBalancer(
- ZookeeperDependencies zookeeperDependencies, ServerList> serverList,
- IClientConfig config, IPing iPing) {
- return new DependenciesBasedLoadBalancer(zookeeperDependencies, serverList,
- config, iPing);
- }
-
- @Bean
- @ConditionalOnMissingBean
- @ConditionalOnDependenciesPassed
- public IPing healthCheckingRule(ZookeeperDependencies zookeeperDependencies) {
- return new PingUrl(false, zookeeperDependencies.getDefaultHealthEndpoint());
- }
-
- @Bean
- @ConditionalOnMissingBean
- @ConditionalOnDependenciesNotPassed
- public ServerList> ribbonServerList(IClientConfig config,
- ServiceDiscovery serviceDiscovery) {
- ZookeeperServerList serverList = new ZookeeperServerList(serviceDiscovery);
- serverList.initWithNiwsConfig(config);
- log.debug(String.format(
- "Server list for Ribbon's non-dependency based load balancing is [%s]",
- serverList));
- return serverList;
- }
-
- @Bean
- public ServerIntrospector serverIntrospector() {
- return new ZookeeperServerIntrospector();
- }
-
- @PostConstruct
- public void preprocess() {
- setProp(this.serviceId, DeploymentContextBasedVipAddresses.key(), this.serviceId);
- setProp(this.serviceId, EnableZoneAffinity.key(), "true");
- }
-
- protected void setProp(String serviceId, String suffix, String value) {
- // how to set the namespace properly?
- String key = getKey(serviceId, suffix);
- DynamicStringProperty property = getProperty(key);
- if (property.get().equals(VALUE_NOT_SET)) {
- ConfigurationManager.getConfigInstance().setProperty(key, value);
- }
- }
-
- protected DynamicStringProperty getProperty(String key) {
- return DynamicPropertyFactory.getInstance().getStringProperty(key, VALUE_NOT_SET);
- }
-
- protected String getKey(String serviceId, String suffix) {
- return serviceId + "." + DEFAULT_NAMESPACE + "." + suffix;
- }
-
-}
diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServer.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServer.java
deleted file mode 100644
index 38b52d6e..00000000
--- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServer.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2015-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.zookeeper.discovery;
-
-import com.netflix.loadbalancer.Server;
-import org.apache.curator.x.discovery.ServiceInstance;
-
-/**
- * A Zookeeper version of a {@link Server Ribbon Server}.
- *
- * @author Spencer Gibb
- * @since 1.0.0
- */
-public class ZookeeperServer extends Server {
-
- private final MetaInfo metaInfo;
-
- private ServiceInstance instance;
-
- public ZookeeperServer(final ServiceInstance instance) {
- // TODO: ssl support
- super(instance.getAddress(), instance.getPort());
- this.metaInfo = new MetaInfo() {
- @Override
- public String getAppName() {
- return instance.getName();
- }
-
- @Override
- public String getServerGroup() {
- return null;
- }
-
- @Override
- public String getServiceIdForDiscovery() {
- return null;
- }
-
- @Override
- public String getInstanceId() {
- return instance.getId();
- }
- };
- this.instance = instance;
- }
-
- @Override
- public MetaInfo getMetaInfo() {
- return this.metaInfo;
- }
-
- public ServiceInstance getInstance() {
- return this.instance;
- }
-
-}
diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServerIntrospector.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServerIntrospector.java
deleted file mode 100644
index 87369b31..00000000
--- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServerIntrospector.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2015-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.zookeeper.discovery;
-
-import java.util.Map;
-
-import com.netflix.loadbalancer.Server;
-import org.apache.curator.x.discovery.ServiceInstance;
-
-import org.springframework.cloud.netflix.ribbon.DefaultServerIntrospector;
-
-/**
- * @author Spencer Gibb
- */
-public class ZookeeperServerIntrospector extends DefaultServerIntrospector {
-
- @Override
- public boolean isSecure(Server server) {
- if (server instanceof ZookeeperServer) {
- ZookeeperServer zookeeperServer = (ZookeeperServer) server;
- Integer sslPort = zookeeperServer.getInstance().getSslPort();
- return sslPort != null && sslPort > 0;
- }
- return super.isSecure(server);
- }
-
- @Override
- public Map getMetadata(Server server) {
- if (server instanceof ZookeeperServer) {
- ZookeeperServer zookeeperServer = (ZookeeperServer) server;
- ServiceInstance instance = zookeeperServer.getInstance();
- if (instance != null && instance.getPayload() != null) {
- return instance.getPayload().getMetadata();
- }
- }
- return super.getMetadata(server);
- }
-
-}
diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServerList.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServerList.java
deleted file mode 100644
index f52d2d14..00000000
--- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/ZookeeperServerList.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2015-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.zookeeper.discovery;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import com.netflix.client.config.IClientConfig;
-import com.netflix.loadbalancer.AbstractServerList;
-import org.apache.curator.x.discovery.ServiceDiscovery;
-import org.apache.curator.x.discovery.ServiceInstance;
-
-import org.springframework.cloud.zookeeper.discovery.dependency.ZookeeperDependencies;
-import org.springframework.util.StringUtils;
-
-import static org.springframework.cloud.zookeeper.support.StatusConstants.INSTANCE_STATUS_KEY;
-import static org.springframework.cloud.zookeeper.support.StatusConstants.STATUS_UP;
-import static org.springframework.util.ReflectionUtils.rethrowRuntimeException;
-
-/**
- * Zookeeper version of {@link AbstractServerList} that returns the list of servers on
- * which instances are ran. The implementation is capable of resolving the servers from
- * {@link ZookeeperDependencies}.
- *
- * @author Spencer Gibb
- * @author Marcin Grzejszczak
- * @since 1.0.0
- */
-public class ZookeeperServerList extends AbstractServerList {
-
- private String serviceId;
-
- private final ServiceDiscovery serviceDiscovery;
-
- public ZookeeperServerList(ServiceDiscovery serviceDiscovery) {
- this.serviceDiscovery = serviceDiscovery;
- }
-
- @Override
- public void initWithNiwsConfig(IClientConfig clientConfig) {
- this.serviceId = clientConfig.getClientName();
- }
-
- public void initFromDependencies(IClientConfig clientConfig,
- ZookeeperDependencies zookeeperDependencies) {
- this.serviceId = getServiceIdFromDepsOrClientName(clientConfig,
- zookeeperDependencies);
- }
-
- private String getServiceIdFromDepsOrClientName(IClientConfig clientConfig,
- ZookeeperDependencies zookeeperDependencies) {
- String serviceIdFromDeps = zookeeperDependencies
- .getPathForAlias(clientConfig.getClientName());
- return StringUtils.hasText(serviceIdFromDeps) ? serviceIdFromDeps
- : clientConfig.getClientName();
- }
-
- @Override
- public List getInitialListOfServers() {
- return getServers();
- }
-
- @Override
- public List getUpdatedListOfServers() {
- return getServers();
- }
-
- @SuppressWarnings("unchecked")
- protected List getServers() {
- try {
- if (this.serviceDiscovery == null) {
- return Collections.EMPTY_LIST;
- }
- Collection> instances = this.serviceDiscovery
- .queryForInstances(this.serviceId);
- if (instances == null || instances.isEmpty()) {
- return Collections.EMPTY_LIST;
- }
- List servers = new ArrayList<>();
- for (ServiceInstance instance : instances) {
- String instanceStatus = null;
- if (instance.getPayload() != null
- && instance.getPayload().getMetadata() != null) {
- instanceStatus = instance.getPayload().getMetadata()
- .get(INSTANCE_STATUS_KEY);
- }
- if (!StringUtils.hasText(instanceStatus) // backwards compatibility
- || instanceStatus.equalsIgnoreCase(STATUS_UP)) {
- servers.add(new ZookeeperServer(instance));
- }
- }
- return servers;
- }
- catch (Exception e) {
- rethrowRuntimeException(e);
- }
- return Collections.EMPTY_LIST;
- }
-
-}
diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependenciesBasedLoadBalancer.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependenciesBasedLoadBalancer.java
index 80e7ca0d..ce77277f 100644
--- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependenciesBasedLoadBalancer.java
+++ b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependenciesBasedLoadBalancer.java
@@ -16,17 +16,6 @@
package org.springframework.cloud.zookeeper.discovery.dependency;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import com.netflix.client.config.IClientConfig;
-import com.netflix.loadbalancer.DynamicServerListLoadBalancer;
-import com.netflix.loadbalancer.IPing;
-import com.netflix.loadbalancer.IRule;
-import com.netflix.loadbalancer.RandomRule;
-import com.netflix.loadbalancer.RoundRobinRule;
-import com.netflix.loadbalancer.Server;
-import com.netflix.loadbalancer.ServerList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -37,85 +26,86 @@ import org.apache.commons.logging.LogFactory;
* @author Marcin Grzejszczak
* @since 1.0.0
*/
-public class DependenciesBasedLoadBalancer extends DynamicServerListLoadBalancer {
+public class DependenciesBasedLoadBalancer /*extends DynamicServerListLoadBalancer*/ {
private static final Log log = LogFactory.getLog(DependenciesBasedLoadBalancer.class);
- private final Map ruleCache = new ConcurrentHashMap<>();
+ //private final Map ruleCache = new ConcurrentHashMap<>();
private final ZookeeperDependencies zookeeperDependencies;
- public DependenciesBasedLoadBalancer(ZookeeperDependencies zookeeperDependencies,
- ServerList> serverList, IClientConfig config, IPing iPing) {
- super(config);
+ public DependenciesBasedLoadBalancer(ZookeeperDependencies zookeeperDependencies/*,
+ ServerList> serverList, IClientConfig config, IPing iPing*/) {
+ //super(config);
this.zookeeperDependencies = zookeeperDependencies;
- setServersList(serverList.getInitialListOfServers());
- setPing(iPing);
- setServerListImpl(serverList);
+ //setServersList(serverList.getInitialListOfServers());
+ //setPing(iPing);
+ //setServerListImpl(serverList);
}
- @Override
- public Server chooseServer(Object key) {
- String keyAsString;
- if ("default".equals(key)) { // this is the default hint, use name instead
- keyAsString = getName();
- }
- else {
- keyAsString = (String) key;
- }
- ZookeeperDependency dependency = this.zookeeperDependencies
- .getDependencyForAlias(keyAsString);
- log.debug(String.format("Current dependencies are [%s]",
- this.zookeeperDependencies));
- if (dependency == null) {
- log.debug(String.format(
- "No dependency found for alias [%s] - will use the default rule which is [%s]",
- keyAsString, this.rule));
- return this.rule.choose(key);
- }
- cacheEntryIfMissing(keyAsString, dependency);
- log.debug(String.format(
- "Will try to retrieve dependency for key [%s]. Current cache contents [%s]",
- keyAsString, this.ruleCache));
- updateListOfServers();
- return this.ruleCache.get(keyAsString).choose(key);
- }
-
- private void cacheEntryIfMissing(String keyAsString, ZookeeperDependency dependency) {
- if (!this.ruleCache.containsKey(keyAsString)) {
- log.debug(String.format("Cache doesn't contain entry for [%s]", keyAsString));
- this.ruleCache.put(keyAsString,
- chooseRuleForLoadBalancerType(dependency.getLoadBalancerType()));
- }
- }
-
- private IRule chooseRuleForLoadBalancerType(LoadBalancerType type) {
- switch (type) {
- case ROUND_ROBIN:
- return getRoundRobinRule();
- case RANDOM:
- return getRandomRule();
- case STICKY:
- return getStickyRule();
- default:
- throw new IllegalArgumentException("Unknown load balancer type " + type);
- }
- }
-
- private RoundRobinRule getRoundRobinRule() {
- return new RoundRobinRule(this);
- }
-
- private IRule getRandomRule() {
- RandomRule randomRule = new RandomRule();
- randomRule.setLoadBalancer(this);
- return randomRule;
- }
-
- private IRule getStickyRule() {
- StickyRule stickyRule = new StickyRule(getRoundRobinRule());
- stickyRule.setLoadBalancer(this);
- return stickyRule;
- }
+ // FIXME: 3.0.0
+ //@Override
+ //public Server chooseServer(Object key) {
+ // String keyAsString;
+ // if ("default".equals(key)) { // this is the default hint, use name instead
+ // keyAsString = getName();
+ // }
+ // else {
+ // keyAsString = (String) key;
+ // }
+ // ZookeeperDependency dependency = this.zookeeperDependencies
+ // .getDependencyForAlias(keyAsString);
+ // log.debug(String.format("Current dependencies are [%s]",
+ // this.zookeeperDependencies));
+ // if (dependency == null) {
+ // log.debug(String.format(
+ // "No dependency found for alias [%s] - will use the default rule which is [%s]",
+ // keyAsString, this.rule));
+ // return this.rule.choose(key);
+ // }
+ // cacheEntryIfMissing(keyAsString, dependency);
+ // log.debug(String.format(
+ // "Will try to retrieve dependency for key [%s]. Current cache contents [%s]",
+ // keyAsString, this.ruleCache));
+ // updateListOfServers();
+ // return this.ruleCache.get(keyAsString).choose(key);
+ //}
+ //
+ //private void cacheEntryIfMissing(String keyAsString, ZookeeperDependency dependency) {
+ // if (!this.ruleCache.containsKey(keyAsString)) {
+ // log.debug(String.format("Cache doesn't contain entry for [%s]", keyAsString));
+ // this.ruleCache.put(keyAsString,
+ // chooseRuleForLoadBalancerType(dependency.getLoadBalancerType()));
+ // }
+ //}
+ //
+ //private IRule chooseRuleForLoadBalancerType(LoadBalancerType type) {
+ // switch (type) {
+ // case ROUND_ROBIN:
+ // return getRoundRobinRule();
+ // case RANDOM:
+ // return getRandomRule();
+ // case STICKY:
+ // return getStickyRule();
+ // default:
+ // throw new IllegalArgumentException("Unknown load balancer type " + type);
+ // }
+ //}
+ //
+ //private RoundRobinRule getRoundRobinRule() {
+ // return new RoundRobinRule(this);
+ //}
+ //
+ //private IRule getRandomRule() {
+ // RandomRule randomRule = new RandomRule();
+ // randomRule.setLoadBalancer(this);
+ // return randomRule;
+ //}
+ //
+ //private IRule getStickyRule() {
+ // StickyRule stickyRule = new StickyRule(getRoundRobinRule());
+ // stickyRule.setLoadBalancer(this);
+ // return stickyRule;
+ //}
}
diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependencyFeignClientAutoConfiguration.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependencyFeignClientAutoConfiguration.java
index eee181a1..22a4e51d 100644
--- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependencyFeignClientAutoConfiguration.java
+++ b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependencyFeignClientAutoConfiguration.java
@@ -16,30 +16,12 @@
package org.springframework.cloud.zookeeper.discovery.dependency;
-import java.io.IOException;
-import java.net.URI;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
import feign.Client;
-import feign.Request;
-import feign.Response;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration;
-import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
-import org.springframework.cloud.openfeign.ribbon.CachingSpringLoadBalancerFactory;
-import org.springframework.cloud.openfeign.ribbon.FeignRibbonClientAutoConfiguration;
-import org.springframework.cloud.openfeign.ribbon.LoadBalancerFeignClient;
import org.springframework.cloud.zookeeper.ConditionalOnZookeeperEnabled;
-import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
/**
* Configuration for ensuring that headers are set for a given dependency when Feign is
@@ -52,61 +34,62 @@ import org.springframework.context.annotation.Primary;
@ConditionalOnDependenciesPassed
@ConditionalOnZookeeperEnabled
@ConditionalOnProperty(value = "spring.cloud.zookeeper.dependency.headers.enabled", matchIfMissing = true)
-@ConditionalOnClass({ Client.class, LoadBalancerFeignClient.class })
-@AutoConfigureAfter({ RibbonAutoConfiguration.class,
- FeignRibbonClientAutoConfiguration.class })
+@ConditionalOnClass({ Client.class/*, LoadBalancerFeignClient.class*/ })
+/*@AutoConfigureAfter({ RibbonAutoConfiguration.class,
+ FeignRibbonClientAutoConfiguration.class })*/
public class DependencyFeignClientAutoConfiguration {
- @Autowired(required = false)
- private LoadBalancerFeignClient ribbonClient;
-
- @Autowired
- private ZookeeperDependencies zookeeperDependencies;
-
- @Autowired
- private CachingSpringLoadBalancerFactory loadBalancerFactory;
-
- @Autowired
- private SpringClientFactory springClientFactory;
-
- @Bean
- @Primary
- Client dependencyBasedFeignClient() {
- return new LoadBalancerFeignClient(new Client.Default(null, null),
- this.loadBalancerFactory, this.springClientFactory) {
-
- @Override
- public Response execute(Request request, Request.Options options)
- throws IOException {
- URI asUri = URI.create(request.url());
- String clientName = asUri.getHost();
- ZookeeperDependency dependencyForAlias = DependencyFeignClientAutoConfiguration.this.zookeeperDependencies
- .getDependencyForAlias(clientName);
- Map> headers = getUpdatedHeadersIfPossible(
- request, dependencyForAlias);
- if (DependencyFeignClientAutoConfiguration.this.ribbonClient != null) {
- return DependencyFeignClientAutoConfiguration.this.ribbonClient
- .execute(request(request, headers), options);
- }
- return super.execute(request(request, headers), options);
- }
-
- private Request request(Request request,
- Map> headers) {
- return Request.create(request.method(), request.url(), headers,
- request.body(), request.charset());
- }
-
- private Map> getUpdatedHeadersIfPossible(
- Request request, ZookeeperDependency dependencyForAlias) {
- if (dependencyForAlias != null) {
- return Collections.unmodifiableMap(new HashMap<>(
- dependencyForAlias.getUpdatedHeaders(request.headers())));
- }
- return request.headers();
- }
-
- };
- }
+ // FIXME: 3.0.0
+ //@Autowired(required = false)
+ //private LoadBalancerFeignClient ribbonClient;
+ //
+ //@Autowired
+ //private ZookeeperDependencies zookeeperDependencies;
+ //
+ //@Autowired
+ //private CachingSpringLoadBalancerFactory loadBalancerFactory;
+ //
+ //@Autowired
+ //private SpringClientFactory springClientFactory;
+ //
+ //@Bean
+ //@Primary
+ //Client dependencyBasedFeignClient() {
+ // return new LoadBalancerFeignClient(new Client.Default(null, null),
+ // this.loadBalancerFactory, this.springClientFactory) {
+ //
+ // @Override
+ // public Response execute(Request request, Request.Options options)
+ // throws IOException {
+ // URI asUri = URI.create(request.url());
+ // String clientName = asUri.getHost();
+ // ZookeeperDependency dependencyForAlias = DependencyFeignClientAutoConfiguration.this.zookeeperDependencies
+ // .getDependencyForAlias(clientName);
+ // Map> headers = getUpdatedHeadersIfPossible(
+ // request, dependencyForAlias);
+ // if (DependencyFeignClientAutoConfiguration.this.ribbonClient != null) {
+ // return DependencyFeignClientAutoConfiguration.this.ribbonClient
+ // .execute(request(request, headers), options);
+ // }
+ // return super.execute(request(request, headers), options);
+ // }
+ //
+ // private Request request(Request request,
+ // Map> headers) {
+ // return Request.create(request.method(), request.url(), headers,
+ // request.body(), request.charset());
+ // }
+ //
+ // private Map> getUpdatedHeadersIfPossible(
+ // Request request, ZookeeperDependency dependencyForAlias) {
+ // if (dependencyForAlias != null) {
+ // return Collections.unmodifiableMap(new HashMap<>(
+ // dependencyForAlias.getUpdatedHeaders(request.headers())));
+ // }
+ // return request.headers();
+ // }
+ //
+ // };
+ //}
}
diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependencyRestTemplateAutoConfiguration.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependencyRestTemplateAutoConfiguration.java
index 47ce7853..bac58dec 100644
--- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependencyRestTemplateAutoConfiguration.java
+++ b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependencyRestTemplateAutoConfiguration.java
@@ -26,11 +26,9 @@ import java.util.Map;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.zookeeper.ConditionalOnZookeeperEnabled;
-import org.springframework.cloud.zookeeper.discovery.ConditionalOnRibbonZookeeper;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest;
@@ -47,10 +45,8 @@ import org.springframework.web.client.RestTemplate;
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnZookeeperEnabled
-@ConditionalOnRibbonZookeeper
@ConditionalOnDependenciesPassed
@ConditionalOnProperty(value = "spring.cloud.zookeeper.dependency.resttemplate.enabled", matchIfMissing = true)
-@AutoConfigureAfter(DependencyRibbonAutoConfiguration.class)
public class DependencyRestTemplateAutoConfiguration {
@Autowired
diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependencyRibbonAutoConfiguration.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependencyRibbonAutoConfiguration.java
deleted file mode 100644
index f659fcca..00000000
--- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/DependencyRibbonAutoConfiguration.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2015-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.zookeeper.discovery.dependency;
-
-import com.netflix.loadbalancer.ILoadBalancer;
-import com.netflix.loadbalancer.Server;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.autoconfigure.AutoConfigureBefore;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
-import org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration;
-import org.springframework.cloud.netflix.ribbon.RibbonLoadBalancerClient;
-import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
-import org.springframework.cloud.zookeeper.ConditionalOnZookeeperEnabled;
-import org.springframework.cloud.zookeeper.discovery.ConditionalOnRibbonZookeeper;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- *
- * Provides LoadBalancerClient that at runtime can pick proper load balancing strategy
- * basing on the Zookeeper dependencies from properties.
- *
- * @author Marcin Grzejszczak
- * @since 1.0.0
- */
-@Configuration(proxyBeanMethods = false)
-@ConditionalOnZookeeperEnabled
-@ConditionalOnRibbonZookeeper
-@ConditionalOnDependenciesPassed
-@AutoConfigureBefore(RibbonAutoConfiguration.class)
-public class DependencyRibbonAutoConfiguration {
-
- private static final Log log = LogFactory
- .getLog(DependencyRibbonAutoConfiguration.class);
-
- @Autowired
- ApplicationContext applicationContext;
-
- @Bean
- @ConditionalOnMissingBean
- @ConditionalOnProperty(value = "spring.cloud.zookeeper.dependency.ribbon.enabled", matchIfMissing = true)
- public LoadBalancerClient loadBalancerClient(
- SpringClientFactory springClientFactory) {
- return new RibbonLoadBalancerClient(springClientFactory) {
- @Override
- protected Server getServer(String serviceId) {
- ILoadBalancer loadBalancer = this.getLoadBalancer(serviceId);
- return loadBalancer == null ? null
- : chooseServerByServiceIdOrDefault(loadBalancer, serviceId);
- }
-
- private Server chooseServerByServiceIdOrDefault(ILoadBalancer loadBalancer,
- String serviceId) {
- log.debug(String.format(
- "Dependencies are set - will try to load balance via provided load balancer [%s] for key [%s]",
- loadBalancer, serviceId));
- Server server = loadBalancer.chooseServer(serviceId);
- log.debug(
- String.format("Retrieved server [%s] via load balancer", server));
- return server != null ? server : loadBalancer.chooseServer("default");
- }
- };
- }
-
-}
diff --git a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/StickyRule.java b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/StickyRule.java
index 6d2f6cae..299dec19 100644
--- a/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/StickyRule.java
+++ b/spring-cloud-zookeeper-discovery/src/main/java/org/springframework/cloud/zookeeper/discovery/dependency/StickyRule.java
@@ -16,14 +16,8 @@
package org.springframework.cloud.zookeeper.discovery.dependency;
-import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import com.netflix.client.config.IClientConfig;
-import com.netflix.loadbalancer.AbstractLoadBalancerRule;
-import com.netflix.loadbalancer.IRule;
-import com.netflix.loadbalancer.Server;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -35,42 +29,43 @@ import org.apache.commons.logging.LogFactory;
* @author Marcin Grzejszczak
* @since 1.0.0
*/
-public class StickyRule extends AbstractLoadBalancerRule {
+public class StickyRule /*extends AbstractLoadBalancerRule*/ {
private static final Log log = LogFactory.getLog(StickyRule.class);
- private final IRule masterStrategy;
+ //private final IRule masterStrategy;
- private final AtomicReference ourInstance = new AtomicReference<>(null);
+ //private final AtomicReference ourInstance = new AtomicReference<>(null);
private final AtomicInteger instanceNumber = new AtomicInteger(-1);
- public StickyRule(IRule masterStrategy) {
- this.masterStrategy = masterStrategy;
- }
-
- @Override
- public void initWithNiwsConfig(IClientConfig iClientConfig) {
-
- }
-
- @Override
- public Server choose(Object key) {
- final List instances = getLoadBalancer().getServerList(true);
- log.debug(String.format("Instances taken from load balancer [%s]", instances));
- Server localOurInstance = this.ourInstance.get();
- log.debug(String.format("Current saved instance [%s]", localOurInstance));
- if (!instances.contains(localOurInstance)) {
- this.ourInstance.compareAndSet(localOurInstance, null);
- }
- if (this.ourInstance.get() == null) {
- Server instance = this.masterStrategy.choose(key);
- if (this.ourInstance.compareAndSet(null, instance)) {
- this.instanceNumber.incrementAndGet();
- }
- }
- return this.ourInstance.get();
- }
+ // FIXME: 3.0.0
+ //public StickyRule(IRule masterStrategy) {
+ // this.masterStrategy = masterStrategy;
+ //}
+ //
+ //@Override
+ //public void initWithNiwsConfig(IClientConfig iClientConfig) {
+ //
+ //}
+ //
+ //@Override
+ //public Server choose(Object key) {
+ // final List instances = getLoadBalancer().getServerList(true);
+ // log.debug(String.format("Instances taken from load balancer [%s]", instances));
+ // Server localOurInstance = this.ourInstance.get();
+ // log.debug(String.format("Current saved instance [%s]", localOurInstance));
+ // if (!instances.contains(localOurInstance)) {
+ // this.ourInstance.compareAndSet(localOurInstance, null);
+ // }
+ // if (this.ourInstance.get() == null) {
+ // Server instance = this.masterStrategy.choose(key);
+ // if (this.ourInstance.compareAndSet(null, instance)) {
+ // this.instanceNumber.incrementAndGet();
+ // }
+ // }
+ // return this.ourInstance.get();
+ //}
/**
* Each time a new instance is picked, an internal counter is incremented. This way
diff --git a/spring-cloud-zookeeper-discovery/src/main/resources/META-INF/spring.factories b/spring-cloud-zookeeper-discovery/src/main/resources/META-INF/spring.factories
index bf5b9e66..ad691903 100644
--- a/spring-cloud-zookeeper-discovery/src/main/resources/META-INF/spring.factories
+++ b/spring-cloud-zookeeper-discovery/src/main/resources/META-INF/spring.factories
@@ -1,9 +1,7 @@
# Auto Configuration
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-org.springframework.cloud.zookeeper.discovery.RibbonZookeeperAutoConfiguration,\
org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryAutoConfiguration,\
org.springframework.cloud.zookeeper.discovery.dependency.DependencyFeignClientAutoConfiguration,\
-org.springframework.cloud.zookeeper.discovery.dependency.DependencyRibbonAutoConfiguration,\
org.springframework.cloud.zookeeper.discovery.dependency.DependencyRestTemplateAutoConfiguration,\
org.springframework.cloud.zookeeper.discovery.dependency.ZookeeperDependenciesAutoConfiguration,\
org.springframework.cloud.zookeeper.discovery.watcher.DependencyWatcherAutoConfiguration,\
diff --git a/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/ZookeeperServerListTests.java b/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/ZookeeperServerListTests.java
deleted file mode 100644
index 5bbf98ba..00000000
--- a/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/ZookeeperServerListTests.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2015-2019 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.springframework.cloud.zookeeper;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.curator.x.discovery.ServiceDiscovery;
-import org.apache.curator.x.discovery.ServiceInstance;
-import org.assertj.core.data.MapEntry;
-import org.junit.Test;
-
-import org.springframework.cloud.zookeeper.discovery.ZookeeperInstance;
-import org.springframework.cloud.zookeeper.discovery.ZookeeperServer;
-import org.springframework.cloud.zookeeper.discovery.ZookeeperServerList;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.nullable;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.springframework.cloud.zookeeper.support.StatusConstants.INSTANCE_STATUS_KEY;
-import static org.springframework.cloud.zookeeper.support.StatusConstants.STATUS_OUT_OF_SERVICE;
-import static org.springframework.cloud.zookeeper.support.StatusConstants.STATUS_UP;
-
-/**
- * @author Spencer Gibb
- */
-public class ZookeeperServerListTests {
-
- @Test
- public void testNullServiceDiscoveryReturnsEmptyList() {
- ZookeeperServerList serverList = new ZookeeperServerList(null);
- List servers = serverList.getInitialListOfServers();
- assertThat(servers).isEmpty();
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void testEmptyInstancesReturnsEmptyList() throws Exception {
- ServiceDiscovery serviceDiscovery = mock(
- ServiceDiscovery.class);
- when(serviceDiscovery.queryForInstances(anyString())).thenReturn(null);
-
- ZookeeperServerList serverList = new ZookeeperServerList(serviceDiscovery);
- List servers = serverList.getInitialListOfServers();
- assertThat(servers).isEmpty();
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void testGetServers() throws Exception {
- ArrayList> instances = new ArrayList<>();
- instances.add(serviceInstance(1, null));
-
- ServiceDiscovery serviceDiscovery = mock(
- ServiceDiscovery.class);
- when(serviceDiscovery.queryForInstances(nullable(String.class)))
- .thenReturn(instances);
-
- ZookeeperServerList serverList = new ZookeeperServerList(serviceDiscovery);
- List servers = serverList.getInitialListOfServers();
- assertThat(servers).hasSize(1);
- }
-
- private ServiceInstance serviceInstance(int instanceNum,
- String instanceStatus) {
- String id = "instance" + instanceNum + "id";
- String name = "instance" + instanceNum + "name";
-
- ZookeeperInstance payload = null;
-
- if (instanceStatus != null) {
- payload = new ZookeeperInstance(id, name,
- Collections.singletonMap(INSTANCE_STATUS_KEY, instanceStatus));
- }
- String address = "instance" + instanceNum + "addr";
- int port = 8080 + instanceNum;
- return new ServiceInstance<>(name, id, address, port, null, payload, 0, null,
- null);
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void testGetServersWithInstanceStatus() throws Exception {
- ArrayList> instances = new ArrayList<>();
- instances.add(serviceInstance(1, STATUS_UP));
- instances.add(serviceInstance(2, STATUS_OUT_OF_SERVICE));
-
- ServiceDiscovery serviceDiscovery = mock(
- ServiceDiscovery.class);
- when(serviceDiscovery.queryForInstances(nullable(String.class)))
- .thenReturn(instances);
-
- ZookeeperServerList serverList = new ZookeeperServerList(serviceDiscovery);
- List servers = serverList.getInitialListOfServers();
- assertThat(servers).hasSize(1);
-
- assertThat(servers.get(0).getInstance().getPayload().getMetadata())
- .contains(MapEntry.entry(INSTANCE_STATUS_KEY, STATUS_UP));
- }
-
-}
diff --git a/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoverySecurePortTests.java b/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoverySecurePortTests.java
index 217a4d26..0563e900 100644
--- a/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoverySecurePortTests.java
+++ b/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/ZookeeperDiscoverySecurePortTests.java
@@ -25,8 +25,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
-import org.springframework.cloud.netflix.ribbon.ServerIntrospector;
-import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
import org.springframework.cloud.zookeeper.discovery.test.CommonTestConfig;
import org.springframework.cloud.zookeeper.serviceregistry.ZookeeperRegistration;
import org.springframework.context.annotation.Configuration;
@@ -57,23 +55,9 @@ public class ZookeeperDiscoverySecurePortTests {
@Autowired
private ZookeeperRegistration zookeeperRegistration;
- @Autowired
- private SpringClientFactory clientFactory;
-
@Value("${spring.application.name}")
private String springAppName;
- @Test
- public void zookeeperServerIntrospectorWorks() {
- ServerIntrospector serverIntrospector = this.clientFactory
- .getInstance(springAppName, ServerIntrospector.class);
- then(serverIntrospector).isInstanceOf(ZookeeperServerIntrospector.class);
-
- ZookeeperServer zookeeperServer = new ZookeeperServer(
- this.zookeeperRegistration.getServiceInstance());
- then(serverIntrospector.isSecure(zookeeperServer)).isTrue();
- }
-
@Test
public void isSecureIsTrue() {
ServiceInstance instance = this.loadBalancerClient.choose(this.springAppName);
diff --git a/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/dependency/StickyRuleTests.java b/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/dependency/StickyRuleTests.java
index ed624e7d..c510db69 100644
--- a/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/dependency/StickyRuleTests.java
+++ b/spring-cloud-zookeeper-discovery/src/test/java/org/springframework/cloud/zookeeper/discovery/dependency/StickyRuleTests.java
@@ -21,8 +21,6 @@ import java.util.List;
import java.util.concurrent.Callable;
import com.jayway.awaitility.Awaitility;
-import com.netflix.loadbalancer.IPing;
-import com.netflix.loadbalancer.NoOpPing;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.test.TestingServer;
import org.junit.Test;
@@ -130,11 +128,6 @@ public class StickyRuleTests {
curatorFramework);
}
- @Bean
- IPing noOpPing() {
- return new NoOpPing();
- }
-
}
}
diff --git a/spring-cloud-zookeeper-sample/pom.xml b/spring-cloud-zookeeper-sample/pom.xml
index 2cf65330..783e3546 100644
--- a/spring-cloud-zookeeper-sample/pom.xml
+++ b/spring-cloud-zookeeper-sample/pom.xml
@@ -11,7 +11,7 @@
org.springframework.cloud
spring-cloud-zookeeper
- 2.2.1.BUILD-SNAPSHOT
+ 3.0.0.BUILD-SNAPSHOT
..
diff --git a/spring-cloud-zookeeper-sample/src/test/java/org/springframework/cloud/zookeeper/sample/ZookeeperDisabledTests.java b/spring-cloud-zookeeper-sample/src/test/java/org/springframework/cloud/zookeeper/sample/ZookeeperDisabledTests.java
index c21a50ae..3fab5ab3 100644
--- a/spring-cloud-zookeeper-sample/src/test/java/org/springframework/cloud/zookeeper/sample/ZookeeperDisabledTests.java
+++ b/spring-cloud-zookeeper-sample/src/test/java/org/springframework/cloud/zookeeper/sample/ZookeeperDisabledTests.java
@@ -23,11 +23,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.zookeeper.ZookeeperAutoConfiguration;
import org.springframework.cloud.zookeeper.config.ZookeeperConfigAutoConfiguration;
-import org.springframework.cloud.zookeeper.discovery.RibbonZookeeperAutoConfiguration;
import org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryAutoConfiguration;
import org.springframework.cloud.zookeeper.discovery.dependency.DependencyFeignClientAutoConfiguration;
import org.springframework.cloud.zookeeper.discovery.dependency.DependencyRestTemplateAutoConfiguration;
-import org.springframework.cloud.zookeeper.discovery.dependency.DependencyRibbonAutoConfiguration;
import org.springframework.cloud.zookeeper.discovery.dependency.ZookeeperDependenciesAutoConfiguration;
import org.springframework.cloud.zookeeper.discovery.watcher.DependencyWatcherAutoConfiguration;
import org.springframework.cloud.zookeeper.serviceregistry.ZookeeperAutoServiceRegistrationAutoConfiguration;
@@ -49,18 +47,12 @@ public class ZookeeperDisabledTests {
@Autowired(required = false)
private ZookeeperConfigAutoConfiguration zookeeperConfigAutoConfiguration;
- @Autowired(required = false)
- private RibbonZookeeperAutoConfiguration ribbonZookeeperAutoConfiguration;
-
@Autowired(required = false)
private ZookeeperDiscoveryAutoConfiguration zookeeperDiscoveryAutoConfiguration;
@Autowired(required = false)
private DependencyFeignClientAutoConfiguration dependencyFeignClientAutoConfiguration;
- @Autowired(required = false)
- private DependencyRibbonAutoConfiguration dependencyRibbonAutoConfiguration;
-
@Autowired(required = false)
private DependencyRestTemplateAutoConfiguration dependencyRestTemplateAutoConfiguration;
@@ -85,14 +77,10 @@ public class ZookeeperDisabledTests {
.as("ZookeeperAutoConfiguration was not disabled").isNull();
assertThat(this.zookeeperConfigAutoConfiguration)
.as("ZookeeperConfigAutoConfiguration was not disabled").isNull();
- assertThat(this.ribbonZookeeperAutoConfiguration)
- .as("RibbonZookeeperAutoConfiguration was not disabled").isNull();
assertThat(this.zookeeperDiscoveryAutoConfiguration)
.as("ZookeeperDiscoveryAutoConfiguration was not disabled").isNull();
assertThat(this.dependencyFeignClientAutoConfiguration)
.as("DependencyFeignClientAutoConfiguration was not disabled").isNull();
- assertThat(this.dependencyRibbonAutoConfiguration)
- .as("DependencyRibbonAutoConfiguration was not disabled").isNull();
assertThat(this.dependencyRestTemplateAutoConfiguration)
.as("DependencyRestTemplateAutoConfiguration was not disabled").isNull();
assertThat(this.zookeeperDependenciesAutoConfiguration)