You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/03/31 09:59:29 UTC

[camel] branch master updated: CAMEL-14813: Remove CachingServiceDiscovery (#3694)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new ddea0ae  CAMEL-14813: Remove CachingServiceDiscovery (#3694)
ddea0ae is described below

commit ddea0ae2bb5ea60e58ccfda450f09efb5bc6b3ec
Author: Luca Burgazzoli <lb...@users.noreply.github.com>
AuthorDate: Tue Mar 31 11:59:16 2020 +0200

    CAMEL-14813: Remove CachingServiceDiscovery (#3694)
---
 core/camel-cloud/pom.xml                           |  4 -
 .../apache/camel/cloud/caching-service-discovery   |  2 -
 .../camel/impl/cloud/CachingServiceDiscovery.java  | 95 ----------------------
 .../impl/cloud/CachingServiceDiscoveryFactory.java | 79 ------------------
 .../impl/cloud/CachingServiceDiscoveryTest.java    | 68 ----------------
 .../modules/ROOT/pages/camel-3x-upgrade-guide.adoc | 24 ++++++
 6 files changed, 24 insertions(+), 248 deletions(-)

diff --git a/core/camel-cloud/pom.xml b/core/camel-cloud/pom.xml
index 1bcb1a4..21d75ba 100644
--- a/core/camel-cloud/pom.xml
+++ b/core/camel-cloud/pom.xml
@@ -43,10 +43,6 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-core-engine</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>camel-caffeine-lrucache</artifactId>
-        </dependency>
 
         <!-- testing -->
         <dependency>
diff --git a/core/camel-cloud/src/generated/resources/META-INF/services/org/apache/camel/cloud/caching-service-discovery b/core/camel-cloud/src/generated/resources/META-INF/services/org/apache/camel/cloud/caching-service-discovery
deleted file mode 100644
index c0be62f..0000000
--- a/core/camel-cloud/src/generated/resources/META-INF/services/org/apache/camel/cloud/caching-service-discovery
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generated by camel build tools - do NOT edit this file!
-class=org.apache.camel.impl.cloud.CachingServiceDiscoveryFactory
diff --git a/core/camel-cloud/src/main/java/org/apache/camel/impl/cloud/CachingServiceDiscovery.java b/core/camel-cloud/src/main/java/org/apache/camel/impl/cloud/CachingServiceDiscovery.java
deleted file mode 100644
index ec6f5bc..0000000
--- a/core/camel-cloud/src/main/java/org/apache/camel/impl/cloud/CachingServiceDiscovery.java
+++ /dev/null
@@ -1,95 +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.cloud;
-
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import com.github.benmanes.caffeine.cache.Caffeine;
-import com.github.benmanes.caffeine.cache.LoadingCache;
-import org.apache.camel.cloud.ServiceDefinition;
-import org.apache.camel.cloud.ServiceDiscovery;
-import org.apache.camel.util.ObjectHelper;
-
-public final class CachingServiceDiscovery implements ServiceDiscovery {
-    private final ServiceDiscovery delegate;
-    private LoadingCache<String, List<ServiceDefinition>> cache;
-    private long timeout;
-
-    public CachingServiceDiscovery(ServiceDiscovery delegate) {
-        this(delegate, 60 * 1000);
-    }
-
-    public CachingServiceDiscovery(ServiceDiscovery delegate, long timeout, TimeUnit unit) {
-        this(delegate, unit.toMillis(timeout));
-    }
-
-    public CachingServiceDiscovery(ServiceDiscovery delegate, long timeout) {
-        this.delegate = ObjectHelper.notNull(delegate, "delegate");
-        setTimeout(timeout);
-    }
-
-    public ServiceDiscovery getDelegate() {
-        return this.delegate;
-    }
-
-    public void setTimeout(long timeout) {
-        this.timeout = timeout;
-        this.cache = Caffeine.newBuilder()
-            .expireAfterAccess(timeout, TimeUnit.MILLISECONDS)
-            .build(delegate::getServices);
-    }
-
-    public void setTimeout(long timeout, TimeUnit unit) {
-        setTimeout(unit.toMillis(timeout));
-    }
-
-    public long getTimeout() {
-        return timeout;
-    }
-
-    public CachingServiceDiscovery timeout(long timeout) {
-        setTimeout(timeout);
-        return this;
-    }
-
-    public CachingServiceDiscovery timeout(long timeout, TimeUnit unit) {
-        setTimeout(timeout, unit);
-        return this;
-    }
-
-    @Override
-    public List<ServiceDefinition> getServices(String name) {
-        return cache.get(name);
-    }
-
-    // **********************
-    // Helpers
-    // **********************
-
-    public static CachingServiceDiscovery wrap(ServiceDiscovery delegate) {
-        return new CachingServiceDiscovery(delegate);
-    }
-
-    public static CachingServiceDiscovery wrap(ServiceDiscovery delegate, long timeout) {
-        return new CachingServiceDiscovery(delegate).timeout(timeout);
-    }
-
-    public static CachingServiceDiscovery wrap(ServiceDiscovery delegate, long timeout, TimeUnit unit) {
-        return new CachingServiceDiscovery(delegate).timeout(timeout, unit);
-    }
-}
diff --git a/core/camel-cloud/src/main/java/org/apache/camel/impl/cloud/CachingServiceDiscoveryFactory.java b/core/camel-cloud/src/main/java/org/apache/camel/impl/cloud/CachingServiceDiscoveryFactory.java
deleted file mode 100644
index 5576782..0000000
--- a/core/camel-cloud/src/main/java/org/apache/camel/impl/cloud/CachingServiceDiscoveryFactory.java
+++ /dev/null
@@ -1,79 +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.cloud;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.cloud.ServiceDiscovery;
-import org.apache.camel.cloud.ServiceDiscoveryFactory;
-import org.apache.camel.spi.annotations.CloudServiceFactory;
-import org.apache.camel.util.ObjectHelper;
-
-@CloudServiceFactory("caching-service-discovery")
-public class CachingServiceDiscoveryFactory implements ServiceDiscoveryFactory {
-    private Integer timeout;
-    private TimeUnit units;
-    private ServiceDiscovery serviceDiscovery;
-
-    public CachingServiceDiscoveryFactory() {
-    }
-
-    // *************************************************************************
-    // Properties
-    // *************************************************************************
-
-    public Integer getTimeout() {
-        return timeout;
-    }
-
-    public void setTimeout(Integer timeout) {
-        this.timeout = timeout;
-    }
-
-    public TimeUnit getUnits() {
-        return units;
-    }
-
-    public void setUnits(TimeUnit units) {
-        this.units = units;
-    }
-
-    public ServiceDiscovery getServiceDiscovery() {
-        return serviceDiscovery;
-    }
-
-    public void setServiceDiscovery(ServiceDiscovery serviceDiscovery) {
-        this.serviceDiscovery = serviceDiscovery;
-    }
-
-    // *************************************************************************
-    // Factory
-    // *************************************************************************
-
-    @Override
-    public ServiceDiscovery newInstance(CamelContext camelContext) throws Exception {
-        ObjectHelper.notNull(serviceDiscovery, "ServiceDiscovery configuration");
-        ObjectHelper.notNull(timeout, "CachingServiceDiscovery timeout");
-        ObjectHelper.notNull(units, "CachingServiceDiscovery time units");
-
-        return new CachingServiceDiscovery(
-            serviceDiscovery,
-            units.toMillis(timeout)
-        );
-    }
-}
diff --git a/core/camel-cloud/src/test/java/org/apache/camel/impl/cloud/CachingServiceDiscoveryTest.java b/core/camel-cloud/src/test/java/org/apache/camel/impl/cloud/CachingServiceDiscoveryTest.java
deleted file mode 100644
index b04bb31..0000000
--- a/core/camel-cloud/src/test/java/org/apache/camel/impl/cloud/CachingServiceDiscoveryTest.java
+++ /dev/null
@@ -1,68 +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.cloud;
-
-import java.util.Arrays;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.model.cloud.CachingServiceCallServiceDiscoveryConfiguration;
-import org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class CachingServiceDiscoveryTest extends ContextTestSupport {
-
-    @Test
-    public void testCachingServiceDiscovery() throws Exception {
-        StaticServiceDiscovery discovery = new StaticServiceDiscovery();
-        CachingServiceDiscovery caching = CachingServiceDiscovery.wrap(discovery, 50, TimeUnit.MILLISECONDS);
-
-        discovery.addServer(new DefaultServiceDefinition("noname", "localhost", 1111));
-        Assert.assertEquals(1, caching.getServices("noname").size());
-        discovery.addServer(new DefaultServiceDefinition("noname", "localhost", 1112));
-        Assert.assertEquals(1, caching.getServices("noname").size());
-
-        // Let the cache expire
-        Thread.sleep(100);
-
-        Assert.assertEquals(2, caching.getServices("noname").size());
-    }
-
-    @Test
-    public void testCachingServiceDiscoveryConfiguration() throws Exception {
-        StaticServiceCallServiceDiscoveryConfiguration staticConf = new StaticServiceCallServiceDiscoveryConfiguration();
-        staticConf.setServers(Arrays.asList("no-name@localhost:1111"));
-
-        CachingServiceCallServiceDiscoveryConfiguration cachingConf = new CachingServiceCallServiceDiscoveryConfiguration();
-        cachingConf.setServiceDiscoveryConfiguration(staticConf);
-        cachingConf.timeout(50);
-        cachingConf.setUnits(TimeUnit.MILLISECONDS.name());
-
-        CachingServiceDiscovery caching = (CachingServiceDiscovery)cachingConf.newInstance(context);
-        StaticServiceDiscovery delegate = (StaticServiceDiscovery)caching.getDelegate();
-
-        Assert.assertEquals(1, caching.getServices("no-name").size());
-        delegate.addServer("no-name@localhost:1112");
-        Assert.assertEquals(1, caching.getServices("no-name").size());
-
-        // Let the cache expire
-        Thread.sleep(100);
-
-        Assert.assertEquals(2, caching.getServices("no-name").size());
-    }
-}
diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
index e9d765c..16598ef 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide.adoc
@@ -9,6 +9,30 @@ xref:camel-3-migration-guide.adoc[Camel 2.x to 3.0 Migration Guide].
 For example if you are upgrading Camel 3.0 to 3.2, then you should follow the guides
 from both 3.0 to 3.1 and 3.1 to 3.2.
 
+== Upgrading Camel 3.1 to 3.2
+
+=== Rest Configuration
+
+The rest configuration has been simplified and there is now a single RestConfiguration instance (https://issues.apache.org/jira/browse/CAMEL-13844[CAMEL-13844]) per Camel Context.
+
+The following methods have been removed:
+
+* org.apache.camel.CamelContext#addRestConfiguration(RestConfiguration restConfiguration)
+* org.apache.camel.CamelContext#getRestConfiguration(String component, boolean defaultIfNotFound)
+* org.apache.camel.CamelContext#getRestConfigurations
+
+
+https://issues.apache.org/jira/browse/CAMEL-13844
+
+=== Camel Cloud
+
+The following `ServiceDiscovery` implementation has been removed: 
+
+* org.apache.camel.impl.cloud.CachingServiceDiscovery
+* org.apache.camel.impl.cloud.CachingServiceDiscoveryFactoyr
+
+https://issues.apache.org/jira/browse/CAMEL-14813
+
 == Upgrading Camel 3.0 to 3.1
 
 === camel-ahc, camel-netty-http, camel-undertow