Permalink
Browse files

Merge pull request #391 from normanmaurer/master

Cleanup generics and remove other warnings
  • Loading branch information...
2 parents 67170ff + 2fdc90e commit 40fa5742d5bc22bede2c03a308671aab75f7a056 Nate McCall committed Apr 5, 2012
Showing with 44 additions and 50 deletions.
  1. +1 −1 core/src/main/java/me/prettyprint/cassandra/jndi/CassandraClientJndiResourceFactory.java
  2. +1 −1 core/src/main/java/me/prettyprint/cassandra/model/MutatorImpl.java
  3. +1 −1 core/src/main/java/me/prettyprint/cassandra/serializers/FastInfosetSerializer.java
  4. +1 −1 core/src/main/java/me/prettyprint/cassandra/serializers/JaxbSerializer.java
  5. +1 −1 core/src/main/java/me/prettyprint/cassandra/service/IndexedSlicesIterator.java
  6. +0 −1 core/src/main/java/me/prettyprint/cassandra/service/template/ColumnFamilyResultWrapper.java
  7. +0 −2 core/src/main/java/me/prettyprint/cassandra/service/template/ColumnFamilyTemplate.java
  8. +0 −1 core/src/main/java/me/prettyprint/cassandra/service/template/SuperCfResultWrapper.java
  9. +1 −1 core/src/test/java/me/prettyprint/cassandra/BaseEmbededServerSetupTest.java
  10. +2 −2 core/src/test/java/me/prettyprint/cassandra/connection/HConnectionManagerTest.java
  11. +1 −1 core/src/test/java/me/prettyprint/cassandra/examples/ExampleDaoV2Test.java
  12. +4 −8 core/src/test/java/me/prettyprint/cassandra/model/CqlQueryTest.java
  13. +2 −2 core/src/test/java/me/prettyprint/cassandra/model/MutatorTest.java
  14. +2 −1 core/src/test/java/me/prettyprint/cassandra/serializers/JaxbSerializerTest.java
  15. +4 −3 core/src/test/java/me/prettyprint/cassandra/serializers/TypeInferringSerializerTest.java
  16. +1 −1 core/src/test/java/me/prettyprint/cassandra/service/CassandraAuthTest.java
  17. +2 −1 core/src/test/java/me/prettyprint/cassandra/service/CassandraHostConfiguratorTest.java
  18. +0 −1 core/src/test/java/me/prettyprint/cassandra/service/KeyspaceTest.java
  19. +9 −9 core/src/test/java/me/prettyprint/cassandra/service/template/ColumnFamilyTemplateTest.java
  20. +9 −9 core/src/test/java/me/prettyprint/cassandra/service/template/SuperCfTemplateTest.java
  21. +2 −2 core/src/test/java/me/prettyprint/hector/api/ApiV2SystemTest.java
