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/12 16:25:58 UTC

[camel] branch master updated: CAMEL-14706: camel-core - Optimize and remove JavaUuidGenerator

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 a5ad6c9  CAMEL-14706: camel-core - Optimize and remove JavaUuidGenerator
a5ad6c9 is described below

commit a5ad6c92d596108e49b774fd711527f474408037
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Mar 12 17:21:41 2020 +0100

    CAMEL-14706: camel-core - Optimize and remove JavaUuidGenerator
---
 .../camel/impl/engine/JavaUuidGenerator.java       | 35 --------------
 .../apache/camel/impl/JavaUuidGeneratorTest.java   | 56 ----------------------
 .../modules/ROOT/pages/camel-3x-upgrade-guide.adoc |  5 ++
 .../modules/ROOT/pages/uuidgenerator.adoc          | 46 +++++-------------
 4 files changed, 16 insertions(+), 126 deletions(-)

diff --git a/core/camel-base/src/main/java/org/apache/camel/impl/engine/JavaUuidGenerator.java b/core/camel-base/src/main/java/org/apache/camel/impl/engine/JavaUuidGenerator.java
deleted file mode 100644
index 687d51e..0000000
--- a/core/camel-base/src/main/java/org/apache/camel/impl/engine/JavaUuidGenerator.java
+++ /dev/null
@@ -1,35 +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.engine;
-
-import java.util.UUID;
-
-import org.apache.camel.spi.UuidGenerator;
-
-/**
- * This implementation uses the {@link UUID} from Java.
- * <p/>
- * The implementation of {@link UUID} is synchronized and therefore
- * other {@link org.apache.camel.spi.UuidGenerator} may be faster in high concurrent systems.
- */
-public class JavaUuidGenerator implements UuidGenerator {
-    
-    @Override
-    public String generateUuid() {
-        return UUID.randomUUID().toString();
-    }
-}
diff --git a/core/camel-core/src/test/java/org/apache/camel/impl/JavaUuidGeneratorTest.java b/core/camel-core/src/test/java/org/apache/camel/impl/JavaUuidGeneratorTest.java
deleted file mode 100644
index fac99df..0000000
--- a/core/camel-core/src/test/java/org/apache/camel/impl/JavaUuidGeneratorTest.java
+++ /dev/null
@@ -1,56 +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;
-
-import org.apache.camel.impl.engine.JavaUuidGenerator;
-import org.apache.camel.util.StopWatch;
-import org.apache.camel.util.TimeUtils;
-import org.junit.Assert;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JavaUuidGeneratorTest extends Assert {
-
-    private static final Logger LOG = LoggerFactory.getLogger(JavaUuidGeneratorTest.class);
-
-    @Test
-    public void testGenerateUUID() {
-        JavaUuidGenerator uuidGenerator = new JavaUuidGenerator();
-
-        String firstUUID = uuidGenerator.generateUuid();
-        String secondUUID = uuidGenerator.generateUuid();
-
-        assertTrue(firstUUID.matches("^\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}$"));
-        assertTrue(secondUUID.matches("^\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}$"));
-        assertFalse(firstUUID.equals(secondUUID));
-    }
-
-    @Test
-    public void testPerformance() {
-        JavaUuidGenerator uuidGenerator = new JavaUuidGenerator();
-        StopWatch watch = new StopWatch();
-
-        LOG.info("First id: " + uuidGenerator.generateUuid());
-        for (int i = 0; i < 500000; i++) {
-            uuidGenerator.generateUuid();
-        }
-        LOG.info("Last id:  " + uuidGenerator.generateUuid());
-
-        LOG.info("Took " + TimeUtils.printDuration(watch.taken()));
-    }
-}
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 bd1a648..f3ab8f1 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
@@ -770,3 +770,8 @@ The deprecated method `preProcessUri` has been removed.
 The method `getEndpoint` now throws `NoSuchEndpointException` directly instead of being wrapped
 within an `FailedToResolveEndpoint`.
 
+==== JavaUuidGenerator
+
+The `org.apache.camel.impl.engine.JavaUuidGenerator` class has been removed.
+Its a very slow UUID generator and its not recommended to be used.
+
diff --git a/docs/user-manual/modules/ROOT/pages/uuidgenerator.adoc b/docs/user-manual/modules/ROOT/pages/uuidgenerator.adoc
index a513f6c..5e07cbb 100644
--- a/docs/user-manual/modules/ROOT/pages/uuidgenerator.adoc
+++ b/docs/user-manual/modules/ROOT/pages/uuidgenerator.adoc
@@ -17,23 +17,23 @@ Camel, that it should use your custom implementation:
 == Configuring from Java DSL
 
 [source,java]
------------------------------------------------------------
+----
 getContext().setUuidGenerator(new MyCustomUuidGenerator());
------------------------------------------------------------
+----
 
 Warning: You should not change the UUID generator at runtime (it should only be
 set once)!
 
 [[UuidGenerator-ConfiguringfromSpringDSL]]
-== Configuring from Spring DSL
+== Configuring from XNL DSL
 
 Camel will configure this UUID generator by doing a lookup in the Spring
 bean registry to find the bean of the type
 `org.apache.camel.spi.UuidGenerator`.
 
-[source,java]
----------------------------------------------------------------------------------------
-<bean id="activeMQUuidGenerator" class="org.apache.camel.impl.ActiveMQUuidGenerator" />
+[source,xml]
+----
+<bean id="simpleUuid" class="org.apache.camel.support.SimpleUuidGenerator" />
 
 <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
   <route>
@@ -41,40 +41,16 @@ bean registry to find the bean of the type
     <to uri="mock:result" />
   </route>
 </camelContext>
----------------------------------------------------------------------------------------
+----
 
 [[UuidGenerator-Providedimplementations]]
 == Provided implementations
 
-Camel comes with three implementations of
+Camel comes with two implementations of
 `org.apache.camel.spi.UuidGenerator`:
 
-* `org.apache.camel.impl.JavaUuidGenerator` - This implementation uses
-`java.util.UUID`. The `java.util.UUID` is synchronized and can therefore
-affect performance on high concurrent systems. Therefore consider one of
-the generators.
-* `org.apache.camel.impl.SimpleUuidGenerator` - This implementation use
+* `org.apache.camel.support.SimpleUuidGenerator` - This implementation use
 internally a `java.util.concurrent.atomic.AtomicLong` and increase the
 ID for every call by one. Starting with 1 as the first id.
-* `org.apache.camel.impl.ActiveMQUuidGenerator` - This implementation
-use the ActiveMQ style of ID's. This implementation may use some APIs
-from the JDK which is forbidden to use if running in the cloud (such as
-Google App Engine) and therefore you may have to use one of the other
-generators.
-
-[[UuidGenerator-ActiveMQUuidGenerator]]
-== ActiveMQUuidGenerator
-
-From *Camel 2.10.7/2.11.1* onwards the JVM system property with key:
-`activemq.idgenerator.port` can be used to assign a specific port which
-is used during initialization of the UUID generator. By default the port
-number 0 is used. Though in some cloud infrastructures this is not
-allowed, and thus a specific port can be assigned instead.
-
-[[UuidGenerator-Thedefaultgenerator]]
-== The default generator
-
-* From Camel 2.5 onwards the `ActiveMQUuidGenerator` is the default
-generator because its the fastest. 
-* In Camel 2.4 or older the default is the `JavaUuidGenerator`
-generator. 
+* `org.apache.camel.impl.engine.DefaultUuidGenerator` - This implementation
+use a fast unique UUID generation that is cluster safe (similar to uuid generator in ActiveMQ)