Search in sources :

Example 1 with BlacklistServiceFilter

use of org.apache.camel.impl.cloud.BlacklistServiceFilter in project camel by apache.

the class CamelCloudServiceFilterAutoConfiguration method serviceFilter.

@Lazy
@Bean(name = "service-filter")
public CamelCloudServiceFilter serviceFilter(CamelCloudConfigurationProperties properties) {
    BlacklistServiceFilter blacklist = new BlacklistServiceFilter();
    Map<String, List<String>> services = properties.getServiceFilter().getBlacklist();
    for (Map.Entry<String, List<String>> entry : services.entrySet()) {
        for (String part : entry.getValue()) {
            String host = StringHelper.before(part, ":");
            String port = StringHelper.after(part, ":");
            if (ObjectHelper.isNotEmpty(host) && ObjectHelper.isNotEmpty(port)) {
                blacklist.addServer(entry.getKey(), host, Integer.parseInt(port));
            }
        }
    }
    return new CamelCloudServiceFilter(Arrays.asList(new HealthyServiceFilter(), blacklist));
}
Also used : HealthyServiceFilter(org.apache.camel.impl.cloud.HealthyServiceFilter) List(java.util.List) BlacklistServiceFilter(org.apache.camel.impl.cloud.BlacklistServiceFilter) Map(java.util.Map) Lazy(org.springframework.context.annotation.Lazy) Bean(org.springframework.context.annotation.Bean)

Aggregations

List (java.util.List)1 Map (java.util.Map)1 BlacklistServiceFilter (org.apache.camel.impl.cloud.BlacklistServiceFilter)1 HealthyServiceFilter (org.apache.camel.impl.cloud.HealthyServiceFilter)1 Bean (org.springframework.context.annotation.Bean)1 Lazy (org.springframework.context.annotation.Lazy)1