http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/cloud/ServiceCallConstants.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/cloud/ServiceCallConstants.java b/camel-core/src/main/java/org/apache/camel/impl/cloud/ServiceCallConstants.java new file mode 100644 index 0000000..6c09340 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/impl/cloud/ServiceCallConstants.java @@ -0,0 +1,29 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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.apache.camel.impl.cloud; + + +public interface ServiceCallConstants { + String SERVICE_CALL_SCHEME = "CamelServiceCallScheme"; + String SERVICE_CALL_URI = "CamelServiceCallUri"; + String SERVICE_CALL_CONTEXT_PATH = "CamelServiceCallContextPath"; + String SERVICE_NAME = "CamelServiceCallServiceName"; + String SERVICE_META = "CamelServiceCallServiceMeta"; + String SERVICE_HOST = "CamelServiceCallServiceHost"; + String SERVICE_PORT = "CamelServiceCallServicePort"; +}
http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/cloud/StaticServiceDiscovery.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/cloud/StaticServiceDiscovery.java b/camel-core/src/main/java/org/apache/camel/impl/cloud/StaticServiceDiscovery.java new file mode 100644 index 0000000..83fccc5 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/impl/cloud/StaticServiceDiscovery.java @@ -0,0 +1,132 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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.apache.camel.impl.cloud; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import org.apache.camel.cloud.ServiceDefinition; +import org.apache.camel.util.StringHelper; + +/** + * A static list of known servers Camel Service Call EIP. + */ +public class StaticServiceDiscovery extends DefaultServiceDiscovery { + + private final List<ServiceDefinition> servers; + + public StaticServiceDiscovery() { + this.servers = new ArrayList<>(); + } + + public StaticServiceDiscovery(List<ServiceDefinition> servers) { + this.servers = new ArrayList<>(servers); + } + + /** + * Set the servers. + * + * @param servers server in the format: [service@]host:port. + */ + public void setServers(List<String> servers) { + this.servers.clear(); + servers.forEach(this::addServer); + } + + /** + * Set the servers. + * + * @param servers servers separated by comma in the format: [service@]host:port,[service@]host2:port,[service@]host3:port and so on. + */ + public void setServers(String servers) { + this.servers.clear(); + addServer(servers); + } + + /** + * Add a server to the known list of servers. + */ + public void addServer(ServiceDefinition server) { + servers.add(server); + } + + /** + * Add a server to the known list of servers. + * @param serverString servers separated by comma in the format: [service@]host:port,[service@]host2:port,[service@]host3:port and so on. + */ + public void addServer(String serverString) { + String[] parts = serverString.split(","); + for (String part : parts) { + String service = StringHelper.before(part, "@"); + if (service != null) { + part = StringHelper.after(service, "@"); + } + String host = StringHelper.before(part, ":"); + String port = StringHelper.after(part, ":"); + + addServer(service, host, Integer.valueOf(port)); + } + } + + /** + * Add a server to the known list of servers. + */ + public void addServer(String host, int port) { + addServer(null, host, port, null); + } + + /** + * Add a server to the known list of servers. + */ + public void addServer(String name, String host, int port) { + addServer(name, host, port, null); + } + + /** + * Add a server to the known list of servers. + */ + public void addServer(String name, String host, int port, Map<String, String> meta) { + servers.add(new DefaultServiceDefinition(name, host, port, meta)); + } + + /** + * Remove an existing server from the list of known servers. + */ + public void removeServer(String host, int port) { + servers.removeIf( + s -> Objects.equals(host, s.getHost()) && port == s.getPort() + ); + } + + /** + * Remove an existing server from the list of known servers. + */ + public void removeServer(String name, String host, int port) { + servers.removeIf( + s -> Objects.equals(name, s.getName()) && Objects.equals(host, s.getHost()) && port == s.getPort() + ); + } + + @Override + public List<ServiceDefinition> getUpdatedListOfServices(String name) { + return Collections.unmodifiableList(servers); + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/cloud/StaticServiceDiscoveryFactory.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/cloud/StaticServiceDiscoveryFactory.java b/camel-core/src/main/java/org/apache/camel/impl/cloud/StaticServiceDiscoveryFactory.java new file mode 100644 index 0000000..eb4d983 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/impl/cloud/StaticServiceDiscoveryFactory.java @@ -0,0 +1,57 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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.apache.camel.impl.cloud; + +import java.util.List; + +import org.apache.camel.CamelContext; +import org.apache.camel.cloud.ServiceDiscovery; +import org.apache.camel.cloud.ServiceDiscoveryFactory; + +public class StaticServiceDiscoveryFactory implements ServiceDiscoveryFactory { + + private List<String> servers; + + public StaticServiceDiscoveryFactory() { + } + + // ************************************************************************* + // Properties + // ************************************************************************* + + public List<String> getServers() { + return servers; + } + + public void setServers(List<String> servers) { + this.servers = servers; + } + + // ************************************************************************* + // Factory + // ************************************************************************* + + @Override + public ServiceDiscovery newInstance(CamelContext camelContext) throws Exception { + StaticServiceDiscovery serviceDiscovery = new StaticServiceDiscovery(); + if (servers != null) { + serviceDiscovery.setServers(servers); + } + + return serviceDiscovery; + } +} http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/remote/AbstractServiceCallProcessorFactory.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/remote/AbstractServiceCallProcessorFactory.java b/camel-core/src/main/java/org/apache/camel/impl/remote/AbstractServiceCallProcessorFactory.java deleted file mode 100644 index 7f0a0af..0000000 --- a/camel-core/src/main/java/org/apache/camel/impl/remote/AbstractServiceCallProcessorFactory.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 - * - * http://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.apache.camel.impl.remote; - -import org.apache.camel.Processor; -import org.apache.camel.model.ProcessorDefinition; -import org.apache.camel.model.remote.ServiceCallDefinition; -import org.apache.camel.model.remote.ServiceCallProcessorFactory; -import org.apache.camel.spi.RouteContext; - -public abstract class AbstractServiceCallProcessorFactory implements ServiceCallProcessorFactory { - @Override - public Processor createChildProcessor(RouteContext routeContext, ProcessorDefinition<?> definition, boolean mandatory) throws Exception { - // not in use - return null; - } - - @Override - public Processor createProcessor(RouteContext routeContext, ProcessorDefinition<?> definition) throws Exception { - return definition instanceof ServiceCallDefinition - ? createProcessor(routeContext, (ServiceCallDefinition) definition) - : null; - } - - protected abstract Processor createProcessor(RouteContext routeContext, ServiceCallDefinition definition) throws Exception; - -} http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/remote/CachingServiceCallServiceListStrategy.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/remote/CachingServiceCallServiceListStrategy.java b/camel-core/src/main/java/org/apache/camel/impl/remote/CachingServiceCallServiceListStrategy.java deleted file mode 100644 index 1ad9b74..0000000 --- a/camel-core/src/main/java/org/apache/camel/impl/remote/CachingServiceCallServiceListStrategy.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 - * - * http://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.apache.camel.impl.remote; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import org.apache.camel.spi.ServiceCallServer; -import org.apache.camel.spi.ServiceCallServerListStrategy; -import org.apache.camel.util.ObjectHelper; - -public class CachingServiceCallServiceListStrategy<T extends ServiceCallServer> implements ServiceCallServerListStrategy<T> { - private final ServiceCallServerListStrategy<T> delegate; - private List<T> servers; - private long lastUpdate; - private long timeout; - - public CachingServiceCallServiceListStrategy(ServiceCallServerListStrategy<T> delegate) { - this.delegate = ObjectHelper.notNull(delegate, "delegate"); - this.lastUpdate = 0; - this.servers = Collections.emptyList(); - this.timeout = 60 * 1000; // 1 min; - } - - public void setTimeout(long timeout) { - this.timeout = timeout; - } - - public void setTimeout(long timeout, TimeUnit unit) { - this.timeout = unit.toMillis(timeout); - } - - public long getTimeout() { - return timeout; - } - - public CachingServiceCallServiceListStrategy<T> timeout(long timeout) { - setTimeout(timeout); - return this; - } - - public CachingServiceCallServiceListStrategy<T> timeout(long timeout, TimeUnit unit) { - setTimeout(timeout, unit); - return this; - } - - @Override - public List<T> getInitialListOfServers(String name) { - return delegate.getInitialListOfServers(name); - } - - @Override - public List<T> getUpdatedListOfServers(String name) { - long now = System.currentTimeMillis(); - - if (lastUpdate == 0 || now > lastUpdate + timeout) { - List<T> updatedList = delegate.getUpdatedListOfServers(name); - if (updatedList.isEmpty()) { - servers = Collections.emptyList(); - } else { - // List is copied as the delegated ServiceCallServerListStrategy - // may update the list - servers = Collections.unmodifiableList(new ArrayList<>(updatedList)); - } - - lastUpdate = now; - } - - return servers; - } - - // ********************** - // Helpers - // ********************** - - public static <S extends ServiceCallServer> CachingServiceCallServiceListStrategy<S> wrap(ServiceCallServerListStrategy<S> delegate) { - return new CachingServiceCallServiceListStrategy<>(delegate); - } - - public static <S extends ServiceCallServer> CachingServiceCallServiceListStrategy<S> wrap(ServiceCallServerListStrategy<S> delegate, long timeout) { - return new CachingServiceCallServiceListStrategy<>(delegate) - .timeout(timeout); - } - - public static <S extends ServiceCallServer> CachingServiceCallServiceListStrategy<S> wrap(ServiceCallServerListStrategy<S> delegate, long timeout, TimeUnit unit) { - return new CachingServiceCallServiceListStrategy<>(delegate) - .timeout(timeout, unit); - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallExpression.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallExpression.java b/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallExpression.java deleted file mode 100644 index 8d790b2..0000000 --- a/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallExpression.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 - * - * http://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.apache.camel.impl.remote; - -import org.apache.camel.Exchange; -import org.apache.camel.support.ServiceCallExpressionSupport; -import org.apache.camel.util.ExchangeHelper; - -public class DefaultServiceCallExpression extends ServiceCallExpressionSupport { - private final String ipHeader; - private final String portHeader; - - public DefaultServiceCallExpression(String name, String scheme, String contextPath, String uri) { - this(name, scheme, contextPath, uri, ServiceCallConstants.SERVER_IP, ServiceCallConstants.SERVER_PORT); - } - - public DefaultServiceCallExpression(String name, String scheme, String contextPath, String uri, String ipHeader, String portHeader) { - super(name, scheme, contextPath, uri); - - this.ipHeader = ipHeader; - this.portHeader = portHeader; - } - - @Override - public String getIp(Exchange exchange) throws Exception { - return ExchangeHelper.getMandatoryHeader(exchange, ipHeader, String.class); - } - - @Override - public int getPort(Exchange exchange) throws Exception { - return ExchangeHelper.getMandatoryHeader(exchange, portHeader, int.class); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallProcessor.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallProcessor.java b/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallProcessor.java deleted file mode 100644 index 9340406..0000000 --- a/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallProcessor.java +++ /dev/null @@ -1,250 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 - * - * http://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.apache.camel.impl.remote; - -import java.util.List; -import java.util.concurrent.RejectedExecutionException; - -import org.apache.camel.AsyncCallback; -import org.apache.camel.AsyncProcessor; -import org.apache.camel.CamelContext; -import org.apache.camel.CamelContextAware; -import org.apache.camel.Exchange; -import org.apache.camel.ExchangePattern; -import org.apache.camel.Expression; -import org.apache.camel.Traceable; -import org.apache.camel.processor.SendDynamicProcessor; -import org.apache.camel.spi.IdAware; -import org.apache.camel.spi.ServiceCallLoadBalancer; -import org.apache.camel.spi.ServiceCallServer; -import org.apache.camel.spi.ServiceCallServerListStrategy; -import org.apache.camel.support.ServiceSupport; -import org.apache.camel.util.AsyncProcessorHelper; -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.ServiceHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class DefaultServiceCallProcessor<S extends ServiceCallServer> extends ServiceSupport implements AsyncProcessor, CamelContextAware, Traceable, IdAware { - private static final Logger LOG = LoggerFactory.getLogger(DefaultServiceCallProcessor.class); - - private final ExchangePattern exchangePattern; - private final String name; - private final String scheme; - private final String uri; - private final String contextPath; - private CamelContext camelContext; - private String id; - private ServiceCallServerListStrategy<S> serverListStrategy; - private ServiceCallLoadBalancer<S> loadBalancer; - private Expression serviceCallExpression; - private SendDynamicProcessor processor; - - public DefaultServiceCallProcessor(String name, String scheme, String uri, ExchangePattern exchangePattern) { - this.uri = uri; - this.exchangePattern = exchangePattern; - - // setup from the provided name which can contain scheme and context-path information as well - String serviceName; - if (name.contains("/")) { - serviceName = ObjectHelper.before(name, "/"); - this.contextPath = ObjectHelper.after(name, "/"); - } else if (name.contains("?")) { - serviceName = ObjectHelper.before(name, "?"); - this.contextPath = ObjectHelper.after(name, "?"); - } else { - serviceName = name; - this.contextPath = null; - } - if (serviceName.contains(":")) { - this.scheme = ObjectHelper.before(serviceName, ":"); - this.name = ObjectHelper.after(serviceName, ":"); - } else { - this.scheme = scheme; - this.name = serviceName; - } - - this.serviceCallExpression = new DefaultServiceCallExpression( - this.name, - this.scheme, - this.contextPath, - this.uri); - } - - @Override - public CamelContext getCamelContext() { - return camelContext; - } - - @Override - public void setCamelContext(CamelContext camelContext) { - this.camelContext = camelContext; - } - - @Override - public String getId() { - return id; - } - - @Override - public void setId(String id) { - this.id = id; - } - - @Override - public String getTraceLabel() { - return id; - } - - public String getName() { - return name; - } - - public String getScheme() { - return scheme; - } - - public String getContextPath() { - return contextPath; - } - - public String getUri() { - return uri; - } - - public ExchangePattern getExchangePattern() { - return exchangePattern; - } - - public ServiceCallLoadBalancer<S> getLoadBalancer() { - return loadBalancer; - } - - public void setLoadBalancer(ServiceCallLoadBalancer<S> loadBalancer) { - this.loadBalancer = loadBalancer; - } - - public DefaultServiceCallProcessor loadBalancer(ServiceCallLoadBalancer<S> loadBalancer) { - setLoadBalancer(loadBalancer); - return this; - } - - public ServiceCallServerListStrategy<S> getServerListStrategy() { - return serverListStrategy; - } - - public void setServerListStrategy(ServiceCallServerListStrategy<S> serverListStrategy) { - this.serverListStrategy = serverListStrategy; - } - - public DefaultServiceCallProcessor serverListStrategy(ServiceCallServerListStrategy<S> serverListStrategy) { - setServerListStrategy(serverListStrategy); - return this; - } - - public void setServiceCallExpression(Expression serviceCallExpression) { - this.serviceCallExpression = serviceCallExpression; - } - - public Expression getServiceCallExpression() { - return serviceCallExpression; - } - - public DefaultServiceCallProcessor serviceCallExpression(Expression serviceCallExpression) { - setServiceCallExpression(serviceCallExpression); - return this; - } - - public AsyncProcessor getProcessor() { - return processor; - } - - @Override - protected void doStart() throws Exception { - ObjectHelper.notEmpty(getName(), "name", "serviceName"); - ObjectHelper.notNull(camelContext, "camelContext"); - ObjectHelper.notNull(serviceCallExpression, "serviceCallExpression"); - - LOG.info("ServiceCall with service name: {} is using load balancer: {} and service discovery: {}", - name, loadBalancer, serverListStrategy); - - processor = new SendDynamicProcessor(uri, serviceCallExpression); - processor.setCamelContext(getCamelContext()); - if (exchangePattern != null) { - processor.setPattern(exchangePattern); - } - - ServiceHelper.startServices(serverListStrategy, processor); - } - - @Override - protected void doStop() throws Exception { - ServiceHelper.stopServices(processor, serverListStrategy); - } - - @Override - public void process(Exchange exchange) throws Exception { - AsyncProcessorHelper.process(this, exchange); - } - - @Override - public boolean process(Exchange exchange, AsyncCallback callback) { - final String serviceName = exchange.getIn().getHeader(ServiceCallConstants.SERVICE_NAME, name, String.class); - final ServiceCallServer server = chooseServer(exchange, serviceName); - - if (exchange.getException() != null) { - callback.done(true); - return true; - } - - String ip = server.getIp(); - int port = server.getPort(); - LOG.debug("Service {} active at server: {}:{}", name, ip, port); - - // set selected server as header - exchange.getIn().setHeader(ServiceCallConstants.SERVER_IP, ip); - exchange.getIn().setHeader(ServiceCallConstants.SERVER_PORT, port); - exchange.getIn().setHeader(ServiceCallConstants.SERVICE_NAME, serviceName); - - // use the dynamic send processor to call the service - return processor.process(exchange, callback); - } - - protected S chooseServer(Exchange exchange, String serviceName) { - ObjectHelper.notNull(serverListStrategy, "serverListStrategy"); - ObjectHelper.notNull(loadBalancer, "loadBalancer"); - - S server = null; - - try { - List<S> servers = serverListStrategy.getUpdatedListOfServers(serviceName); - if (servers == null || servers.isEmpty()) { - exchange.setException(new RejectedExecutionException("No active services with name " + name)); - } else { - // let the client load balancer chose which server to use - server = servers.size() > 1 ? loadBalancer.chooseServer(servers) : servers.get(0); - if (server == null) { - exchange.setException(new RejectedExecutionException("No active services with name " + name)); - } - } - } catch (Throwable e) { - exchange.setException(e); - } - - return server; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallProcessorFactory.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallProcessorFactory.java b/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallProcessorFactory.java deleted file mode 100644 index 99a0844..0000000 --- a/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallProcessorFactory.java +++ /dev/null @@ -1,289 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 - * - * http://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.apache.camel.impl.remote; - -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - -import org.apache.camel.CamelContextAware; -import org.apache.camel.ExchangePattern; -import org.apache.camel.Processor; -import org.apache.camel.model.PropertyDefinition; -import org.apache.camel.model.remote.ServiceCallConfigurationDefinition; -import org.apache.camel.model.remote.ServiceCallDefinition; -import org.apache.camel.spi.RouteContext; -import org.apache.camel.spi.ServiceCallLoadBalancer; -import org.apache.camel.spi.ServiceCallServer; -import org.apache.camel.spi.ServiceCallServerListStrategy; -import org.apache.camel.util.CamelContextHelper; -import org.apache.camel.util.IntrospectionSupport; -import org.apache.camel.util.ObjectHelper; - -public abstract class DefaultServiceCallProcessorFactory<C, S extends ServiceCallServer> extends AbstractServiceCallProcessorFactory { - protected Processor createProcessor(RouteContext routeContext, ServiceCallDefinition definition) throws Exception { - return createProcessor(routeContext, definition, createConfiguration(routeContext)); - } - - protected Processor createProcessor(RouteContext routeContext, ServiceCallDefinition definition, C cfg) throws Exception { - String name = definition.getName(); - String uri = definition.getUri(); - ExchangePattern mep = definition.getPattern(); - - ServiceCallConfigurationDefinition config = definition.getServiceCallConfiguration(); - ServiceCallConfigurationDefinition configRef = null; - if (definition.getServiceCallConfigurationRef() != null) { - // lookup in registry first - configRef = CamelContextHelper.lookup(routeContext.getCamelContext(), definition.getServiceCallConfigurationRef(), ServiceCallConfigurationDefinition.class); - if (configRef == null) { - // and fallback as service configuration - routeContext.getCamelContext().getServiceCallConfiguration(definition.getServiceCallConfigurationRef(), ServiceCallConfigurationDefinition.class); - } - } - - // if no configuration explicit configured then use default - if (config == null && configRef == null) { - config = routeContext.getCamelContext().getServiceCallConfiguration(null, ServiceCallConfigurationDefinition.class); - } - if (config == null) { - // if no default then try to find if there configuration in the registry of the given type - Set<ServiceCallConfigurationDefinition> set = routeContext.getCamelContext().getRegistry().findByType(ServiceCallConfigurationDefinition.class); - if (set.size() == 1) { - config = set.iterator().next(); - } - } - - if (config == null && configRef == null) { - throw new IllegalStateException("The ServiceCall: " + definition + " must be configured before it can be used."); - } - - if (cfg != null) { - // extract the properties from the configuration from the model - Map<String, Object> parameters = new HashMap<>(); - if (configRef != null) { - IntrospectionSupport.getProperties(configRef, parameters, null); - } - if (config != null) { - IntrospectionSupport.getProperties(config, parameters, null); - } - - IntrospectionSupport.setProperties(cfg, parameters); - } - - // lookup the load balancer to use (configured on EIP takes precedence vs configured on configuration) - ServiceCallLoadBalancer lb = configureLoadBalancer(cfg, routeContext, definition); - if (lb == null && config != null) { - lb = configureLoadBalancer(cfg, routeContext, config); - } - if (lb == null && configRef != null) { - lb = configureLoadBalancer(cfg, routeContext, configRef); - } - - // lookup the server list strategy to use (configured on EIP takes precedence vs configured on configuration) - ServiceCallServerListStrategy sl = configureServerListStrategy(cfg, routeContext, definition); - if (sl == null && config != null) { - sl = configureServerListStrategy(cfg, routeContext, config); - } - if (sl == null && configRef != null) { - sl = configureServerListStrategy(cfg, routeContext, configRef); - } - - // The component is used to configure what the default scheme to use (eg camel component name). - // The component configured on EIP takes precedence vs configured on configuration. - String component = definition.getComponent(); - if (component == null) { - component = config != null ? config.getComponent() : null; - if (component == null && configRef != null) { - component = configRef.getComponent(); - } - } - - if (ObjectHelper.isNotEmpty(lb) && lb instanceof CamelContextAware) { - ((CamelContextAware)lb).setCamelContext(routeContext.getCamelContext()); - } - - if (ObjectHelper.isNotEmpty(sl) && sl instanceof CamelContextAware) { - ((CamelContextAware)sl).setCamelContext(routeContext.getCamelContext()); - } - - if (sl == null) { - sl = createDefaultServerListStrategy(cfg); - } - if (lb == null) { - lb = createDefaultLoadBalancer(cfg); - } - - Map<String, String> properties = configureProperties(routeContext, config, configRef); - - DefaultServiceCallProcessor processor = createProcessor(name, component, uri, mep, cfg, properties); - if (sl != null && processor.getServerListStrategy() == null) { - processor.setServerListStrategy(sl); - } - if (lb != null && processor.getLoadBalancer() == null) { - processor.setLoadBalancer(lb); - } - - return processor; - } - - // ************************************************************************* - // Helpers - // ************************************************************************* - - protected Map<String, String> configureProperties( - RouteContext routeContext, ServiceCallConfigurationDefinition config, ServiceCallConfigurationDefinition configRef) throws Exception { - - Map<String, String> answer = new HashMap<>(); - if (config != null && config.getProperties() != null) { - for (PropertyDefinition prop : config.getProperties()) { - // support property placeholders - String key = CamelContextHelper.parseText(routeContext.getCamelContext(), prop.getKey()); - String value = CamelContextHelper.parseText(routeContext.getCamelContext(), prop.getValue()); - answer.put(key, value); - } - } - if (configRef != null && configRef.getProperties() != null) { - for (PropertyDefinition prop : configRef.getProperties()) { - // support property placeholders - String key = CamelContextHelper.parseText(routeContext.getCamelContext(), prop.getKey()); - String value = CamelContextHelper.parseText(routeContext.getCamelContext(), prop.getValue()); - answer.put(key, value); - } - } - return answer; - } - - protected ServiceCallLoadBalancer configureLoadBalancer(C conf, RouteContext routeContext, ServiceCallDefinition sd) throws Exception { - ServiceCallLoadBalancer lb = null; - String ref; - - if (sd != null) { - lb = sd.getLoadBalancer(); - ref = sd.getLoadBalancerRef(); - if (lb == null && ref != null) { - lb = builtInLoadBalancer( - conf, - ref) - .orElseGet(() -> CamelContextHelper.mandatoryLookup( - routeContext.getCamelContext(), - ref, - ServiceCallLoadBalancer.class) - ); - } - } - - return lb; - } - - protected ServiceCallLoadBalancer configureLoadBalancer(C conf, RouteContext routeContext, ServiceCallConfigurationDefinition config) throws Exception { - ServiceCallLoadBalancer lb = config.getLoadBalancer(); - String ref = config.getLoadBalancerRef(); - if (lb == null && ref != null) { - lb = builtInLoadBalancer( - conf, - ref) - .orElseGet(() ->CamelContextHelper.mandatoryLookup( - routeContext.getCamelContext(), - ref, - ServiceCallLoadBalancer.class) - ); - } - return lb; - } - - protected ServiceCallServerListStrategy configureServerListStrategy(C conf, RouteContext routeContext, ServiceCallDefinition sd) throws Exception { - ServiceCallServerListStrategy sl = null; - String ref; - if (sd != null) { - sl = sd.getServerListStrategy(); - ref = sd.getServerListStrategyRef(); - if (sl == null && ref != null) { - sl = builtInServerListStrategy( - conf, - ref) - .orElseGet(() -> CamelContextHelper.mandatoryLookup( - routeContext.getCamelContext(), - ref, - ServiceCallServerListStrategy.class) - ); - } - } - - return sl; - } - - protected ServiceCallServerListStrategy configureServerListStrategy(C conf, RouteContext routeContext, ServiceCallConfigurationDefinition config) throws Exception { - ServiceCallServerListStrategy sl = config.getServerListStrategy(); - String ref = config.getServerListStrategyRef(); - if (sl == null && ref != null) { - sl = builtInServerListStrategy( - conf, - ref) - .orElseGet(() -> CamelContextHelper.mandatoryLookup( - routeContext.getCamelContext(), - ref, - ServiceCallServerListStrategy.class) - ); - } - - return sl; - } - - // special for ref is referring to built-in load balancers - protected Optional<ServiceCallLoadBalancer> builtInLoadBalancer(C conf, String name) throws Exception { - ServiceCallLoadBalancer lb = null; - if (ObjectHelper.equal(name, "random", true)) { - lb = new RandomServiceCallLoadBalancer(); - } else if (ObjectHelper.equal(name, "roundrobin", true)) { - lb = new RoundRobinServiceCallLoadBalancer(); - } - - return Optional.ofNullable(lb); - } - - // special for ref is referring to built-in server list strategies - protected Optional<ServiceCallServerListStrategy> builtInServerListStrategy(C conf, String name) throws Exception { - return Optional.empty(); - } - - protected DefaultServiceCallProcessor createProcessor( - String name, - String component, - String uri, - ExchangePattern mep, - C conf, - Map<String, String> properties) throws Exception { - - return new DefaultServiceCallProcessor(name, component, uri, mep); - } - - // TODO: rename - protected abstract C createConfiguration(RouteContext routeContext) throws Exception; - - // ************************************************************************* - // Defaults - // ************************************************************************* - - protected ServiceCallLoadBalancer<S> createDefaultLoadBalancer(C conf) throws Exception { - return new RoundRobinServiceCallLoadBalancer<>(); - } - - protected ServiceCallServerListStrategy<S> createDefaultServerListStrategy(C conf) throws Exception { - return null; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallServer.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallServer.java b/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallServer.java deleted file mode 100644 index 30aac8d..0000000 --- a/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallServer.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 - * - * http://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.apache.camel.impl.remote; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.spi.ServiceCallServer; - -public class DefaultServiceCallServer implements ServiceCallServer { - - private final String ip; - private final int port; - private final Map<String, String> meta; - - public DefaultServiceCallServer(String ip, int port) { - this.ip = ip; - this.port = port; - this.meta = Collections.emptyMap(); - } - - public DefaultServiceCallServer(String ip, int port, Map<String, String> meta) { - this.ip = ip; - this.port = port; - this.meta = Collections.unmodifiableMap(new HashMap<>(meta)); - } - - @Override - public String getIp() { - return ip; - } - - @Override - public int getPort() { - return port; - } - - @Override - public Map<String, String> getMetadata() { - return this.meta; - } - - @Override - public String toString() { - return "DefaultServiceCallServer[" + ip + ":" + port + "]"; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallServerListStrategy.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallServerListStrategy.java b/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallServerListStrategy.java deleted file mode 100644 index 48f8b22..0000000 --- a/camel-core/src/main/java/org/apache/camel/impl/remote/DefaultServiceCallServerListStrategy.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 - * - * http://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.apache.camel.impl.remote; - -import java.util.Collections; -import java.util.List; - -import org.apache.camel.CamelContext; -import org.apache.camel.CamelContextAware; -import org.apache.camel.spi.ServiceCallServer; -import org.apache.camel.spi.ServiceCallServerListStrategy; -import org.apache.camel.support.ServiceSupport; - - -public class DefaultServiceCallServerListStrategy<T extends ServiceCallServer> - extends ServiceSupport implements ServiceCallServerListStrategy<T>, CamelContextAware { - - private CamelContext camelContext; - - @Override - public List<T> getInitialListOfServers(String name) { - return Collections.emptyList(); - } - - @Override - public List<T> getUpdatedListOfServers(String name) { - return Collections.emptyList(); - } - - @Override - public void setCamelContext(CamelContext camelContext) { - this.camelContext = camelContext; - } - - @Override - public CamelContext getCamelContext() { - return camelContext; - } - - @Override - protected void doStart() throws Exception { - // nop - } - - @Override - protected void doStop() throws Exception { - // nop - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/remote/RandomServiceCallLoadBalancer.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/remote/RandomServiceCallLoadBalancer.java b/camel-core/src/main/java/org/apache/camel/impl/remote/RandomServiceCallLoadBalancer.java deleted file mode 100644 index a9d7af2..0000000 --- a/camel-core/src/main/java/org/apache/camel/impl/remote/RandomServiceCallLoadBalancer.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 - * - * http://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.apache.camel.impl.remote; - -import java.util.List; -import java.util.Random; - -import org.apache.camel.spi.ServiceCallLoadBalancer; -import org.apache.camel.spi.ServiceCallServer; - -public class RandomServiceCallLoadBalancer implements ServiceCallLoadBalancer<ServiceCallServer> { - private final Random random; - - public RandomServiceCallLoadBalancer() { - this.random = new Random(); - } - - @Override - public ServiceCallServer chooseServer(List<ServiceCallServer> servers) { - int size = servers.size(); - int index = (size > 1) ? random.nextInt(size) : 0; - - return servers.get(index); - } - - @Override - public String toString() { - return "RandomServiceCallLoadBalancer"; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/remote/RoundRobinServiceCallLoadBalancer.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/remote/RoundRobinServiceCallLoadBalancer.java b/camel-core/src/main/java/org/apache/camel/impl/remote/RoundRobinServiceCallLoadBalancer.java deleted file mode 100644 index 966a6ae..0000000 --- a/camel-core/src/main/java/org/apache/camel/impl/remote/RoundRobinServiceCallLoadBalancer.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 - * - * http://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.apache.camel.impl.remote; - -import java.util.List; - -import org.apache.camel.spi.ServiceCallLoadBalancer; -import org.apache.camel.spi.ServiceCallServer; - -public class RoundRobinServiceCallLoadBalancer<S extends ServiceCallServer> implements ServiceCallLoadBalancer<S> { - private int counter = -1; - - @Override - public S chooseServer(List<S> servers) { - int size = servers.size(); - if (++counter >= size || size == 1) { - counter = 0; - } - return servers.get(counter); - } - - @Override - public String toString() { - return "RoundRobinServiceCallLoadBalancer"; - } -} http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/remote/ServiceCallConstants.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/remote/ServiceCallConstants.java b/camel-core/src/main/java/org/apache/camel/impl/remote/ServiceCallConstants.java deleted file mode 100644 index 3d3fb26..0000000 --- a/camel-core/src/main/java/org/apache/camel/impl/remote/ServiceCallConstants.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 - * - * http://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.apache.camel.impl.remote; - - -public interface ServiceCallConstants { - String SERVICE_NAME = "CamelServiceCallServiceName"; - String SERVER_IP = "CamelServiceCallServerIp"; - String SERVER_PORT = "CamelServiceCallServerPort"; -} http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/impl/remote/package.html ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/impl/remote/package.html b/camel-core/src/main/java/org/apache/camel/impl/remote/package.html deleted file mode 100644 index 0cb7249..0000000 --- a/camel-core/src/main/java/org/apache/camel/impl/remote/package.html +++ /dev/null @@ -1,25 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You 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 - - http://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. ---> -<html> -<head> -</head> -<body> - -Remote <a href="http://camel.apache.org/servicecall-eip.html">service call</a> support classes. - -</body> -</html> http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/model/Constants.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/Constants.java b/camel-core/src/main/java/org/apache/camel/model/Constants.java index eaec06e..d6bbf3b 100644 --- a/camel-core/src/main/java/org/apache/camel/model/Constants.java +++ b/camel-core/src/main/java/org/apache/camel/model/Constants.java @@ -26,11 +26,11 @@ public final class Constants { public static final String JAXB_CONTEXT_PACKAGES = "" + "org.apache.camel:" + "org.apache.camel.model:" + + "org.apache.camel.model.cloud:" + "org.apache.camel.model.config:" + "org.apache.camel.model.dataformat:" + "org.apache.camel.model.language:" + "org.apache.camel.model.loadbalancer:" - + "org.apache.camel.model.remote:" + "org.apache.camel.model.rest:" + "org.apache.camel.model.transformer"; http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java index ba5fd37..bf2b315 100644 --- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java @@ -51,11 +51,11 @@ import org.apache.camel.builder.ExpressionBuilder; import org.apache.camel.builder.ExpressionClause; import org.apache.camel.builder.ProcessClause; import org.apache.camel.builder.ProcessorBuilder; +import org.apache.camel.model.cloud.ServiceCallDefinition; import org.apache.camel.model.language.ConstantExpression; import org.apache.camel.model.language.ExpressionDefinition; import org.apache.camel.model.language.LanguageExpression; import org.apache.camel.model.language.SimpleExpression; -import org.apache.camel.model.remote.ServiceCallDefinition; import org.apache.camel.model.rest.RestDefinition; import org.apache.camel.processor.InterceptEndpointProcessor; import org.apache.camel.processor.Pipeline; http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/model/cloud/ConsulServiceCallServiceDiscoveryConfiguration.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/ConsulServiceCallServiceDiscoveryConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/ConsulServiceCallServiceDiscoveryConfiguration.java new file mode 100644 index 0000000..b30f871 --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/model/cloud/ConsulServiceCallServiceDiscoveryConfiguration.java @@ -0,0 +1,258 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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.apache.camel.model.cloud; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +import org.apache.camel.spi.Metadata; +import org.apache.camel.util.jsse.SSLContextParameters; + +@Metadata(label = "routing,cloud,service-discovery") +@XmlRootElement(name = "consulServiceDiscovery") +@XmlAccessorType(XmlAccessType.FIELD) +public class ConsulServiceCallServiceDiscoveryConfiguration extends ServiceCallServiceDiscoveryConfiguration { + @XmlAttribute + private String url; + @XmlAttribute + private String dc; + @XmlAttribute @Metadata(label = "security") + private String aclToken; + @XmlAttribute @Metadata(label = "security") + private String userName; + @XmlAttribute @Metadata(label = "security") + private String password; + @XmlAttribute + private Long connectTimeoutMillis; + @XmlAttribute + private Long readTimeoutMillis; + @XmlAttribute + private Long writeTimeoutMillis; + @XmlAttribute @Metadata(defaultValue = "10") + private Integer blockSeconds = 10; + @XmlTransient + private SSLContextParameters sslContextParameters; + + public ConsulServiceCallServiceDiscoveryConfiguration() { + this(null); + } + + public ConsulServiceCallServiceDiscoveryConfiguration(ServiceCallDefinition parent) { + super(parent, "consul-service-discovery"); + } + + // ************************************************************************* + // Getter/Setter + // ************************************************************************* + + /** + * The Consul agent URL + */ + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getDc() { + return dc; + } + + /** + * The data center + */ + public void setDc(String dc) { + this.dc = dc; + } + + public String getAclToken() { + return aclToken; + } + + /** + * Sets the ACL token to be used with Consul + */ + public void setAclToken(String aclToken) { + this.aclToken = aclToken; + } + + public String getUserName() { + return userName; + } + + /** + * Sets the username to be used for basic authentication + */ + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + /** + * Sets the password to be used for basic authentication + */ + public void setPassword(String password) { + this.password = password; + } + + public Long getConnectTimeoutMillis() { + return connectTimeoutMillis; + } + + /** + * Connect timeout for OkHttpClient + */ + public void setConnectTimeoutMillis(Long connectTimeoutMillis) { + this.connectTimeoutMillis = connectTimeoutMillis; + } + + public Long getReadTimeoutMillis() { + return readTimeoutMillis; + } + + /** + * Read timeout for OkHttpClient + */ + public void setReadTimeoutMillis(Long readTimeoutMillis) { + this.readTimeoutMillis = readTimeoutMillis; + } + + public Long getWriteTimeoutMillis() { + return writeTimeoutMillis; + } + + /** + * Write timeout for OkHttpClient + */ + public void setWriteTimeoutMillis(Long writeTimeoutMillis) { + this.writeTimeoutMillis = writeTimeoutMillis; + } + + public Integer getBlockSeconds() { + return blockSeconds; + } + + /** + * The seconds to wait for a watch event, default 10 seconds + */ + public void setBlockSeconds(Integer blockSeconds) { + this.blockSeconds = blockSeconds; + } + + public SSLContextParameters getSslContextParameters() { + return sslContextParameters; + } + + /** + * To configure security using SSLContextParameters. + */ + public void setSslContextParameters(SSLContextParameters sslContextParameters) { + this.sslContextParameters = sslContextParameters; + } + + // ************************************************************************* + // Fluent API + // ************************************************************************* + + /** + * The Consul agent URL + */ + public ConsulServiceCallServiceDiscoveryConfiguration url(String url) { + setUrl(url); + return this; + } + + /** + * The data center + */ + public ConsulServiceCallServiceDiscoveryConfiguration dc(String dc) { + setDc(dc); + return this; + } + + /** + * Sets the ACL token to be used with Consul + */ + public ConsulServiceCallServiceDiscoveryConfiguration aclToken(String aclToken) { + setAclToken(aclToken); + return this; + } + + /** + * Sets the username to be used for basic authentication + */ + public ConsulServiceCallServiceDiscoveryConfiguration userName(String userName) { + setUserName(userName); + return this; + } + + /** + * Sets the password to be used for basic authentication + */ + public ConsulServiceCallServiceDiscoveryConfiguration password(String password) { + setPassword(password); + return this; + } + + /** + * Connect timeout for OkHttpClient + */ + public ConsulServiceCallServiceDiscoveryConfiguration connectTimeoutMillis(Long connectTimeoutMillis) { + setConnectTimeoutMillis(connectTimeoutMillis); + return this; + } + + /** + * Read timeout for OkHttpClient + */ + public ConsulServiceCallServiceDiscoveryConfiguration readTimeoutMillis(Long readTimeoutMillis) { + setReadTimeoutMillis(readTimeoutMillis); + return this; + } + + /** + * Write timeout for OkHttpClient + */ + public ConsulServiceCallServiceDiscoveryConfiguration writeTimeoutMillis(Long writeTimeoutMillis) { + setWriteTimeoutMillis(writeTimeoutMillis); + return this; + } + + /** + * The seconds to wait for a watch event, default 10 seconds + */ + public ConsulServiceCallServiceDiscoveryConfiguration blockSeconds(Integer blockSeconds) { + setBlockSeconds(blockSeconds); + return this; + } + + /** + * To configure security using SSLContextParameters. + */ + public ConsulServiceCallServiceDiscoveryConfiguration sslContextParameters(SSLContextParameters sslContextParameters) { + setSslContextParameters(sslContextParameters); + return this; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/model/cloud/DnsServiceCallServiceDiscoveryConfiguration.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/DnsServiceCallServiceDiscoveryConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/DnsServiceCallServiceDiscoveryConfiguration.java new file mode 100644 index 0000000..1862ccd --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/model/cloud/DnsServiceCallServiceDiscoveryConfiguration.java @@ -0,0 +1,88 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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.apache.camel.model.cloud; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.camel.spi.Metadata; + +@Metadata(label = "routing,cloud,service-discovery") +@XmlRootElement(name = "dnsServiceDiscovery") +@XmlAccessorType(XmlAccessType.FIELD) +public class DnsServiceCallServiceDiscoveryConfiguration extends ServiceCallServiceDiscoveryConfiguration { + @XmlAttribute @Metadata(defaultValue = "_tcp") + String proto = "_tcp"; + @XmlAttribute + String domain; + + public DnsServiceCallServiceDiscoveryConfiguration() { + this(null); + } + + public DnsServiceCallServiceDiscoveryConfiguration(ServiceCallDefinition parent) { + super(parent, "dns-service-discovery"); + } + + // ************************************************************************* + // Properties + // ************************************************************************* + + public String getProto() { + return proto; + } + + /** + * The transport protocol of the desired service. + */ + public void setProto(String proto) { + this.proto = proto; + } + + public String getDomain() { + return domain; + } + + /** + * The domain name; + */ + public void setDomain(String domain) { + this.domain = domain; + } + + // ************************************************************************* + // Fluent API + // ************************************************************************* + + /** + * The transport protocol of the desired service. + */ + public DnsServiceCallServiceDiscoveryConfiguration proto(String proto) { + setProto(proto); + return this; + } + + /** + * The domain name; + */ + public DnsServiceCallServiceDiscoveryConfiguration domain(String domain) { + setDomain(domain); + return this; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/model/cloud/EtcdServiceCallServiceDiscoveryConfiguration.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/EtcdServiceCallServiceDiscoveryConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/EtcdServiceCallServiceDiscoveryConfiguration.java new file mode 100644 index 0000000..22bd4cf --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/model/cloud/EtcdServiceCallServiceDiscoveryConfiguration.java @@ -0,0 +1,194 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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.apache.camel.model.cloud; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlTransient; + +import org.apache.camel.spi.Metadata; +import org.apache.camel.util.jsse.SSLContextParameters; + +@Metadata(label = "routing,cloud,service-discovery") +@XmlRootElement(name = "etcdServiceDiscovery") +@XmlAccessorType(XmlAccessType.FIELD) +public class EtcdServiceCallServiceDiscoveryConfiguration extends ServiceCallServiceDiscoveryConfiguration { + @XmlAttribute + private String uris; + @XmlAttribute @Metadata(label = "security") + private String userName; + @XmlAttribute @Metadata(label = "security") + private String password; + @XmlAttribute + private Long timeout; + @XmlAttribute @Metadata(defaultValue = "/services/") + private String servicePath = "/services/"; + @XmlTransient + private SSLContextParameters sslContextParameters; + @XmlAttribute @Metadata(defaultValue = "on-demand", enums = "on-demand,watch") + private String type = "on-demand"; + + public EtcdServiceCallServiceDiscoveryConfiguration() { + this(null); + } + + public EtcdServiceCallServiceDiscoveryConfiguration(ServiceCallDefinition parent) { + super(parent, "etcd-service-discovery"); + } + + // ************************************************************************* + // Properties + // ************************************************************************* + + public String getUris() { + return uris; + } + + /** + * The URIs the client can connect to. + */ + public void setUris(String uris) { + this.uris = uris; + } + + public String getUserName() { + return userName; + } + + /** + * The user name to use for basic authentication. + */ + public void setUserName(String userName) { + this.userName = userName; + } + public String getPassword() { + return password; + } + + /** + * The password to use for basic authentication. + */ + public void setPassword(String password) { + this.password = password; + } + + public Long getTimeout() { + return timeout; + } + + /** + * To set the maximum time an action could take to complete. + */ + public void setTimeout(Long timeout) { + this.timeout = timeout; + } + + public String getServicePath() { + return servicePath; + } + + /** + * The path to look for for service discovery + */ + public void setServicePath(String servicePath) { + this.servicePath = servicePath; + } + + public SSLContextParameters getSslContextParameters() { + return sslContextParameters; + } + + /** + * To configure security using SSLContextParameters. + */ + public void setSslContextParameters(SSLContextParameters sslContextParameters) { + this.sslContextParameters = sslContextParameters; + } + + public String getType() { + return type; + } + + /** + * To set the discovery type, valid values are on-demand and watch. + */ + public void setType(String type) { + this.type = type; + } + + // ************************************************************************* + // Fluent API + // ************************************************************************* + + /** + * The URIs the client can connect to. + */ + public EtcdServiceCallServiceDiscoveryConfiguration uris(String uris) { + setUris(uris); + return this; + } + + /** + * The user name to use for basic authentication. + */ + public EtcdServiceCallServiceDiscoveryConfiguration userName(String userName) { + setUserName(userName); + return this; + } + + /** + * The password to use for basic authentication. + */ + public EtcdServiceCallServiceDiscoveryConfiguration password(String password) { + setPassword(password); + return this; + } + + /** + * To set the maximum time an action could take to complete. + */ + public EtcdServiceCallServiceDiscoveryConfiguration timeout(Long timeout) { + setTimeout(timeout); + return this; + } + + /** + * The path to look for for service discovery + */ + public EtcdServiceCallServiceDiscoveryConfiguration servicePath(String servicePath) { + setServicePath(servicePath); + return this; + } + + /** + * To configure security using SSLContextParameters. + */ + public EtcdServiceCallServiceDiscoveryConfiguration sslContextParameters(SSLContextParameters sslContextParameters) { + setSslContextParameters(sslContextParameters); + return this; + } + + /** + * To set the discovery type, valid values are on-demand and watch. + */ + public EtcdServiceCallServiceDiscoveryConfiguration type(String type) { + setType(type); + return this; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/a811f400/camel-core/src/main/java/org/apache/camel/model/cloud/KubernetesServiceCallServiceDiscoveryConfiguration.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/cloud/KubernetesServiceCallServiceDiscoveryConfiguration.java b/camel-core/src/main/java/org/apache/camel/model/cloud/KubernetesServiceCallServiceDiscoveryConfiguration.java new file mode 100644 index 0000000..0aa9cbe --- /dev/null +++ b/camel-core/src/main/java/org/apache/camel/model/cloud/KubernetesServiceCallServiceDiscoveryConfiguration.java @@ -0,0 +1,421 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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.apache.camel.model.cloud; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.camel.spi.Metadata; + +@Metadata(label = "routing,cloud,service-discovery") +@XmlRootElement(name = "kubernetesServiceDiscovery") +@XmlAccessorType(XmlAccessType.FIELD) +public class KubernetesServiceCallServiceDiscoveryConfiguration extends ServiceCallServiceDiscoveryConfiguration { + @XmlAttribute @Metadata(defaultValue = "environment", enums = "environment,dns,client") + private String lookup = "environment"; + @XmlAttribute + private String dnsDomain; + @XmlAttribute + private String namespace; + @XmlAttribute + private String apiVersion; + @XmlAttribute @Metadata(label = "client") + private String masterUrl; + @XmlAttribute @Metadata(label = "client") + private String username; + @XmlAttribute @Metadata(label = "client") + private String password; + @XmlAttribute @Metadata(label = "client") + private String oauthToken; + @XmlAttribute @Metadata(label = "client") + private String caCertData; + @XmlAttribute @Metadata(label = "client") + private String caCertFile; + @XmlAttribute @Metadata(label = "client") + private String clientCertData; + @XmlAttribute @Metadata(label = "client") + private String clientCertFile; + @XmlAttribute @Metadata(label = "client") + private String clientKeyAlgo; + @XmlAttribute @Metadata(label = "client") + private String clientKeyData; + @XmlAttribute @Metadata(label = "client") + private String clientKeyFile; + @XmlAttribute @Metadata(label = "client") + private String clientKeyPassphrase; + @XmlAttribute @Metadata(label = "client") + private Boolean trustCerts; + + public KubernetesServiceCallServiceDiscoveryConfiguration() { + this(null); + } + + public KubernetesServiceCallServiceDiscoveryConfiguration(ServiceCallDefinition parent) { + super(parent, "kubernetes-service-discovery"); + } + + // ************************************************************************* + // Properties + // ************************************************************************* + + public String getMasterUrl() { + return masterUrl; + } + + /** + * Sets the URL to the master when using client lookup + */ + public void setMasterUrl(String masterUrl) { + this.masterUrl = masterUrl; + } + + public String getNamespace() { + return namespace; + } + + /** + * Sets the namespace to use. Will by default use namespace from the ENV variable KUBERNETES_MASTER. + */ + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + public String getApiVersion() { + return apiVersion; + } + + /** + * Sets the API version when using client lookup + */ + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + } + + public String getLookup() { + return lookup; + } + + /** + * How to perform service lookup. Possible values: client, dns, environment. + * <p/> + * When using client, then the client queries the kubernetes master to obtain a list + * of active pods that provides the service, and then random (or round robin) select a pod. + * <p/> + * When using dns the service name is resolved as <tt>name.namespace.service.dnsDomain</tt>. + * <p/> + * When using environment then environment variables are used to lookup the service. + * <p/> + * By default environment is used. + */ + public void setLookup(String lookup) { + this.lookup = lookup; + } + + public String getDnsDomain() { + return dnsDomain; + } + + /** + * Sets the DNS domain to use for DNS lookup. + */ + public void setDnsDomain(String dnsDomain) { + this.dnsDomain = dnsDomain; + } + + public String getUsername() { + return username; + } + + /** + * Sets the username for authentication when using client lookup + */ + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + /** + * Sets the password for authentication when using client lookup + */ + public void setPassword(String password) { + this.password = password; + } + + public String getOauthToken() { + return oauthToken; + } + + /** + * Sets the OAUTH token for authentication (instead of username/password) when using client lookup + */ + public void setOauthToken(String oauthToken) { + this.oauthToken = oauthToken; + } + + public String getCaCertData() { + return caCertData; + } + + /** + * Sets the Certificate Authority data when using client lookup + */ + public void setCaCertData(String caCertData) { + this.caCertData = caCertData; + } + + public String getCaCertFile() { + return caCertFile; + } + + /** + * Sets the Certificate Authority data that are loaded from the file when using client lookup + */ + public void setCaCertFile(String caCertFile) { + this.caCertFile = caCertFile; + } + + public String getClientCertData() { + return clientCertData; + } + + /** + * Sets the Client Certificate data when using client lookup + */ + public void setClientCertData(String clientCertData) { + this.clientCertData = clientCertData; + } + + public String getClientCertFile() { + return clientCertFile; + } + + /** + * Sets the Client Certificate data that are loaded from the file when using client lookup + */ + public void setClientCertFile(String clientCertFile) { + this.clientCertFile = clientCertFile; + } + + public String getClientKeyAlgo() { + return clientKeyAlgo; + } + + /** + * Sets the Client Keystore algorithm, such as RSA when using client lookup + */ + public void setClientKeyAlgo(String clientKeyAlgo) { + this.clientKeyAlgo = clientKeyAlgo; + } + + public String getClientKeyData() { + return clientKeyData; + } + + /** + * Sets the Client Keystore data when using client lookup + */ + public void setClientKeyData(String clientKeyData) { + this.clientKeyData = clientKeyData; + } + + public String getClientKeyFile() { + return clientKeyFile; + } + + /** + * Sets the Client Keystore data that are loaded from the file when using client lookup + */ + public void setClientKeyFile(String clientKeyFile) { + this.clientKeyFile = clientKeyFile; + } + + public String getClientKeyPassphrase() { + return clientKeyPassphrase; + } + + /** + * Sets the Client Keystore passphrase when using client lookup + */ + public void setClientKeyPassphrase(String clientKeyPassphrase) { + this.clientKeyPassphrase = clientKeyPassphrase; + } + + public Boolean getTrustCerts() { + return trustCerts; + } + + /** + * Sets whether to turn on trust certificate check when using client lookup + */ + public void setTrustCerts(Boolean trustCerts) { + this.trustCerts = trustCerts; + } + + // ************************************************************************* + // Fluent API + // ************************************************************************* + + /** + * Sets the URL to the master when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration masterUrl(String masterUrl) { + setMasterUrl(masterUrl); + return this; + } + + /** + * Sets the namespace to use. Will by default use namespace from the ENV variable KUBERNETES_MASTER. + */ + public KubernetesServiceCallServiceDiscoveryConfiguration namespace(String namespace) { + setNamespace(namespace); + return this; + } + + /** + * Sets the API version when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration apiVersion(String apiVersion) { + setApiVersion(apiVersion); + return this; + } + + /** + * How to perform service lookup. Possible values: client, dns, environment. + * <p/> + * When using client, then the client queries the kubernetes master to obtain a list + * of active pods that provides the service, and then random (or round robin) select a pod. + * <p/> + * When using dns the service name is resolved as <tt>name.namespace.service.dnsDomain</tt>. + * <p/> + * When using environment then environment variables are used to lookup the service. + * <p/> + * By default environment is used. + */ + public KubernetesServiceCallServiceDiscoveryConfiguration lookup(String lookup) { + setLookup(lookup); + return this; + } + + /** + * Sets the DNS domain to use for DNS lookup. + */ + public KubernetesServiceCallServiceDiscoveryConfiguration dnsDomain(String dnsDomain) { + setDnsDomain(dnsDomain); + return this; + } + + /** + * Sets the username for authentication when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration username(String username) { + setUsername(username); + return this; + } + + /** + * Sets the password for authentication when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration password(String password) { + setPassword(password); + return this; + } + + /** + * Sets the OAUTH token for authentication (instead of username/password) when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration oauthToken(String oauthToken) { + setOauthToken(oauthToken); + return this; + } + + /** + * Sets the Certificate Authority data when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration caCertData(String caCertData) { + setCaCertData(caCertData); + return this; + } + + /** + * Sets the Certificate Authority data that are loaded from the file when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration caCertFile(String caCertFile) { + setCaCertFile(caCertFile); + return this; + } + + /** + * Sets the Client Certificate data when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration clientCertData(String clientCertData) { + setClientCertData(clientCertData); + return this; + } + + /** + * Sets the Client Certificate data that are loaded from the file when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration clientCertFile(String clientCertFile) { + setClientCertFile(clientCertFile); + return this; + } + + /** + * Sets the Client Keystore algorithm, such as RSA when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration clientKeyAlgo(String clientKeyAlgo) { + setClientKeyAlgo(clientKeyAlgo); + return this; + } + + /** + * Sets the Client Keystore data when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration clientKeyData(String clientKeyData) { + setClientKeyData(clientKeyData); + return this; + } + + /** + * Sets the Client Keystore data that are loaded from the file when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration clientKeyFile(String clientKeyFile) { + setClientKeyFile(clientKeyFile); + return this; + } + + /** + * Sets the Client Keystore passphrase when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration clientKeyPassphrase(String clientKeyPassphrase) { + setClientKeyPassphrase(clientKeyPassphrase); + return this; + } + + /** + * Sets whether to turn on trust certificate check when using client lookup + */ + public KubernetesServiceCallServiceDiscoveryConfiguration trustCerts(boolean trustCerts) { + setTrustCerts(trustCerts); + return this; + } +} \ No newline at end of file