@@ -123,7 +123,7 @@ private void configure(Reference resourceRef) throws Exception {
if ( log.isDebugEnabled() )
log.debug("JNDI resource created with CassandraHostConfiguration: {}", cassandraHostConfigurator.getAutoDiscoverHosts());
- cluster = HFactory.createCluster((String)clusterNameRef.getContent(), cassandraHostConfigurator);
+ cluster = HFactory.getOrCreateCluster((String)clusterNameRef.getContent(), cassandraHostConfigurator);
keyspace = HFactory.createKeyspace((String)keyspaceNameRef.getContent(), cluster);
}
}
@@ -316,7 +316,7 @@ public int getPendingMutationCount() {
addCounterSubDeletion(key,cf,
new HCounterSuperColumnImpl<SN,N>(sNameSerializer,nameSerializer)
.setName(supercolumnName)
- .addSubCounterColumn(new HCounterColumnImpl(nameSerializer)));
+ .addSubCounterColumn(new HCounterColumnImpl<N>(nameSerializer)));
return execute();
}
@@ -29,7 +29,7 @@
* that concrete classes directly referenced by any class in the list
* will also be serializable through this instance.
*/
- public FastInfosetSerializer(final Class... serializableClasses) {
+ public FastInfosetSerializer(final Class<?>... serializableClasses) {
super(serializableClasses);
}
@@ -51,7 +51,7 @@
* that concrete classes directly referenced by any class in the list
* will also be serializable through this instance.
*/
- public JaxbSerializer(final Class... serializableClasses) {
+ public JaxbSerializer(final Class<?>... serializableClasses) {
marshaller = new ThreadLocal<Marshaller>() {
@Override
protected Marshaller initialValue() {
@@ -9,7 +9,7 @@
*
* @author thrykol
*/
-public class IndexedSlicesIterator<K, N, V> implements Iterator {
+public class IndexedSlicesIterator<K, N, V> implements Iterator<Row<K, N, V>> {
private IndexedSlicesQuery<K, N, V> query;
private K startKey;
@@ -22,7 +22,6 @@
private Map<N,HColumn<N,ByteBuffer>> columns;
private Iterator<Map.Entry<ByteBuffer, List<ColumnOrSuperColumn>>> rows;
private Map.Entry<ByteBuffer, List<ColumnOrSuperColumn>> entry;
- private ExecutionResult<Map<ByteBuffer,List<ColumnOrSuperColumn>>> executionResult;
private boolean hasEntries;
public ColumnFamilyResultWrapper(Serializer<K> keySerializer,
@@ -117,7 +117,6 @@ public int countColumns(K key, N start, N end, int max) {
return doExecuteMultigetSlice(keys, activeSlicePredicate);
}
- @SuppressWarnings("unchecked")
public <T> T queryColumns(K key, ColumnFamilyRowMapper<K, N, T> mapper) {
return queryColumns(key, activeSlicePredicate, mapper);
}
@@ -148,7 +147,6 @@ public int countColumns(K key, N start, N end, int max) {
* @param mapper
* @return
*/
- @SuppressWarnings("unchecked")
public <T> T queryColumns(K key, List<N> columns,
ColumnFamilyRowMapper<K, N, T> mapper) {
HSlicePredicate<N> predicate = new HSlicePredicate<N>(topSerializer);
@@ -45,7 +45,6 @@
private Map<SN,Map<N,HColumn<N,ByteBuffer>>> columns = new LinkedHashMap<SN,Map<N,HColumn<N,ByteBuffer>>>();
private Iterator<Map.Entry<ByteBuffer, List<ColumnOrSuperColumn>>> rows;
private Map.Entry<ByteBuffer, List<ColumnOrSuperColumn>> entry;
- private ExecutionResult<Map<ByteBuffer,List<ColumnOrSuperColumn>>> executionResult;
private List<SN> superColumns;
private Map<N,HColumn<N,ByteBuffer>> subColumns = new LinkedHashMap<N,HColumn<N,ByteBuffer>>();
private SN currentSuperColumn;
@@ -43,7 +43,7 @@ public static void setup() throws TTransportException, IOException, InterruptedE
@AfterClass
public static void teardown() throws IOException {
- embedded.teardown();
+ EmbeddedServerHelper.teardown();
embedded = null;
}
@@ -39,15 +39,15 @@ public void testAddCassandraHostFail() {
@Test(expected=IllegalArgumentException.class)
public void testNullHostList() {
- HConnectionManager hcm = new HConnectionManager(clusterName, new CassandraHostConfigurator());
+ new HConnectionManager(clusterName, new CassandraHostConfigurator());
}
@Test
public void testMarkHostDownWithNoRetry() {
cassandraHostConfigurator = new CassandraHostConfigurator("127.0.0.1:9170");
cassandraHostConfigurator.setRetryDownedHosts(false);
connectionManager = new HConnectionManager(clusterName, cassandraHostConfigurator);
- CassandraHost cassandraHost = new CassandraHost("127.0.0.1", 9170);
+ new CassandraHost("127.0.0.1", 9170);
HClient client = connectionManager.borrowClient();
connectionManager.markHostAsDown(client.getCassandraHost());
assertEquals(0,connectionManager.getActivePools().size());
@@ -40,7 +40,7 @@ public static void setup() throws TTransportException, IOException, InterruptedE
@AfterClass
public static void teardown() throws IOException {
- embedded.teardown();
+ EmbeddedServerHelper.teardown();
}
@Test
@@ -16,13 +16,9 @@
import org.apache.cassandra.utils.ByteBufferUtil;
import org.junit.Before;
import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class CqlQueryTest extends BaseEmbededServerSetupTest {
-
- private Logger log = LoggerFactory.getLogger(CqlQueryTest.class);
-
+
private final static String KEYSPACE = "Keyspace1";
private static final StringSerializer se = new StringSerializer();
private static final LongSerializer le = new LongSerializer();
@@ -87,15 +83,15 @@ public void testCountQuery() {
public void testSyntaxFailQuery() {
CqlQuery<String,String,Long> cqlQuery = new CqlQuery<String,String,Long>(keyspace, se, se, le);
cqlQuery.setQuery("SELECT COUNT(*) FROM Standard1 WHERE KEY = 'cqlQueryTest_key1'");
- QueryResult<CqlRows<String,String,Long>> result = cqlQuery.execute();
+ cqlQuery.execute();
}
@Test
public void testInsertSyntax() {
CqlQuery<String,String,Long> cqlQuery = new CqlQuery<String,String,Long>(keyspace, se, se, le);
cqlQuery.setQuery("update StandardLong1 set 'birthyear' = '1976' WHERE KEY = 'cqlQueryTest_key7'");
- QueryResult<CqlRows<String,String,Long>> result = cqlQuery.execute();
+ cqlQuery.execute();
}
@Test
@@ -106,6 +102,6 @@ public void testInsertSyntaxHex() {
ByteBufferUtil.bytesToHex(se.toByteBuffer("1976")),
ByteBufferUtil.bytesToHex(se.toByteBuffer("mykey1")));
cqlQuery.setQuery(query);
- QueryResult<CqlRows<String,String,Long>> result = cqlQuery.execute();
+ cqlQuery.execute();
}
}
@@ -99,7 +99,7 @@ public void testSubDelete() {
columnList.add(createColumn("col_3","val_3",se,se));
HSuperColumn<String, String, String> superColumn =
createSuperColumn("super_name", columnList, se, se, se);
- MutationResult r = m.insert("sk1", "Super1", superColumn);
+ m.insert("sk1", "Super1", superColumn);
SuperColumnQuery<String, String, String, String> scq = HFactory.createSuperColumnQuery(keyspace, se, se, se, se);
scq.setColumnFamily("Super1");
@@ -124,7 +124,7 @@ public void testSubDeleteHSuperColumn() {
columnList.add(createColumn("col_3","val_3",se,se));
HSuperColumn<String, String, String> superColumn =
createSuperColumn("super_name", columnList, se, se, se);
- MutationResult r = m.insert("sk1", "Super1", superColumn);
+ m.insert("sk1", "Super1", superColumn);
SuperColumnQuery<String, String, String, String> scq = HFactory.createSuperColumnQuery(keyspace, se, se, se, se);
scq.setColumnFamily("Super1");
@@ -38,7 +38,8 @@
}
/** private constructor for JAXB compatibility. */
- private JaxbString() {
+ @SuppressWarnings("unused")
+ private JaxbString() {
}
@Override
@@ -31,22 +31,23 @@ public void testConversions() {
@Test
public void testByteConversions() {
- TypeInferringSerializer ext = TypeInferringSerializer.get();
+ TypeInferringSerializer<Object> ext = TypeInferringSerializer.get();
ByteBuffer byteBuffer = ext.toByteBuffer("bytes".getBytes());
Assert.assertTrue(byteBuffer != null);
}
@SuppressWarnings("rawtypes")
private void test(Object object) {
- TypeInferringSerializer ext = TypeInferringSerializer.get();
+ TypeInferringSerializer<Object> ext = TypeInferringSerializer.get();
ByteBuffer bytes = ext.toByteBuffer(object);
Serializer ser = SerializerTypeInferer.getSerializer(object.getClass());
Object target = ser.fromByteBuffer(bytes);
assertEquals(object, target);
}
- private static class SampleObject implements Serializable {
+ @SuppressWarnings("serial")
+private static class SampleObject implements Serializable {
private final String a = "test";
private final List<Void> b = new ArrayList<Void>();
private final Calendar c = Calendar.getInstance();
@@ -79,7 +79,7 @@ public static void setup() throws TTransportException, IOException, InterruptedE
@AfterClass
public static void teardown() throws IOException {
- embedded.teardown();
+ EmbeddedServerHelper.teardown();
embedded = null;
}
@@ -87,7 +87,8 @@ public void testConfiguratorPort() {
@Test
public void testConfiguratorClockResolution() {
// Define my own clock resolution.
- class SequentialClockResolution implements ClockResolution {
+ @SuppressWarnings("serial")
+ class SequentialClockResolution implements ClockResolution {
@Override
public long createClock() {
return System.currentTimeMillis() * -1;
@@ -11,7 +11,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -16,12 +16,12 @@
public void testCreateSelect() {
ColumnFamilyTemplate<String, String> template = new ThriftColumnFamilyTemplate<String, String>(keyspace, "Standard1", se, se);
- ColumnFamilyUpdater updater = template.createUpdater("key1");
+ ColumnFamilyUpdater<String,String> updater = template.createUpdater("key1");
updater.setString("column1","value1");
template.update(updater);
template.addColumn("column1", se);
- ColumnFamilyResult wrapper = template.queryColumns("key1");
+ ColumnFamilyResult<String,String> wrapper = template.queryColumns("key1");
assertEquals("value1",wrapper.getString("column1"));
}
@@ -40,7 +40,7 @@ public void testCreateSelectMultiColumn() {
template.addColumn("stringval", se);
template.addColumn("curdate", DateSerializer.get());
template.addColumn("longval", LongSerializer.get());
- ColumnFamilyResult wrapper = template.queryColumns("cskey1");
+ ColumnFamilyResult<String,String> wrapper = template.queryColumns("cskey1");
assertEquals("value1",wrapper.getString("stringval"));
assertEquals(date,wrapper.getDate("curdate"));
assertEquals(new Long(5),wrapper.getLong("longval"));
@@ -79,7 +79,7 @@ public void testCompareClocks() {
@Test
public void testCreateSelectTemplate() {
ColumnFamilyTemplate<String, String> template = new ThriftColumnFamilyTemplate<String, String>(keyspace, "Standard1", se, se);
- ColumnFamilyUpdater updater = template.createUpdater("key1");
+ ColumnFamilyUpdater<String,String> updater = template.createUpdater("key1");
updater.setString("column1","value1");
template.update(updater);
template.setCount(10);
@@ -96,13 +96,13 @@ public String mapRow(ColumnFamilyResult<String, String> results) {
@Test
public void testOverloadedMapRowCallback() {
ColumnFamilyTemplate<String, String> template = new ThriftColumnFamilyTemplate<String, String>(keyspace, "Standard1", se, se);
- ColumnFamilyUpdater updater = template.createUpdater("key1");
+ ColumnFamilyUpdater<String,String> updater = template.createUpdater("key1");
updater.setString("column1","value1");
updater.addKey("key2");
updater.setString("column1", "value2");
template.update(updater);
template.setCount(10);
- MappedColumnFamilyResult result = template.queryColumns(Arrays.asList("key1","key2"), new ColumnFamilyRowMapper<String, String, String>() {
+ MappedColumnFamilyResult<String,String,String> result = template.queryColumns(Arrays.asList("key1","key2"), new ColumnFamilyRowMapper<String, String, String>() {
@Override
public String mapRow(ColumnFamilyResult<String, String> results) {
@@ -121,7 +121,7 @@ public String mapRow(ColumnFamilyResult<String, String> results) {
@Test
public void testQueryMultiget() {
ColumnFamilyTemplate<String, String> template = new ThriftColumnFamilyTemplate<String, String>(keyspace, "Standard1", se, se);
- ColumnFamilyUpdater updater = template.createUpdater("mg_key1");
+ ColumnFamilyUpdater<String,String> updater = template.createUpdater("mg_key1");
updater.setString("column1","value1");
updater.addKey("mg_key2");
updater.setString("column1","value2");
@@ -130,7 +130,7 @@ public void testQueryMultiget() {
template.update(updater);
template.addColumn("column1", se);
- ColumnFamilyResult wrapper = template.queryColumns(Arrays.asList("mg_key1", "mg_key2", "mg_key3"));
+ ColumnFamilyResult<String,String> wrapper = template.queryColumns(Arrays.asList("mg_key1", "mg_key2", "mg_key3"));
assertEquals("value1",wrapper.getString("column1"));
wrapper.next();
assertEquals("value2",wrapper.getString("column1"));
@@ -157,7 +157,7 @@ public void testGetKeyTwiceCall() {
@Test
public void testQueryIndexedSlices() {
ColumnFamilyTemplate<String, String> template = new ThriftColumnFamilyTemplate<String, String>(keyspace, "Indexed1", se, se);
- ColumnFamilyUpdater updater = template.createUpdater("index_key1");
+ ColumnFamilyUpdater<String,String> updater = template.createUpdater("index_key1");
updater.setLong("birthyear", 1974L);
updater.setLong("birthmonth", 4L);
updater.addKey("index_key2");
@@ -17,7 +17,7 @@
public void testSuperCfInsertReadTemplate() {
SuperCfTemplate<String, String, String> sTemplate =
new ThriftSuperCfTemplate<String, String, String>(keyspace, "Super1", se, se, se);
- SuperCfUpdater sUpdater = sTemplate.createUpdater("skey1","super1");
+ SuperCfUpdater<String,String,String> sUpdater = sTemplate.createUpdater("skey1","super1");
sUpdater.setString("sub_col_1", "sub_val_1");
sTemplate.update(sUpdater);
@@ -37,7 +37,7 @@ public void testSuperCfInsertReadTemplate() {
public void testSuperCfMultiSc() {
SuperCfTemplate<String, String, String> sTemplate =
new ThriftSuperCfTemplate<String, String, String>(keyspace, "Super1", se, se, se);
- SuperCfUpdater sUpdater = sTemplate.createUpdater("skey2","super1");
+ SuperCfUpdater<String,String,String> sUpdater = sTemplate.createUpdater("skey2","super1");
sUpdater.setString("sub1_col_1", "sub1_val_1");
sUpdater.addSuperColumn("super2");
sUpdater.setString("sub2_col_1", "sub2_val_1");
@@ -58,7 +58,7 @@ public void testSuperCfMultiSc() {
public void testQuerySingleSubColumn() {
SuperCfTemplate<String, String, String> sTemplate =
new ThriftSuperCfTemplate<String, String, String>(keyspace, "Super1", se, se, se);
- SuperCfUpdater sUpdater = sTemplate.createUpdater("skey3","super1");
+ SuperCfUpdater<String,String,String> sUpdater = sTemplate.createUpdater("skey3","super1");
sUpdater.setString("sub1_col_1", "sub1_val_1");
sTemplate.update(sUpdater);
@@ -70,7 +70,7 @@ public void testQuerySingleSubColumn() {
public void testQuerySingleSubColumnExtractSuper() {
SuperCfTemplate<String, String, String> sTemplate =
new ThriftSuperCfTemplate<String, String, String>(keyspace, "Super1", se, se, se);
- SuperCfUpdater sUpdater = sTemplate.createUpdater("skey3","super1");
+ SuperCfUpdater<String,String,String> sUpdater = sTemplate.createUpdater("skey3","super1");
sUpdater.setString("sub1_col_1", "sub1_val_1");
sUpdater.setString("sub1_col_2", "sub1_val_2");
sTemplate.update(sUpdater);
@@ -86,7 +86,7 @@ public void testQuerySingleSubColumnExtractSuper() {
public void testQuerySingleSubColumnEmpty() {
SuperCfTemplate<String, String, String> sTemplate =
new ThriftSuperCfTemplate<String, String, String>(keyspace, "Super1", se, se, se);
- SuperCfUpdater sUpdater = sTemplate.createUpdater("skey3","super1");
+ SuperCfUpdater<String,String,String> sUpdater = sTemplate.createUpdater("skey3","super1");
sUpdater.setString("sub1_col_1", "sub1_val_1");
sTemplate.update(sUpdater);
@@ -98,7 +98,7 @@ public void testQuerySingleSubColumnEmpty() {
public void testSuperCfInsertReadMultiKey() {
SuperCfTemplate<String, String, String> sTemplate =
new ThriftSuperCfTemplate<String, String, String>(keyspace, "Super1", se, se, se);
- SuperCfUpdater sUpdater = sTemplate.createUpdater("s_multi_key1","super1");
+ SuperCfUpdater<String,String,String> sUpdater = sTemplate.createUpdater("s_multi_key1","super1");
sUpdater.setString("sub_col_1", "sub_val_1");
sUpdater.addKey("s_multi_key2");
sUpdater.addSuperColumn("super1");
@@ -116,7 +116,7 @@ public void testSuperCfInsertReadMultiKey() {
public void testSuperCfInsertReadMultiKeyNoSc() {
SuperCfTemplate<String, String, String> sTemplate =
new ThriftSuperCfTemplate<String, String, String>(keyspace, "Super1", se, se, se);
- SuperCfUpdater sUpdater = sTemplate.createUpdater("s_multi_key1","super1");
+ SuperCfUpdater<String,String,String> sUpdater = sTemplate.createUpdater("s_multi_key1","super1");
sUpdater.setString("sub_col_1", "sub_val_1");
sUpdater.addKey("s_multi_key2");
sUpdater.addSuperColumn("super1");
@@ -134,7 +134,7 @@ public void testSuperCfInsertReadMultiKeyNoSc() {
public void testSuperCfKeyOnly() {
SuperCfTemplate<String, String, String> sTemplate =
new ThriftSuperCfTemplate<String, String, String>(keyspace, "Super1", se, se, se);
- SuperCfUpdater sUpdater = sTemplate.createUpdater("skey1","super1");
+ SuperCfUpdater<String,String,String> sUpdater = sTemplate.createUpdater("skey1","super1");
sUpdater.setString("sub_col_1", "sub_val_1");
sUpdater.addSuperColumn("super2");
sUpdater.setString("sub_col_1", "sub_val_2");
@@ -159,7 +159,7 @@ public void testSuperCfNoResults() {
public void testDeleteSubColumns() {
SuperCfTemplate<String, String, String> sTemplate =
new ThriftSuperCfTemplate<String, String, String>(keyspace, "Super1", se, se, se);
- SuperCfUpdater sUpdater = sTemplate.createUpdater("skey3","super1");
+ SuperCfUpdater<String,String,String> sUpdater = sTemplate.createUpdater("skey3","super1");
sUpdater.setString("sub1_col_1", "sub1_val_1");
sUpdater.setString("sub1_col_2", "sub1_val_2");
sUpdater.setString("sub1_col_3", "sub1_val_3");
Oops, something went wrong.

0 comments on commit 40fa574

Please sign in to comment.