Fixed CS.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/51e251c7 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/51e251c7 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/51e251c7 Branch: refs/heads/master Commit: 51e251c700dfd1bdb0f443d9e42d1281890338dd Parents: ceaef10 Author: Candle <[email protected]> Authored: Tue Dec 15 18:22:20 2015 +0000 Committer: Claus Ibsen <[email protected]> Committed: Wed Dec 16 14:19:12 2015 +0100 ---------------------------------------------------------------------- .../aws/ddbstream/DdbStreamConsumer.java | 26 ++++++++------------ .../aws/ddbstream/DdbStreamEndpoint.java | 2 -- .../component/aws/ddbstream/ShardList.java | 23 ++++++++++++++--- .../component/aws/ddbstream/ShardListTest.java | 22 +++++++++++++++-- 4 files changed, 50 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/51e251c7/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamConsumer.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamConsumer.java index d4c9ac7..0a6a83c 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamConsumer.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamConsumer.java @@ -16,6 +16,10 @@ */ package org.apache.camel.component.aws.ddbstream; +import java.util.ArrayDeque; +import java.util.List; +import java.util.Queue; + import com.amazonaws.services.dynamodbv2.AmazonDynamoDBStreams; import com.amazonaws.services.dynamodbv2.model.DescribeStreamRequest; import com.amazonaws.services.dynamodbv2.model.DescribeStreamResult; @@ -27,9 +31,6 @@ import com.amazonaws.services.dynamodbv2.model.ListStreamsRequest; import com.amazonaws.services.dynamodbv2.model.ListStreamsResult; import com.amazonaws.services.dynamodbv2.model.Record; import com.amazonaws.services.dynamodbv2.model.Shard; -import java.util.ArrayDeque; -import java.util.List; -import java.util.Queue; import org.apache.camel.AsyncCallback; import org.apache.camel.Exchange; import org.apache.camel.Processor; @@ -42,23 +43,19 @@ import org.slf4j.LoggerFactory; public class DdbStreamConsumer extends ScheduledBatchPollingConsumer { private static final Logger LOG = LoggerFactory.getLogger(DdbStreamConsumer.class); - private String currentShardIterator = null; + private String currentShardIterator; private Shard currentShard; - private ShardList shardList = new ShardList(); + private final ShardList shardList = new ShardList(); public DdbStreamConsumer(DdbStreamEndpoint endpoint, Processor processor) { super(endpoint, processor); } - /* - * Returns the number of messages polled. - */ @Override protected int poll() throws Exception { GetRecordsRequest req = new GetRecordsRequest() .withShardIterator(getShardItertor()) - .withLimit(getEndpoint().getMaxResultsPerRequest()) - ; + .withLimit(getEndpoint().getMaxResultsPerRequest()); GetRecordsResult result = getClient().getRecords(req); Queue<Exchange> exchanges = createExchanges(result.getRecords()); @@ -100,13 +97,11 @@ public class DdbStreamConsumer extends ScheduledBatchPollingConsumer { // either return a cached one or get a new one via a GetShardIterator request. if (currentShardIterator == null) { ListStreamsRequest req0 = new ListStreamsRequest() - .withTableName(getEndpoint().getTableName()) - ; + .withTableName(getEndpoint().getTableName()); ListStreamsResult res0 = getClient().listStreams(req0); final String streamArn = res0.getStreams().get(0).getStreamArn(); // XXX assumes there is only one stream DescribeStreamRequest req1 = new DescribeStreamRequest() - .withStreamArn(streamArn) - ; + .withStreamArn(streamArn); DescribeStreamResult res1 = getClient().describeStream(req1); shardList.addAll(res1.getStreamDescription().getShards()); @@ -122,8 +117,7 @@ public class DdbStreamConsumer extends ScheduledBatchPollingConsumer { GetShardIteratorRequest req = new GetShardIteratorRequest() .withStreamArn(streamArn) .withShardId(currentShard.getShardId()) - .withShardIteratorType(getEndpoint().getIteratorType()) - ; + .withShardIteratorType(getEndpoint().getIteratorType()); GetShardIteratorResult result = getClient().getShardIterator(req); currentShardIterator = result.getShardIterator(); } http://git-wip-us.apache.org/repos/asf/camel/blob/51e251c7/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamEndpoint.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamEndpoint.java index 35812ce..dfcc6cc 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamEndpoint.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/DdbStreamEndpoint.java @@ -73,7 +73,6 @@ public class DdbStreamEndpoint extends ScheduledPollEndpoint { @Override public boolean isSingleton() { - // probably right. return true; } @@ -81,7 +80,6 @@ public class DdbStreamEndpoint extends ScheduledPollEndpoint { return amazonDynamoDbStreamsClient; } - // required for injection. public AmazonDynamoDBStreams getAmazonDynamoDBStreamsClient() { return amazonDynamoDbStreamsClient; } http://git-wip-us.apache.org/repos/asf/camel/blob/51e251c7/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/ShardList.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/ShardList.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/ShardList.java index a85e703..6e804f5 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/ShardList.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/ddbstream/ShardList.java @@ -1,14 +1,31 @@ +/** + * 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.aws.ddbstream; -import com.amazonaws.services.dynamodbv2.model.Shard; import java.util.Collection; import java.util.HashMap; import java.util.Map; + +import com.amazonaws.services.dynamodbv2.model.Shard; import org.slf4j.Logger; import org.slf4j.LoggerFactory; class ShardList { - private final Logger LOG = LoggerFactory.getLogger(ShardList.class); + private final Logger log = LoggerFactory.getLogger(ShardList.class); private final Map<String, Shard> shards = new HashMap<>(); @@ -58,7 +75,7 @@ class ShardList { current = s.getParentShardId(); } } - LOG.trace("removed {} shards from the store, new size is {}", removedShards, shards.size()); + log.trace("removed {} shards from the store, new size is {}", removedShards, shards.size()); } @Override http://git-wip-us.apache.org/repos/asf/camel/blob/51e251c7/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddbstream/ShardListTest.java ---------------------------------------------------------------------- diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddbstream/ShardListTest.java b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddbstream/ShardListTest.java index 773f4a0..60f3d46 100644 --- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddbstream/ShardListTest.java +++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddbstream/ShardListTest.java @@ -1,11 +1,29 @@ +/** + * 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.aws.ddbstream; -import com.amazonaws.services.dynamodbv2.model.Shard; + import java.util.ArrayList; import java.util.List; +import com.amazonaws.services.dynamodbv2.model.Shard; + +import org.junit.Test; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import org.junit.Test; public class ShardListTest {
