You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/04/16 10:16:27 UTC
[3/4] git commit: CAMEL-7118 Fixed some CS errors
CAMEL-7118 Fixed some CS errors
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e53c66a9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e53c66a9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e53c66a9
Branch: refs/heads/master
Commit: e53c66a9fdeb81ee6081fefc016a12420a01d8e0
Parents: dd9e28a
Author: Willem Jiang <wi...@gmail.com>
Authored: Wed Apr 16 15:37:17 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Wed Apr 16 16:09:33 2014 +0800
----------------------------------------------------------------------
.../HazelcastAggregationRepository.java | 39 ++++++++++++++------
...stAggregationRepositoryCamelTestSupport.java | 26 +++++++++----
...stAggregationRepositoryConstructorsTest.java | 21 +++++++++--
...castAggregationRepositoryOperationsTest.java | 20 +++++++++-
...regationRepositoryRecoverableRoutesTest.java | 38 ++++++++++++-------
...azelcastAggregationRepositoryRoutesTest.java | 21 ++++++++---
.../hazelcast/SumOfIntsAggregationStrategy.java | 22 ++++++++---
7 files changed, 140 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/e53c66a9/components/camel-hazelcast/src/main/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/main/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepository.java b/components/camel-hazelcast/src/main/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepository.java
index 3b493ca..66ba725 100644
--- a/components/camel-hazelcast/src/main/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepository.java
+++ b/components/camel-hazelcast/src/main/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepository.java
@@ -1,5 +1,25 @@
+/**
+ * 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.processor.aggregate.hazelcast;
+import java.util.Collections;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.Lock;
import com.hazelcast.config.Config;
import com.hazelcast.config.XmlConfigBuilder;
@@ -9,6 +29,7 @@ import com.hazelcast.core.IMap;
import com.hazelcast.core.TransactionalMap;
import com.hazelcast.transaction.TransactionContext;
import com.hazelcast.transaction.TransactionOptions;
+
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.impl.DefaultExchange;
@@ -16,12 +37,6 @@ import org.apache.camel.impl.DefaultExchangeHolder;
import org.apache.camel.spi.OptimisticLockingAggregationRepository;
import org.apache.camel.spi.RecoverableAggregationRepository;
import org.apache.camel.support.ServiceSupport;
-
-import java.util.Collections;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Lock;
-
import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -41,16 +56,17 @@ import org.slf4j.LoggerFactory;
public final class HazelcastAggregationRepository extends ServiceSupport
implements RecoverableAggregationRepository,
OptimisticLockingAggregationRepository {
+ private static final Logger LOG = LoggerFactory.getLogger(HazelcastAggregationRepository.class.getName());
+ private static final String COMPLETED_SUFFIX = "-completed";
+
private boolean optimistic;
private boolean useLocalHzInstance;
private boolean useRecovery = true;
private IMap<String, DefaultExchangeHolder> cache;
private IMap<String, DefaultExchangeHolder> persistedCache;
- private static final Logger LOG = LoggerFactory.getLogger(HazelcastAggregationRepository.class.getName()) ;
private HazelcastInstance hzInstance;
private String mapName;
private String persistenceMapName;
- private static final String COMPLETED_SUFFIX = "-completed";
private String deadLetterChannel;
private long recoveryInterval = 5000;
private int maximumRedeliveries = 3;
@@ -187,7 +203,7 @@ public final class HazelcastAggregationRepository extends ServiceSupport
@Override
public Exchange add(CamelContext camelContext, String key, Exchange exchange) {
- if (optimistic){
+ if (optimistic) {
throw new UnsupportedOperationException();
}
LOG.trace("Adding an Exchange with ID {} for key {} in a thread-safe manner.", exchange.getExchangeId(), key);
@@ -208,10 +224,9 @@ public final class HazelcastAggregationRepository extends ServiceSupport
if (useRecovery) {
LOG.trace("Scanning for exchanges to recover in {} context", camelContext.getName());
Set<String> scanned = Collections.unmodifiableSet(persistedCache.keySet());
- LOG.trace("Found {} keys for exchanges to recover in {} context", scanned.size(),camelContext.getName());
+ LOG.trace("Found {} keys for exchanges to recover in {} context", scanned.size(), camelContext.getName());
return scanned;
- }
- else {
+ } else {
LOG.warn("What for to run recovery scans in {} context while repository {} is running in non-recoverable aggregation repository mode?!",
camelContext.getName(), mapName);
return Collections.emptySet();
http://git-wip-us.apache.org/repos/asf/camel/blob/e53c66a9/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryCamelTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryCamelTestSupport.java b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryCamelTestSupport.java
index 166c8a0..491ffef 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryCamelTestSupport.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryCamelTestSupport.java
@@ -1,3 +1,19 @@
+/**
+ * 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.processor.aggregate.hazelcast;
import com.hazelcast.core.Hazelcast;
@@ -6,14 +22,10 @@ import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-/**
- * @author Alexander Lomov
- * Date: 04.01.14
- * Time: 3:00
- */
+
public class HazelcastAggregationRepositoryCamelTestSupport extends CamelTestSupport {
- private static HazelcastInstance hzOne = null;
- private static HazelcastInstance hzTwo = null;
+ private static HazelcastInstance hzOne;
+ private static HazelcastInstance hzTwo;
protected static void doInitializeHazelcastInstances() {
hzOne = Hazelcast.newHazelcastInstance();
http://git-wip-us.apache.org/repos/asf/camel/blob/e53c66a9/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryConstructorsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryConstructorsTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryConstructorsTest.java
index 5258129..788e8b4 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryConstructorsTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryConstructorsTest.java
@@ -1,3 +1,19 @@
+/**
+ * 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.processor.aggregate.hazelcast;
import com.hazelcast.core.HazelcastInstance;
@@ -50,15 +66,14 @@ public class HazelcastAggregationRepositoryConstructorsTest extends CamelTestSup
@Test
public void locallyInitializedHazelcastInstanceAdd() throws Exception {
- HazelcastAggregationRepository repo = new HazelcastAggregationRepository("hzRepoMap");
+ HazelcastAggregationRepository repo = new HazelcastAggregationRepository("hzRepoMap");
try {
repo.doStart();
Exchange ex = new DefaultExchange(context());
repo.add(context(), "somedefaultkey", ex);
//} catch (Throwable e) {
//fail(e.getMessage());
- }
- finally {
+ } finally {
repo.doStop();
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/e53c66a9/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryOperationsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryOperationsTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryOperationsTest.java
index fea8176..59d38bf 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryOperationsTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryOperationsTest.java
@@ -1,10 +1,26 @@
+/**
+ * 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.processor.aggregate.hazelcast;
+import java.util.Set;
+
import org.apache.camel.Exchange;
import org.junit.Test;
-import java.util.Set;
-
public class HazelcastAggregationRepositoryOperationsTest extends HazelcastAggregationRepositoryCamelTestSupport {
http://git-wip-us.apache.org/repos/asf/camel/blob/e53c66a9/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryRecoverableRoutesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryRecoverableRoutesTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryRecoverableRoutesTest.java
index cea5903..9f29dd3 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryRecoverableRoutesTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryRecoverableRoutesTest.java
@@ -1,3 +1,19 @@
+/**
+ * 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.processor.aggregate.hazelcast;
import org.apache.camel.EndpointInject;
@@ -7,11 +23,6 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Test;
-/**
- * @author Alexander Lomov
- * Date: 04.01.14
- * Time: 4:37
- */
public class HazelcastAggregationRepositoryRecoverableRoutesTest extends HazelcastAggregationRepositoryCamelTestSupport {
@@ -52,18 +63,18 @@ public class HazelcastAggregationRepositoryRecoverableRoutesTest extends Hazelca
.handled(true)
.useOriginalMessage()
.to(MOCK_GOTCHA)
- .end();
+ .end();
interceptSendToEndpoint(MOCK_FAILURE)
.throwException(new EverythingIsLostException("The field is lost... everything is lost"))
- .end();
+ .end();
from(DIRECT_ONE)
.aggregate(header(correlator))
.aggregationRepository(repoOne)
.aggregationStrategy(new SumOfIntsAggregationStrategy())
.completionSize(completionSize)
- .to(MOCK_FAILURE);
+ .to(MOCK_FAILURE);
}
};
@@ -77,18 +88,18 @@ public class HazelcastAggregationRepositoryRecoverableRoutesTest extends Hazelca
.handled(true)
.useOriginalMessage()
.to(MOCK_GOTCHA)
- .end();
+ .end();
interceptSendToEndpoint(MOCK_FAILURE)
.throwException(new EverythingIsLostException("The field is lost... everything is lost"))
- .end();
+ .end();
from(DIRECT_TWO)
.aggregate(header(correlator))
.aggregationRepository(repoTwo)
.aggregationStrategy(new SumOfIntsAggregationStrategy())
.completionSize(completionSize)
- .to(MOCK_FAILURE);
+ .to(MOCK_FAILURE);
}
};
@@ -109,8 +120,9 @@ public class HazelcastAggregationRepositoryRecoverableRoutesTest extends Hazelca
mockFailure.assertIsSatisfied();
}
- @SuppressWarnings("unused")
- private static class EverythingIsLostException extends Exception {
+ private static final class EverythingIsLostException extends Exception {
+ private static final long serialVersionUID = 1L;
+
private EverythingIsLostException() {
}
http://git-wip-us.apache.org/repos/asf/camel/blob/e53c66a9/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryRoutesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryRoutesTest.java b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryRoutesTest.java
index 2b16a5d..8becc17 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryRoutesTest.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/HazelcastAggregationRepositoryRoutesTest.java
@@ -1,3 +1,19 @@
+/**
+ * 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.processor.aggregate.hazelcast;
import org.apache.camel.EndpointInject;
@@ -7,11 +23,6 @@ import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Test;
-/**
- * @author Alexander Lomov
- * Date: 04.01.14
- * Time: 2:40
- */
public class HazelcastAggregationRepositoryRoutesTest extends HazelcastAggregationRepositoryCamelTestSupport {
http://git-wip-us.apache.org/repos/asf/camel/blob/e53c66a9/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/SumOfIntsAggregationStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/SumOfIntsAggregationStrategy.java b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/SumOfIntsAggregationStrategy.java
index bf88b63..cbbe554 100644
--- a/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/SumOfIntsAggregationStrategy.java
+++ b/components/camel-hazelcast/src/test/java/org/apache/camel/processor/aggregate/hazelcast/SumOfIntsAggregationStrategy.java
@@ -1,13 +1,25 @@
+/**
+ * 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.processor.aggregate.hazelcast;
import org.apache.camel.Exchange;
import org.apache.camel.processor.aggregate.AggregationStrategy;
-/**
-* @author Alexander Lomov
-* Date: 04.01.14
-* Time: 13:25
-*/
+
class SumOfIntsAggregationStrategy implements AggregationStrategy {
@Override
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {