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 2013/07/09 07:54:12 UTC
[1/3] git commit: CAMEL-6521: ActiveMQUuidGenerator should allow
configuring server socket port number
Updated Branches:
refs/heads/camel-2.10.x bb9a50262 -> 95a3189d8
refs/heads/camel-2.11.x 17376da4f -> be7118702
refs/heads/master 99253d9c3 -> 372fd02a9
CAMEL-6521: ActiveMQUuidGenerator should allow configuring server socket port number
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/372fd02a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/372fd02a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/372fd02a
Branch: refs/heads/master
Commit: 372fd02a901677b824124f6e1e4d0f2cd8177187
Parents: 99253d9
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 9 07:51:39 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 9 07:51:39 2013 +0200
----------------------------------------------------------------------
.../camel/impl/ActiveMQUuidGenerator.java | 22 +++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/372fd02a/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java b/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
index 40618fd..297860c 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
@@ -20,6 +20,7 @@ import java.net.ServerSocket;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.camel.spi.UuidGenerator;
+import org.apache.camel.util.IOHelper;
import org.apache.camel.util.InetAddressUtil;
import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
@@ -31,10 +32,15 @@ import org.slf4j.LoggerFactory;
* <p/>
* This implementation is not synchronized but it leverages API which may not be accessible
* in the cloud (such as Google App Engine).
+ * <p/>
+ * The JVM system property {@link #PROPERTY_IDGENERATOR_PORT} can be used to set a specific port
+ * number to be used as part of the initialization process to generate unique UUID.
*/
public class ActiveMQUuidGenerator implements UuidGenerator {
- private static final transient Logger LOG = LoggerFactory.getLogger(ActiveMQUuidGenerator.class);
+ // use same JVM property name as ActiveMQ
+ public static final String PROPERTY_IDGENERATOR_PORT = "activemq.idgenerator.port";
+ private static final transient Logger LOG = LoggerFactory.getLogger(ActiveMQUuidGenerator.class);
private static final String UNIQUE_STUB;
private static int instanceCount;
private static String hostName;
@@ -55,14 +61,24 @@ public class ActiveMQUuidGenerator implements UuidGenerator {
}
if (canAccessSystemProps) {
+ int idGeneratorPort = 0;
+ ServerSocket ss = null;
try {
+ idGeneratorPort = Integer.parseInt(System.getProperty(PROPERTY_IDGENERATOR_PORT, "0"));
+ LOG.trace("Using port {}", idGeneratorPort);
hostName = InetAddressUtil.getLocalHostName();
- ServerSocket ss = new ServerSocket(0);
+ ss = new ServerSocket(idGeneratorPort);
stub = "-" + ss.getLocalPort() + "-" + System.currentTimeMillis() + "-";
Thread.sleep(100);
ss.close();
} catch (Exception ioe) {
- LOG.warn("Could not generate unique stub by using DNS and binding to local port, will fallback and use localhost as name", ioe);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Cannot generate unique stub by using DNS and binding to local port: " + idGeneratorPort, ioe);
+ } else {
+ LOG.warn("Cannot generate unique stub by using DNS and binding to local port: " + idGeneratorPort + " due " + ioe.getMessage());
+ }
+ } finally {
+ IOHelper.close(ss);
}
}
[2/3] git commit: CAMEL-6521: ActiveMQUuidGenerator should allow
configuring server socket port number
Posted by da...@apache.org.
CAMEL-6521: ActiveMQUuidGenerator should allow configuring server socket port number
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/be711870
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/be711870
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/be711870
Branch: refs/heads/camel-2.11.x
Commit: be7118702f331e9e0d37318896ce8513bea90d8d
Parents: 17376da
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 9 07:51:39 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 9 07:53:03 2013 +0200
----------------------------------------------------------------------
.../camel/impl/ActiveMQUuidGenerator.java | 22 +++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/be711870/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java b/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
index 40618fd..297860c 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
@@ -20,6 +20,7 @@ import java.net.ServerSocket;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.camel.spi.UuidGenerator;
+import org.apache.camel.util.IOHelper;
import org.apache.camel.util.InetAddressUtil;
import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
@@ -31,10 +32,15 @@ import org.slf4j.LoggerFactory;
* <p/>
* This implementation is not synchronized but it leverages API which may not be accessible
* in the cloud (such as Google App Engine).
+ * <p/>
+ * The JVM system property {@link #PROPERTY_IDGENERATOR_PORT} can be used to set a specific port
+ * number to be used as part of the initialization process to generate unique UUID.
*/
public class ActiveMQUuidGenerator implements UuidGenerator {
- private static final transient Logger LOG = LoggerFactory.getLogger(ActiveMQUuidGenerator.class);
+ // use same JVM property name as ActiveMQ
+ public static final String PROPERTY_IDGENERATOR_PORT = "activemq.idgenerator.port";
+ private static final transient Logger LOG = LoggerFactory.getLogger(ActiveMQUuidGenerator.class);
private static final String UNIQUE_STUB;
private static int instanceCount;
private static String hostName;
@@ -55,14 +61,24 @@ public class ActiveMQUuidGenerator implements UuidGenerator {
}
if (canAccessSystemProps) {
+ int idGeneratorPort = 0;
+ ServerSocket ss = null;
try {
+ idGeneratorPort = Integer.parseInt(System.getProperty(PROPERTY_IDGENERATOR_PORT, "0"));
+ LOG.trace("Using port {}", idGeneratorPort);
hostName = InetAddressUtil.getLocalHostName();
- ServerSocket ss = new ServerSocket(0);
+ ss = new ServerSocket(idGeneratorPort);
stub = "-" + ss.getLocalPort() + "-" + System.currentTimeMillis() + "-";
Thread.sleep(100);
ss.close();
} catch (Exception ioe) {
- LOG.warn("Could not generate unique stub by using DNS and binding to local port, will fallback and use localhost as name", ioe);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Cannot generate unique stub by using DNS and binding to local port: " + idGeneratorPort, ioe);
+ } else {
+ LOG.warn("Cannot generate unique stub by using DNS and binding to local port: " + idGeneratorPort + " due " + ioe.getMessage());
+ }
+ } finally {
+ IOHelper.close(ss);
}
}
[3/3] git commit: CAMEL-6521: ActiveMQUuidGenerator should allow
configuring server socket port number
Posted by da...@apache.org.
CAMEL-6521: ActiveMQUuidGenerator should allow configuring server socket port number
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/95a3189d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/95a3189d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/95a3189d
Branch: refs/heads/camel-2.10.x
Commit: 95a3189d83603478e0c75747e72319a055664048
Parents: bb9a502
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Jul 9 07:51:39 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Jul 9 07:53:30 2013 +0200
----------------------------------------------------------------------
.../camel/impl/ActiveMQUuidGenerator.java | 22 +++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/95a3189d/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java b/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
index 40618fd..297860c 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ActiveMQUuidGenerator.java
@@ -20,6 +20,7 @@ import java.net.ServerSocket;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.camel.spi.UuidGenerator;
+import org.apache.camel.util.IOHelper;
import org.apache.camel.util.InetAddressUtil;
import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
@@ -31,10 +32,15 @@ import org.slf4j.LoggerFactory;
* <p/>
* This implementation is not synchronized but it leverages API which may not be accessible
* in the cloud (such as Google App Engine).
+ * <p/>
+ * The JVM system property {@link #PROPERTY_IDGENERATOR_PORT} can be used to set a specific port
+ * number to be used as part of the initialization process to generate unique UUID.
*/
public class ActiveMQUuidGenerator implements UuidGenerator {
- private static final transient Logger LOG = LoggerFactory.getLogger(ActiveMQUuidGenerator.class);
+ // use same JVM property name as ActiveMQ
+ public static final String PROPERTY_IDGENERATOR_PORT = "activemq.idgenerator.port";
+ private static final transient Logger LOG = LoggerFactory.getLogger(ActiveMQUuidGenerator.class);
private static final String UNIQUE_STUB;
private static int instanceCount;
private static String hostName;
@@ -55,14 +61,24 @@ public class ActiveMQUuidGenerator implements UuidGenerator {
}
if (canAccessSystemProps) {
+ int idGeneratorPort = 0;
+ ServerSocket ss = null;
try {
+ idGeneratorPort = Integer.parseInt(System.getProperty(PROPERTY_IDGENERATOR_PORT, "0"));
+ LOG.trace("Using port {}", idGeneratorPort);
hostName = InetAddressUtil.getLocalHostName();
- ServerSocket ss = new ServerSocket(0);
+ ss = new ServerSocket(idGeneratorPort);
stub = "-" + ss.getLocalPort() + "-" + System.currentTimeMillis() + "-";
Thread.sleep(100);
ss.close();
} catch (Exception ioe) {
- LOG.warn("Could not generate unique stub by using DNS and binding to local port, will fallback and use localhost as name", ioe);
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Cannot generate unique stub by using DNS and binding to local port: " + idGeneratorPort, ioe);
+ } else {
+ LOG.warn("Cannot generate unique stub by using DNS and binding to local port: " + idGeneratorPort + " due " + ioe.getMessage());
+ }
+ } finally {
+ IOHelper.close(ss);
}
}