http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/ObjectMapperCqlStatementMapper.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/ObjectMapperCqlStatementMapper.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/ObjectMapperCqlStatementMapper.java index fa9a348..4f5a021 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/ObjectMapperCqlStatementMapper.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/ObjectMapperCqlStatementMapper.java @@ -1,20 +1,13 @@ /** - * 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 + * 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. + * 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.storm.cassandra.query.impl; @@ -54,7 +47,8 @@ public class ObjectMapperCqlStatementMapper implements CQLStatementTupleMapper { private final Collection<TypeCodec<?>> codecs; private final Collection<Class<?>> udtClasses; - public ObjectMapperCqlStatementMapper(String operationField, String valueField, String timestampField, String ttlField, String consistencyLevelField, Collection<TypeCodec<?>> codecs, Collection<Class<?>> udtClasses) { + public ObjectMapperCqlStatementMapper(String operationField, String valueField, String timestampField, String ttlField, + String consistencyLevelField, Collection<TypeCodec<?>> codecs, Collection<Class<?>> udtClasses) { Preconditions.checkNotNull(operationField, "Operation field must not be null"); Preconditions.checkNotNull(valueField, "Value field should not be null"); this.operationField = operationField; @@ -68,14 +62,15 @@ public class ObjectMapperCqlStatementMapper implements CQLStatementTupleMapper { @Override public List<Statement> map(Map<String, Object> map, Session session, ITuple tuple) { - final ObjectMapperOperation operation = (ObjectMapperOperation)tuple.getValueByField(operationField); + final ObjectMapperOperation operation = (ObjectMapperOperation) tuple.getValueByField(operationField); Preconditions.checkNotNull(operation, "Operation must not be null"); final Object value = tuple.getValueByField(valueField); final Object timestampObject = timestampField != null ? tuple.getValueByField(timestampField) : null; final Object ttlObject = ttlField != null ? tuple.getValueByField(ttlField) : null; - final ConsistencyLevel consistencyLevel = consistencyLevelField != null ? (ConsistencyLevel) tuple.getValueByField(consistencyLevelField) : null; + final ConsistencyLevel consistencyLevel = + consistencyLevelField != null ? (ConsistencyLevel) tuple.getValueByField(consistencyLevelField) : null; final Class<?> valueClass = value.getClass();
http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/PreparedStatementBinder.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/PreparedStatementBinder.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/PreparedStatementBinder.java index 677ef56..5a4d39e 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/PreparedStatementBinder.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/PreparedStatementBinder.java @@ -1,41 +1,23 @@ /** - * 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 + * 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. + * 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.storm.cassandra.query.impl; import com.datastax.driver.core.BoundStatement; import com.datastax.driver.core.CodecRegistry; import com.datastax.driver.core.PreparedStatement; -import com.datastax.driver.core.TupleValue; -import com.datastax.driver.core.TypeTokens; -import com.datastax.driver.core.UDTValue; -import org.apache.storm.cassandra.query.Column; - import java.io.Serializable; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.net.InetAddress; -import java.nio.ByteBuffer; -import java.util.Date; import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import org.apache.storm.cassandra.query.Column; /** * @@ -66,15 +48,15 @@ public interface PreparedStatementBinder extends Serializable { Object[] values = Column.getVals(columns); BoundStatement boundStatement = statement.bind(); - for(Column col : columns) { + for (Column col : columns) { // For native protocol V3 or below, all variables must be bound. // With native protocol V4 or above, variables can be left unset, // in which case they will be ignored server side (no tombstones will be generated). - if(col.isNull()) { + if (col.isNull()) { boundStatement.setToNull(col.getColumnName()); } else { boundStatement.set(col.getColumnName(), col.getVal(), - CodecRegistry.DEFAULT_INSTANCE.codecFor(col.getVal())); + CodecRegistry.DEFAULT_INSTANCE.codecFor(col.getVal())); } } return statement.bind(values); http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/RoutingKeyGenerator.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/RoutingKeyGenerator.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/RoutingKeyGenerator.java index 9c84506..948a21f 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/RoutingKeyGenerator.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/RoutingKeyGenerator.java @@ -1,32 +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 + * 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. + * 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.storm.cassandra.query.impl; import com.datastax.driver.core.CodecRegistry; import com.datastax.driver.core.ProtocolVersion; import com.google.common.base.Preconditions; -import org.apache.storm.tuple.ITuple; - import java.io.Serializable; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; +import org.apache.storm.tuple.ITuple; public class RoutingKeyGenerator implements Serializable { @@ -43,7 +36,7 @@ public class RoutingKeyGenerator implements Serializable { public List<ByteBuffer> getRoutingKeys(ITuple tuple) { List<ByteBuffer> keys = new ArrayList<>(routingKeys.size()); - for(String s : routingKeys) { + for (String s : routingKeys) { Object value = tuple.getValueByField(s); ByteBuffer serialized = CodecRegistry.DEFAULT_INSTANCE.codecFor(value).serialize(value, ProtocolVersion.NEWEST_SUPPORTED); keys.add(serialized); http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/SimpleCQLStatementMapper.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/SimpleCQLStatementMapper.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/SimpleCQLStatementMapper.java index 532bf6d..17a9049 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/SimpleCQLStatementMapper.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/impl/SimpleCQLStatementMapper.java @@ -1,36 +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 + * 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. + * 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.storm.cassandra.query.impl; -import org.apache.storm.tuple.ITuple; import com.datastax.driver.core.Session; import com.datastax.driver.core.SimpleStatement; import com.datastax.driver.core.Statement; import com.google.common.base.Preconditions; -import org.apache.storm.cassandra.query.CQLStatementTupleMapper; -import org.apache.storm.cassandra.query.Column; -import org.apache.storm.cassandra.query.CqlMapper; - import java.nio.ByteBuffer; import java.util.Arrays; import java.util.List; import java.util.Map; +import org.apache.storm.cassandra.query.CQLStatementTupleMapper; +import org.apache.storm.cassandra.query.Column; +import org.apache.storm.cassandra.query.CqlMapper; +import org.apache.storm.tuple.ITuple; /** * @@ -71,12 +64,13 @@ public class SimpleCQLStatementMapper implements CQLStatementTupleMapper { List<Column> columns = mapper.map(tuple); SimpleStatement statement = new SimpleStatement(queryString, Column.getVals(columns)); - if(hasRoutingKeys()) { + if (hasRoutingKeys()) { List<ByteBuffer> keys = rkGenerator.getRoutingKeys(tuple); - if( keys.size() == 1) + if (keys.size() == 1) { statement.setRoutingKey(keys.get(0)); - else + } else { statement.setRoutingKey(keys.toArray(new ByteBuffer[keys.size()])); + } } return Arrays.asList((Statement) statement); http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/selector/FieldSelector.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/selector/FieldSelector.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/selector/FieldSelector.java index 3349bc3..dd9222a 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/selector/FieldSelector.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/query/selector/FieldSelector.java @@ -1,28 +1,21 @@ /** - * 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 + * 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. + * 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.storm.cassandra.query.selector; -import org.apache.storm.tuple.ITuple; import com.datastax.driver.core.utils.UUIDs; -import org.apache.storm.cassandra.query.Column; - import java.io.Serializable; +import org.apache.storm.cassandra.query.Column; +import org.apache.storm.tuple.ITuple; public class FieldSelector implements Serializable { http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraBackingMap.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraBackingMap.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraBackingMap.java index 029710e..61f9001 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraBackingMap.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraBackingMap.java @@ -1,21 +1,15 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; import com.datastax.driver.core.HostDistance; @@ -23,6 +17,11 @@ import com.datastax.driver.core.PoolingOptions; import com.datastax.driver.core.Session; import com.datastax.driver.core.Statement; import com.google.common.base.Preconditions; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Semaphore; import org.apache.storm.cassandra.client.SimpleClient; import org.apache.storm.cassandra.client.SimpleClientProvider; import org.apache.storm.cassandra.query.AyncCQLResultSetValuesMapper; @@ -41,12 +40,6 @@ import org.apache.storm.tuple.Values; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Semaphore; - /** * An IBackingState implementation for Cassandra. * @@ -99,8 +92,8 @@ public class CassandraBackingMap<T> implements IBackingMap<T> { if (options.maxParallelism == null || options.maxParallelism <= 0) { PoolingOptions po = session.getCluster().getConfiguration().getPoolingOptions(); Integer maxRequestsPerHost = Math.min( - po.getMaxConnectionsPerHost(HostDistance.LOCAL) * po.getMaxRequestsPerConnection(HostDistance.LOCAL), - po.getMaxConnectionsPerHost(HostDistance.REMOTE) * po.getMaxRequestsPerConnection(HostDistance.REMOTE) + po.getMaxConnectionsPerHost(HostDistance.LOCAL) * po.getMaxRequestsPerConnection(HostDistance.LOCAL), + po.getMaxConnectionsPerHost(HostDistance.REMOTE) * po.getMaxRequestsPerConnection(HostDistance.REMOTE) ); options.maxParallelism = maxRequestsPerHost / 2; LOG.info("Parallelism default set to {}", options.maxParallelism); @@ -127,7 +120,7 @@ public class CassandraBackingMap<T> implements IBackingMap<T> { } List<List<Values>> results = getResultMapper - .map(session, selects, keyTuples); + .map(session, selects, keyTuples); List<T> states = new ArrayList<>(); for (List<Values> values : results) { @@ -228,12 +221,12 @@ public class CassandraBackingMap<T> implements IBackingMap<T> { @Override public String toString() { return String.format("%s: [keys: %s, StateMapper: %s, getMapper: %s, putMapper: %s, maxParallelism: %d", - this.getClass().getSimpleName(), - keyFields, - stateMapper, - getMapper, - putMapper, - maxParallelism + this.getClass().getSimpleName(), + keyFields, + stateMapper, + getMapper, + putMapper, + maxParallelism ); } } http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraMapStateFactory.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraMapStateFactory.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraMapStateFactory.java index 75f0d4f..5b82a6b 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraMapStateFactory.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraMapStateFactory.java @@ -1,23 +1,18 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; +import java.util.Map; import org.apache.storm.task.IMetricsContext; import org.apache.storm.trident.state.OpaqueValue; import org.apache.storm.trident.state.State; @@ -31,8 +26,6 @@ import org.apache.storm.trident.state.map.NonTransactionalMap; import org.apache.storm.trident.state.map.OpaqueMap; import org.apache.storm.trident.state.map.TransactionalMap; -import java.util.Map; - /** * A StateFactory implementation that creates a MapState backed by CassandraBackingMap. * @@ -78,8 +71,8 @@ public class CassandraMapStateFactory implements StateFactory { cassandraBackingMap.prepare(); IBackingMap backingMap = cacheSize > 0 - ? new CachedMap<>(cassandraBackingMap, cacheSize) - : cassandraBackingMap; + ? new CachedMap<>(cassandraBackingMap, cacheSize) + : cassandraBackingMap; MapState<?> mapState; @@ -89,7 +82,7 @@ public class CassandraMapStateFactory implements StateFactory { break; case TRANSACTIONAL: - mapState = TransactionalMap.build((IBackingMap<TransactionalValue>)backingMap); + mapState = TransactionalMap.build((IBackingMap<TransactionalValue>) backingMap); break; case NON_TRANSACTIONAL: http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraQuery.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraQuery.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraQuery.java index ca4416d..4fafa61 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraQuery.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraQuery.java @@ -1,29 +1,22 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; -import org.apache.storm.tuple.Values; +import java.util.List; import org.apache.storm.trident.operation.TridentCollector; import org.apache.storm.trident.state.BaseQueryFunction; import org.apache.storm.trident.tuple.TridentTuple; - -import java.util.List; +import org.apache.storm.tuple.Values; /** * http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraState.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraState.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraState.java index 7fa138f..9ecae36 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraState.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraState.java @@ -1,43 +1,36 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; -import org.apache.storm.topology.FailedException; -import org.apache.storm.tuple.Values; import com.datastax.driver.core.BatchStatement; import com.datastax.driver.core.Session; import com.datastax.driver.core.Statement; import com.google.common.base.Preconditions; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import org.apache.storm.cassandra.client.SimpleClient; import org.apache.storm.cassandra.client.SimpleClientProvider; import org.apache.storm.cassandra.query.CQLResultSetValuesMapper; import org.apache.storm.cassandra.query.CQLStatementTupleMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.apache.storm.topology.FailedException; import org.apache.storm.trident.operation.TridentCollector; import org.apache.storm.trident.state.State; import org.apache.storm.trident.tuple.TridentTuple; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import org.apache.storm.tuple.Values; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -57,33 +50,6 @@ public class CassandraState implements State { this.options = options; } - public static final class Options implements Serializable { - private final SimpleClientProvider clientProvider; - private CQLStatementTupleMapper cqlStatementTupleMapper; - private CQLResultSetValuesMapper cqlResultSetValuesMapper; - private BatchStatement.Type batchingType; - - public Options(SimpleClientProvider clientProvider) { - this.clientProvider = clientProvider; - } - - public Options withCQLStatementTupleMapper(CQLStatementTupleMapper cqlStatementTupleMapper) { - this.cqlStatementTupleMapper = cqlStatementTupleMapper; - return this; - } - - public Options withCQLResultSetValuesMapper(CQLResultSetValuesMapper cqlResultSetValuesMapper) { - this.cqlResultSetValuesMapper = cqlResultSetValuesMapper; - return this; - } - - public Options withBatching(BatchStatement.Type batchingType) { - this.batchingType = batchingType; - return this; - } - - } - @Override public void beginCommit(Long txid) { LOG.debug("beginCommit is no operation"); @@ -155,4 +121,31 @@ public class CassandraState implements State { return batchRetrieveResult; } + public static final class Options implements Serializable { + private final SimpleClientProvider clientProvider; + private CQLStatementTupleMapper cqlStatementTupleMapper; + private CQLResultSetValuesMapper cqlResultSetValuesMapper; + private BatchStatement.Type batchingType; + + public Options(SimpleClientProvider clientProvider) { + this.clientProvider = clientProvider; + } + + public Options withCQLStatementTupleMapper(CQLStatementTupleMapper cqlStatementTupleMapper) { + this.cqlStatementTupleMapper = cqlStatementTupleMapper; + return this; + } + + public Options withCQLResultSetValuesMapper(CQLResultSetValuesMapper cqlResultSetValuesMapper) { + this.cqlResultSetValuesMapper = cqlResultSetValuesMapper; + return this; + } + + public Options withBatching(BatchStatement.Type batchingType) { + this.batchingType = batchingType; + return this; + } + + } + } http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraStateFactory.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraStateFactory.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraStateFactory.java index a7f9e9c..fcdbb1c 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraStateFactory.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraStateFactory.java @@ -1,32 +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 + * 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. + * 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.storm.cassandra.trident.state; -import org.apache.storm.task.IMetricsContext; +import java.util.Map; import org.apache.storm.cassandra.CassandraContext; import org.apache.storm.cassandra.query.CQLResultSetValuesMapper; import org.apache.storm.cassandra.query.CQLStatementTupleMapper; +import org.apache.storm.task.IMetricsContext; import org.apache.storm.trident.state.State; import org.apache.storm.trident.state.StateFactory; -import java.util.Map; - /** * */ @@ -38,7 +31,8 @@ public class CassandraStateFactory implements StateFactory { } public CassandraStateFactory(CQLStatementTupleMapper cqlStatementTupleMapper, CQLResultSetValuesMapper cqlResultSetValuesMapper) { - this(new CassandraState.Options(new CassandraContext()).withCQLStatementTupleMapper(cqlStatementTupleMapper).withCQLResultSetValuesMapper(cqlResultSetValuesMapper)); + this(new CassandraState.Options(new CassandraContext()).withCQLStatementTupleMapper(cqlStatementTupleMapper) + .withCQLResultSetValuesMapper(cqlResultSetValuesMapper)); } @Override http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraStateUpdater.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraStateUpdater.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraStateUpdater.java index ad185b9..e4bb380 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraStateUpdater.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/CassandraStateUpdater.java @@ -1,29 +1,22 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; +import java.util.List; import org.apache.storm.trident.operation.TridentCollector; import org.apache.storm.trident.state.BaseStateUpdater; import org.apache.storm.trident.tuple.TridentTuple; -import java.util.List; - /** * */ http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/MapStateFactoryBuilder.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/MapStateFactoryBuilder.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/MapStateFactoryBuilder.java index e36b7ef..ed8ab71 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/MapStateFactoryBuilder.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/MapStateFactoryBuilder.java @@ -1,25 +1,24 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; import com.datastax.driver.core.querybuilder.Insert; import com.datastax.driver.core.querybuilder.Select; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; import org.apache.storm.cassandra.CassandraContext; import org.apache.storm.cassandra.query.CQLStatementTupleMapper; import org.apache.storm.trident.state.JSONNonTransactionalSerializer; @@ -34,12 +33,10 @@ import org.apache.storm.tuple.Fields; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import static com.datastax.driver.core.querybuilder.QueryBuilder.*; +import static com.datastax.driver.core.querybuilder.QueryBuilder.bindMarker; +import static com.datastax.driver.core.querybuilder.QueryBuilder.eq; +import static com.datastax.driver.core.querybuilder.QueryBuilder.insertInto; +import static com.datastax.driver.core.querybuilder.QueryBuilder.select; import static org.apache.storm.cassandra.DynamicStatementBuilder.all; import static org.apache.storm.cassandra.DynamicStatementBuilder.boundQuery; @@ -85,20 +82,20 @@ public class MapStateFactoryBuilder<T> { public static <U> MapStateFactoryBuilder<OpaqueValue<U>> opaque(Map<String, Object> cassandraConf) { return new MapStateFactoryBuilder<OpaqueValue<U>>() - .withStateType(StateType.OPAQUE) - .withCassandraConfig(cassandraConf); + .withStateType(StateType.OPAQUE) + .withCassandraConfig(cassandraConf); } public static <U> MapStateFactoryBuilder<TransactionalValue<U>> transactional(Map<String, Object> cassandraConf) { return new MapStateFactoryBuilder<TransactionalValue<U>>() - .withStateType(StateType.TRANSACTIONAL) - .withCassandraConfig(cassandraConf); + .withStateType(StateType.TRANSACTIONAL) + .withCassandraConfig(cassandraConf); } public static <U> MapStateFactoryBuilder<U> nontransactional(Map<String, Object> cassandraConf) { return new MapStateFactoryBuilder<U>() - .withStateType(StateType.NON_TRANSACTIONAL) - .withCassandraConfig(cassandraConf); + .withStateType(StateType.NON_TRANSACTIONAL) + .withCassandraConfig(cassandraConf); } public MapStateFactoryBuilder<T> withTable(String keyspace, String table) { @@ -167,7 +164,7 @@ public class MapStateFactoryBuilder<T> { Objects.requireNonNull(stateType, "A state type must be specified."); List<String> stateFields = stateMapper.getStateFields() - .toList(); + .toList(); String[] stateFieldsArray = stateFields.toArray(new String[stateFields.size()]); @@ -177,47 +174,47 @@ public class MapStateFactoryBuilder<T> { // Build get query Select.Where getQuery = select(stateFieldsArray) - .from(keyspace, table) - .where(); + .from(keyspace, table) + .where(); for (String key : keys) { getQuery.and(eq(key, bindMarker())); } CQLStatementTupleMapper get = boundQuery(getQuery.toString()) - .bind(all()) - .build(); + .bind(all()) + .build(); // Build put query Insert putStatement = insertInto(keyspace, table) - .values(allFields, Collections.<Object>nCopies(allFields.size(), bindMarker())); + .values(allFields, Collections.<Object>nCopies(allFields.size(), bindMarker())); CQLStatementTupleMapper put = boundQuery(putStatement.toString()) - .bind(all()) - .build(); + .bind(all()) + .build(); CassandraBackingMap.Options options = new CassandraBackingMap.Options<T>(new CassandraContext()) - .withGetMapper(get) - .withPutMapper(put) - .withStateMapper(stateMapper) - .withKeys(new Fields(keys)) - .withMaxParallelism(maxParallelism); + .withGetMapper(get) + .withPutMapper(put) + .withStateMapper(stateMapper) + .withKeys(new Fields(keys)) + .withMaxParallelism(maxParallelism); logger.debug("Building factory with: \n get: {}\n put: {}\n mapper: {}", - getQuery.toString(), - putStatement.toString(), - stateMapper.toString()); + getQuery.toString(), + putStatement.toString(), + stateMapper.toString()); switch (stateType) { case NON_TRANSACTIONAL: return CassandraMapStateFactory.nonTransactional(options, cassandraConfig) - .withCache(cacheSize); + .withCache(cacheSize); case TRANSACTIONAL: return CassandraMapStateFactory.transactional(options, cassandraConfig) - .withCache(cacheSize); + .withCache(cacheSize); case OPAQUE: return CassandraMapStateFactory.opaque(options, cassandraConfig) - .withCache(cacheSize); + .withCache(cacheSize); } return null; http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/NonTransactionalTupleStateMapper.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/NonTransactionalTupleStateMapper.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/NonTransactionalTupleStateMapper.java index 3a36b07..cdaa2a1 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/NonTransactionalTupleStateMapper.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/NonTransactionalTupleStateMapper.java @@ -1,29 +1,22 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; +import java.util.List; import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.ITuple; import org.apache.storm.tuple.Values; -import java.util.List; - /** * State mapper that maps a tuple to separate state fields. */ http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/OpaqueTupleStateMapper.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/OpaqueTupleStateMapper.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/OpaqueTupleStateMapper.java index 882c9b1..a7e857b 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/OpaqueTupleStateMapper.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/OpaqueTupleStateMapper.java @@ -1,31 +1,24 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; +import java.util.ArrayList; +import java.util.List; import org.apache.storm.trident.state.OpaqueValue; import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.ITuple; import org.apache.storm.tuple.Values; -import java.util.ArrayList; -import java.util.List; - /** * State mapper that maps an opaque tuple to separate state fields. */ @@ -64,8 +57,7 @@ public class OpaqueTupleStateMapper implements StateMapper<OpaqueValue<ITuple>> for (String valueField : tupleFields) { if (tuple.getCurr() != null) { values.add(tuple.getCurr().getValueByField(valueField)); - } - else { + } else { values.add(null); } } @@ -73,8 +65,7 @@ public class OpaqueTupleStateMapper implements StateMapper<OpaqueValue<ITuple>> for (String valueField : tupleFields) { if (tuple.getPrev() != null) { values.add(tuple.getPrev().getValueByField(valueField)); - } - else { + } else { values.add(null); } } http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SerializedStateMapper.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SerializedStateMapper.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SerializedStateMapper.java index b4ec6c8..49b43fd 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SerializedStateMapper.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SerializedStateMapper.java @@ -1,30 +1,23 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; +import java.nio.ByteBuffer; +import java.util.List; import org.apache.storm.trident.state.Serializer; import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.Values; -import java.nio.ByteBuffer; -import java.util.List; - public class SerializedStateMapper<T> implements StateMapper<T> { private final Fields stateFields; @@ -50,12 +43,10 @@ public class SerializedStateMapper<T> implements StateMapper<T> { public T fromValues(List<Values> values) { if (values.size() == 0) { return null; - } - else if (values.size() == 1) { + } else if (values.size() == 1) { ByteBuffer bytes = (ByteBuffer) values.get(0).get(0); return serializer.deserialize(bytes.array()); - } - else { + } else { throw new IllegalArgumentException("Can only convert single values, " + values.size() + " encountered"); } } http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SimpleStateMapper.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SimpleStateMapper.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SimpleStateMapper.java index cc03a09..0bc3191 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SimpleStateMapper.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SimpleStateMapper.java @@ -1,31 +1,24 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; +import java.util.List; import org.apache.storm.trident.state.OpaqueValue; import org.apache.storm.trident.state.StateType; import org.apache.storm.trident.state.TransactionalValue; import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.Values; -import java.util.List; - public class SimpleStateMapper<T> implements StateMapper<T> { private final Fields fields; @@ -77,8 +70,7 @@ public class SimpleStateMapper<T> implements StateMapper<T> { public T fromValues(List<Values> valuesSet) { if (valuesSet == null || valuesSet.size() == 0) { return null; - } - else if (valuesSet.size() == 1) { + } else if (valuesSet.size() == 1) { Values values = valuesSet.get(0); if (values == null) { return null; http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SimpleTuple.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SimpleTuple.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SimpleTuple.java index 6424bc0..7bc066e 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SimpleTuple.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/SimpleTuple.java @@ -1,30 +1,23 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; -import org.apache.storm.tuple.Fields; -import org.apache.storm.tuple.ITuple; +package org.apache.storm.cassandra.trident.state; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.apache.storm.tuple.Fields; +import org.apache.storm.tuple.ITuple; /** * Utility class for passing around ordered key/value data with an immutable key set. @@ -60,18 +53,12 @@ public class SimpleTuple implements ITuple, Serializable { int index = keys.indexOf(key); if (index >= 0) { values.set(index, value); - } - else { + } else { throw new IllegalArgumentException("Field " + key + " does not exist."); } return this; } - public SimpleTuple setValues(List<Object> values) { - this.values = new ArrayList<>(values); - return this; - } - @Override public int size() { return keys.size(); @@ -206,6 +193,11 @@ public class SimpleTuple implements ITuple, Serializable { return Collections.unmodifiableList(values); } + public SimpleTuple setValues(List<Object> values) { + this.values = new ArrayList<>(values); + return this; + } + public List<String> getKeys() { return Collections.unmodifiableList(keys); } http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/StateMapper.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/StateMapper.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/StateMapper.java index ef0c783..257c3ba 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/StateMapper.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/StateMapper.java @@ -1,28 +1,21 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; -import org.apache.storm.tuple.Fields; -import org.apache.storm.tuple.Values; +package org.apache.storm.cassandra.trident.state; import java.io.Serializable; import java.util.List; +import org.apache.storm.tuple.Fields; +import org.apache.storm.tuple.Values; public interface StateMapper<T> extends Serializable { http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TransactionalTupleStateMapper.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TransactionalTupleStateMapper.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TransactionalTupleStateMapper.java index 83332b9..7b3d670 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TransactionalTupleStateMapper.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TransactionalTupleStateMapper.java @@ -1,31 +1,24 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; +import java.util.ArrayList; +import java.util.List; import org.apache.storm.trident.state.TransactionalValue; import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.ITuple; import org.apache.storm.tuple.Values; -import java.util.ArrayList; -import java.util.List; - /** * State mapper that maps a transactional tuple to separate state fields. */ @@ -61,8 +54,7 @@ public class TransactionalTupleStateMapper implements StateMapper<TransactionalV for (String valueField : tupleFields) { if (tuple.getVal() != null) { values.add(tuple.getVal().getValueByField(valueField)); - } - else { + } else { values.add(null); } } http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TridentAyncCQLResultSetValuesMapper.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TridentAyncCQLResultSetValuesMapper.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TridentAyncCQLResultSetValuesMapper.java index 0d03fed..0159eef 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TridentAyncCQLResultSetValuesMapper.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TridentAyncCQLResultSetValuesMapper.java @@ -1,21 +1,15 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; import com.datastax.driver.core.ResultSet; @@ -23,6 +17,9 @@ import com.datastax.driver.core.Row; import com.datastax.driver.core.Session; import com.datastax.driver.core.Statement; import com.google.common.util.concurrent.SettableFuture; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.Semaphore; import org.apache.storm.cassandra.executor.AsyncExecutor; import org.apache.storm.cassandra.executor.AsyncExecutorProvider; import org.apache.storm.cassandra.executor.AsyncResultHandler; @@ -33,10 +30,6 @@ import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.ITuple; import org.apache.storm.tuple.Values; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Semaphore; - /** * A result set mapper implementation which runs requests in parallel and waits for them all to finish. */ @@ -113,5 +106,4 @@ public class TridentAyncCQLResultSetValuesMapper implements AyncCQLResultSetValu } - } http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TridentResultSetValuesMapper.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TridentResultSetValuesMapper.java b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TridentResultSetValuesMapper.java index 69cd6f8..cd34362 100644 --- a/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TridentResultSetValuesMapper.java +++ b/external/storm-cassandra/src/main/java/org/apache/storm/cassandra/trident/state/TridentResultSetValuesMapper.java @@ -1,35 +1,28 @@ /** - * 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 + * 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. + * 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.storm.cassandra.trident.state; -import org.apache.storm.tuple.Fields; -import org.apache.storm.tuple.ITuple; -import org.apache.storm.tuple.Values; import com.datastax.driver.core.ResultSet; import com.datastax.driver.core.Row; import com.datastax.driver.core.Session; import com.datastax.driver.core.Statement; -import org.apache.storm.cassandra.query.CQLResultSetValuesMapper; - import java.util.ArrayList; import java.util.LinkedList; import java.util.List; +import org.apache.storm.cassandra.query.CQLResultSetValuesMapper; +import org.apache.storm.tuple.Fields; +import org.apache.storm.tuple.ITuple; +import org.apache.storm.tuple.Values; /** * http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/test/java/org/apache/storm/cassandra/WeatherSpout.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/test/java/org/apache/storm/cassandra/WeatherSpout.java b/external/storm-cassandra/src/test/java/org/apache/storm/cassandra/WeatherSpout.java index caf19ee..1043130 100644 --- a/external/storm-cassandra/src/test/java/org/apache/storm/cassandra/WeatherSpout.java +++ b/external/storm-cassandra/src/test/java/org/apache/storm/cassandra/WeatherSpout.java @@ -1,23 +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 + * 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. + * 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.storm.cassandra; +import java.util.Map; +import java.util.concurrent.atomic.AtomicLong; import org.apache.storm.spout.SpoutOutputCollector; import org.apache.storm.task.TopologyContext; import org.apache.storm.topology.OutputFieldsDeclarer; @@ -26,9 +22,6 @@ import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.Values; import org.junit.Assert; -import java.util.Map; -import java.util.concurrent.atomic.AtomicLong; - public class WeatherSpout extends BaseRichSpout { private SpoutOutputCollector spoutOutputCollector; http://git-wip-us.apache.org/repos/asf/storm/blob/1a2d131f/external/storm-cassandra/src/test/java/org/apache/storm/cassandra/testtools/EmbeddedCassandraResource.java ---------------------------------------------------------------------- diff --git a/external/storm-cassandra/src/test/java/org/apache/storm/cassandra/testtools/EmbeddedCassandraResource.java b/external/storm-cassandra/src/test/java/org/apache/storm/cassandra/testtools/EmbeddedCassandraResource.java index 0f02bb4..57dd6b9 100644 --- a/external/storm-cassandra/src/test/java/org/apache/storm/cassandra/testtools/EmbeddedCassandraResource.java +++ b/external/storm-cassandra/src/test/java/org/apache/storm/cassandra/testtools/EmbeddedCassandraResource.java @@ -1,22 +1,15 @@ /** * Copyright (c) 2009-2011 VMware, Inc. All Rights Reserved. * - * 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 + * 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. + * 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.storm.cassandra.testtools; @@ -25,12 +18,10 @@ import java.io.File; import java.io.IOException; import java.util.HashSet; import java.util.Set; - import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.io.util.FileUtils; import org.apache.cassandra.service.CassandraDaemon; import org.apache.cassandra.utils.FBUtilities; - import org.junit.rules.ExternalResource; /** @@ -41,7 +32,8 @@ import org.junit.rules.ExternalResource; * This implementation is based on the springsource community project, * com.springsource.insight:insight-plugin-cassandra12. * - * {@see <a href="https://github.com/spring-projects/spring-insight-plugins/blob/c2986b457b482cd08a77a26297c087df59535067/collection-plugins/cassandra12/src/test/java/com/springsource/insight/plugin/cassandra/embeded/EmbeddedCassandraService.java"> + * {@see <a href="https://github.com/spring-projects/spring-insight-plugins/blob/c2986b457b482cd08a77a26297c087df59535067/collection + * -plugins/cassandra12/src/test/java/com/springsource/insight/plugin/cassandra/embeded/EmbeddedCassandraService.java"> * com.springsource.insight:insight-plugin-cassandra12 * </a>} * @@ -52,10 +44,9 @@ import org.junit.rules.ExternalResource; */ public class EmbeddedCassandraResource extends ExternalResource { - CassandraDaemon cassandraDaemon; - private final String host; private final Integer nativeTransportPort; + CassandraDaemon cassandraDaemon; public EmbeddedCassandraResource() { try { @@ -64,8 +55,7 @@ public class EmbeddedCassandraResource extends ExternalResource { cassandraDaemon.init(null); host = DatabaseDescriptor.getRpcAddress().getHostName(); nativeTransportPort = DatabaseDescriptor.getNativeTransportPort(); - } - catch (Exception e) { + } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } } @@ -83,8 +73,7 @@ public class EmbeddedCassandraResource extends ExternalResource { if (FBUtilities.isWindows()) { cassandraDaemon.thriftServer.stop(); cassandraDaemon.nativeServer.stop(); - } - else { + } else { cassandraDaemon.stop(); }
