Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1148] changed instanceIsolation filter oder before zoneAware filter #1149

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.Request;
import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier;
import org.springframework.core.Ordered;
import org.springframework.core.env.Environment;

import com.google.common.eventbus.Subscribe;
import com.huaweicloud.common.disovery.InstanceIDAdapter;
Expand All @@ -37,7 +37,11 @@ public class InstanceIsolationServiceInstanceFilter implements ServiceInstanceFi

private final Map<String, Long> isolatedInstances = new ConcurrentHashMap<>();

public InstanceIsolationServiceInstanceFilter() {
private final int instanceIsolationFilterOrder;

public InstanceIsolationServiceInstanceFilter(Environment environment) {
instanceIsolationFilterOrder = environment
.getProperty("spring.cloud.servicecomb.instance.isolation.filter.order", Integer.class, -3);
EventManager.register(this);
}

Expand Down Expand Up @@ -88,6 +92,6 @@ public List<ServiceInstance> filter(ServiceInstanceListSupplier supplier, List<S

@Override
public int getOrder() {
return Ordered.LOWEST_PRECEDENCE;
return instanceIsolationFilterOrder;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

@Configuration
@ConditionalOnProperty(value = "spring.cloud.servicecomb.loadbalancer.enabled",
Expand All @@ -49,7 +50,7 @@ public LoadBalancerRequestFactory loadBalancerRequestFactory(LoadBalancerClient
}

@Bean
public InstanceIsolationServiceInstanceFilter instanceIsolationServiceInstanceFilter() {
return new InstanceIsolationServiceInstanceFilter();
public InstanceIsolationServiceInstanceFilter instanceIsolationServiceInstanceFilter(Environment environment) {
return new InstanceIsolationServiceInstanceFilter(environment);
}
}
Loading