You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cm...@apache.org on 2013/09/30 22:51:26 UTC
git commit: CAMEL-6675: Upgrade to hazelcast 3.0.x. Thanks Marios
Trivizas for the patch.
Updated Branches:
refs/heads/master f187868e3 -> 507045961
CAMEL-6675: Upgrade to hazelcast 3.0.x. Thanks Marios Trivizas for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/50704596
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/50704596
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/50704596
Branch: refs/heads/master
Commit: 507045961afbed5d9b3e79f30f51ec0fcbd64ff2
Parents: f187868
Author: cmueller <cm...@apache.org>
Authored: Mon Sep 30 22:51:13 2013 +0200
Committer: cmueller <cm...@apache.org>
Committed: Mon Sep 30 22:51:13 2013 +0200
----------------------------------------------------------------------
components/camel-hazelcast/pom.xml | 2 +-
.../HazelcastAtomicnumberProducer.java | 7 ++-
.../hazelcast/seda/HazelcastSedaConsumer.java | 35 +++++++-------
.../HazelcastMapProducerForSpringTest.java | 31 +-----------
.../hazelcast/HazelcastMapProducerTest.java | 31 +-----------
.../component/hazelcast/testutil/Dummy.java | 50 ++++++++++++++++++++
parent/pom.xml | 2 +-
7 files changed, 75 insertions(+), 83 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/50704596/components/camel-hazelcast/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/pom.xml b/components/camel-hazelcast/pom.xml
index 4b82258..ac16d58 100644
--- a/components/camel-hazelcast/pom.xml
+++ b/components/camel-hazelcast/pom.xml
@@ -31,7 +31,7 @@
<properties>
<camel.osgi.import.before.defaults>
- com.hazelcast.*;version="[1.9,3)"
+ com.hazelcast.*;version="[3.0,4)"
</camel.osgi.import.before.defaults>
<camel.osgi.export.pkg>
org.apache.camel.component.hazelcast.*;${camel.osgi.version},
http://git-wip-us.apache.org/repos/asf/camel/blob/50704596/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberProducer.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberProducer.java
index eef43d0..2f4f454 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberProducer.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/atomicnumber/HazelcastAtomicnumberProducer.java
@@ -18,9 +18,8 @@ package org.apache.camel.component.hazelcast.atomicnumber;
import java.util.Map;
-import com.hazelcast.core.AtomicNumber;
-
import com.hazelcast.core.HazelcastInstance;
+import com.hazelcast.core.IAtomicLong;
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.component.hazelcast.HazelcastComponentHelper;
@@ -29,12 +28,12 @@ import org.apache.camel.impl.DefaultProducer;
public class HazelcastAtomicnumberProducer extends DefaultProducer {
- private final AtomicNumber atomicnumber;
+ private final IAtomicLong atomicnumber;
private final HazelcastComponentHelper helper = new HazelcastComponentHelper();
public HazelcastAtomicnumberProducer(HazelcastInstance hazelcastInstance, Endpoint endpoint, String cacheName) {
super(endpoint);
- this.atomicnumber = hazelcastInstance.getAtomicNumber(cacheName);
+ this.atomicnumber = hazelcastInstance.getAtomicLong(cacheName);
}
public void process(Exchange exchange) throws Exception {
http://git-wip-us.apache.org/repos/asf/camel/blob/50704596/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java
index 9b2e125..9ab4fd1 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/component/hazelcast/seda/HazelcastSedaConsumer.java
@@ -20,7 +20,8 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
-import com.hazelcast.core.Transaction;
+import com.hazelcast.transaction.TransactionContext;
+
import org.apache.camel.AsyncCallback;
import org.apache.camel.AsyncProcessor;
import org.apache.camel.Consumer;
@@ -75,14 +76,14 @@ public class HazelcastSedaConsumer extends DefaultConsumer implements Runnable {
while (queue != null && isRunAllowed()) {
final Exchange exchange = this.getEndpoint().createExchange();
- Transaction transaction = null;
+ TransactionContext transactionCtx = null;
if (endpoint.getConfiguration().isTransacted()) {
// Get and begin transaction if exist
- transaction = endpoint.getHazelcastInstance().getTransaction();
+ transactionCtx = endpoint.getHazelcastInstance().newTransactionContext();
- if (transaction != null && transaction.getStatus() == Transaction.TXN_STATUS_NO_TXN) {
- log.trace("Begin transaction: {}", transaction);
- transaction.begin();
+ if (transactionCtx != null) {
+ log.trace("Begin transaction: {}", transactionCtx.getTxnId());
+ transactionCtx.beginTransaction();
}
}
try {
@@ -104,8 +105,8 @@ public class HazelcastSedaConsumer extends DefaultConsumer implements Runnable {
if (exchange.getException() != null) {
// Rollback
- if (transaction != null) {
- transaction.rollback();
+ if (transactionCtx != null) {
+ transactionCtx.rollbackTransaction();
}
getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
}
@@ -113,16 +114,16 @@ public class HazelcastSedaConsumer extends DefaultConsumer implements Runnable {
} catch (Exception e) {
LOG.error("Hzlq Exception caught: " + e, e);
// Rollback
- if (transaction != null) {
- log.trace("Rollback transaction: {}", transaction);
- transaction.rollback();
+ if (transactionCtx != null) {
+ log.trace("Rollback transaction: {}", transactionCtx.getTxnId());
+ transactionCtx.rollbackTransaction();
}
}
}
// It's OK, I commit
- if (exchange.getException() == null && transaction != null && transaction.getStatus() == Transaction.TXN_STATUS_ACTIVE) {
- log.trace("Commit transaction: {}", transaction);
- transaction.commit();
+ if (exchange.getException() == null && transactionCtx != null) {
+ log.trace("Commit transaction: {}", transactionCtx.getTxnId());
+ transactionCtx.commitTransaction();
}
} catch (InterruptedException e) {
if (LOG.isDebugEnabled()) {
@@ -131,9 +132,9 @@ public class HazelcastSedaConsumer extends DefaultConsumer implements Runnable {
continue;
} catch (Throwable e) {
// Rollback
- if (transaction != null) {
- log.trace("Rollback transaction: {}", transaction);
- transaction.rollback();
+ if (transactionCtx != null) {
+ log.trace("Rollback transaction: {}", transactionCtx.getTxnId());
+ transactionCtx.rollbackTransaction();
}
getExceptionHandler().handleException("Error processing exchange", exchange, e);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/50704596/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerForSpringTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerForSpringTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerForSpringTest.java
index 1ed9eee..5493be0 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerForSpringTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerForSpringTest.java
@@ -22,6 +22,7 @@ import java.util.Collection;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
+import org.apache.camel.component.hazelcast.testutil.Dummy;
import org.apache.camel.test.spring.CamelSpringTestSupport;
import org.junit.Test;
@@ -107,34 +108,4 @@ public class HazelcastMapProducerForSpringTest extends CamelSpringTestSupport im
assertEquals(1, b2.size());
}
- public class Dummy implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private String foo;
- private int bar;
-
- public Dummy(String foo, int bar) {
- this.foo = foo;
- this.bar = bar;
- }
-
- public String getFoo() {
- return foo;
- }
-
- public void setFoo(String foo) {
- this.foo = foo;
- }
-
- public int getBar() {
- return bar;
- }
-
- public void setBar(int bar) {
- this.bar = bar;
- }
-
- }
-
}
http://git-wip-us.apache.org/repos/asf/camel/blob/50704596/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerTest.java
index 04fc428..8c5ccfe 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/HazelcastMapProducerTest.java
@@ -23,8 +23,8 @@ import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.hazelcast.testutil.Dummy;
import org.apache.camel.test.junit4.CamelTestSupport;
-
import org.junit.Test;
public class HazelcastMapProducerTest extends CamelTestSupport implements Serializable {
@@ -122,34 +122,5 @@ public class HazelcastMapProducerTest extends CamelTestSupport implements Serial
};
}
- public class Dummy implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private String foo;
- private int bar;
-
- public Dummy(String foo, int bar) {
- this.foo = foo;
- this.bar = bar;
- }
-
- public String getFoo() {
- return foo;
- }
-
- public void setFoo(String foo) {
- this.foo = foo;
- }
-
- public int getBar() {
- return bar;
- }
-
- public void setBar(int bar) {
- this.bar = bar;
- }
-
- }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/50704596/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/testutil/Dummy.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/testutil/Dummy.java b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/testutil/Dummy.java
new file mode 100644
index 0000000..48b3e5d
--- /dev/null
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/component/hazelcast/testutil/Dummy.java
@@ -0,0 +1,50 @@
+/**
+ * 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.component.hazelcast.testutil;
+
+import java.io.Serializable;
+
+public class Dummy implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String foo;
+ private int bar;
+
+ public Dummy(String foo, int bar) {
+ this.foo = foo;
+ this.bar = bar;
+ }
+
+ public String getFoo() {
+ return foo;
+ }
+
+ public void setFoo(String foo) {
+ this.foo = foo;
+ }
+
+ public int getBar() {
+ return bar;
+ }
+
+ public void setBar(int bar) {
+ this.bar = bar;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/50704596/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 8d34536..ed938dd 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -171,7 +171,7 @@
<hawtbuf-version>1.9</hawtbuf-version>
<hawtdb-version>1.6</hawtdb-version>
<hawtdispatch-version>1.17</hawtdispatch-version>
- <hazelcast-version>2.6</hazelcast-version>
+ <hazelcast-version>3.0.2</hazelcast-version>
<hbase-version>0.94.10</hbase-version>
<hbase-bundle-version>0.94.6_1</hbase-bundle-version>
<hibernate-validator-version>5.0.1.Final</hibernate-validator-version>