Skip to content

Commit

Permalink
updated to 0.7 hector and cassandra deps. Added mvn.riptano.com for m…
Browse files Browse the repository at this point in the history
…aven respository
  • Loading branch information
zznate committed Sep 7, 2010
1 parent eee5a5f commit b886352
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 175 deletions.
136 changes: 33 additions & 103 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.vrvm.cassandra.hector</groupId>
<groupId>com.riptano.cassandra.hector</groupId>
<artifactId>hector-examples</artifactId>
<version>1.0-SNAPSHOT</version>
<version>0.7</version>
<packaging>jar</packaging>
<name>hector-examples</name>

<properties>
<hector.version>0.6.0-15</hector.version>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -39,12 +35,30 @@
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-javautils</artifactId>
<version>1.0.0</version>
<version>0.7.0</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>r06</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>avro</artifactId>
<version>1.3.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>snakeyaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>me.prettyprint</groupId>
<artifactId>hector</artifactId>
<version>${hector.version}</version>
<version>0.7.0-17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand All @@ -64,12 +78,12 @@
<dependency>
<groupId>libthrift</groupId>
<artifactId>libthrift</artifactId>
<version>917130</version>
<version>959516</version>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra</artifactId>
<version>0.6.0</version>
<artifactId>apache-cassandra</artifactId>
<version>0.7.0-beta1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand Down Expand Up @@ -97,97 +111,7 @@
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>install libthrift</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<groupId>libthrift</groupId>
<artifactId>libthrift</artifactId>
<version>917130</version>
<file>${basedir}/lib/libthrift-r917130.jar</file>
</configuration>
</execution>
<execution>
<id>install cassandra</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra</artifactId>
<version>0.6.0</version>
<file>${basedir}/lib/apache-cassandra-0.6.0.jar</file>
</configuration>
</execution>
<execution>
<id>install high-scale-lib</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<groupId>org.cliffc.high_scale_lib</groupId>
<artifactId>high-scale-lib</artifactId>
<version>1.0.0</version>
<file>${basedir}/lib/high-scale-lib.jar</file>
</configuration>
</execution>
<execution>
<id>install clhm-production</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<groupId>com.reardencommerce</groupId>
<artifactId>clhm-production</artifactId>
<version>1.0.0</version>
<file>${basedir}/lib/clhm-production.jar</file>
</configuration>
</execution>
<execution>
<id>install cassandra-javautils</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-javautils</artifactId>
<version>1.0.0</version>
<file>${basedir}/lib/cassandra-javautils.jar</file>
</configuration>
</execution>
<execution>
<id>install hector</id>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<groupId>me.prettyprint</groupId>
<artifactId>hector</artifactId>
<version>0.6.0-14</version>
<file>${basedir}/lib/hector-${hector.version}.jar</file>
</configuration>
</execution>
</executions>
</plugin>

<!-- mvn exec:java -Dexec.mainClass="com.example.Main" -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand All @@ -203,5 +127,11 @@
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>riptano</id>
<name>riptano</name>
<url>http://mvn.riptano.com/content/repositories/public/</url>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static void main(String[] args) throws Exception {
CassandraClientPool pool = CassandraClientPoolFactory.INSTANCE.get();
CassandraClient client = pool.borrowClient("localhost", 9160);
Keyspace keyspace = null;
/*
try {
keyspace = client.getKeyspace("Keyspace1");
Expand All @@ -48,5 +49,6 @@ public static void main(String[] args) throws Exception {
} finally {
pool.releaseClient(keyspace.getClient());
}
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static void main(String[] args) throws Exception {
CassandraClientPool pool = CassandraClientPoolFactory.INSTANCE.get();
CassandraClient client = pool.borrowClient("localhost", 9160);
Keyspace keyspace = null;
/*
try {
keyspace = client.getKeyspace("Keyspace1");
Expand Down Expand Up @@ -78,5 +79,6 @@ public static void main(String[] args) throws Exception {
} finally {
pool.releaseClient(keyspace.getClient());
}
*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static void main(String[] args) throws Exception {
CassandraClientPool pool = CassandraClientPoolFactory.INSTANCE.get();
CassandraClient client = pool.borrowClient("localhost", 9160);
Keyspace keyspace = null;
/*
try {
keyspace = client.getKeyspace("Keyspace1");
// Insert 10 rows with 3 columns each of dummy data
Expand Down Expand Up @@ -75,6 +76,7 @@ public static void main(String[] args) throws Exception {
} finally {
pool.releaseClient(keyspace.getClient());
}
*/
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public static void main(String[] args) throws Exception {
CassandraClientPool pool = CassandraClientPoolFactory.INSTANCE.get();
CassandraClient client = pool.borrowClient("localhost", 9160);
Keyspace keyspace = null;
/*
try {
keyspace = client.getKeyspace("Keyspace1");
Expand Down Expand Up @@ -68,5 +69,6 @@ public static void main(String[] args) throws Exception {
} finally {
pool.releaseClient(keyspace.getClient());
}
*/
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package com.riptano.cassandra.hector.example;

import me.prettyprint.cassandra.model.ColumnQuery;
import me.prettyprint.cassandra.model.HColumn;
import me.prettyprint.cassandra.model.HFactory;
import me.prettyprint.cassandra.model.HectorException;
import me.prettyprint.cassandra.model.KeyspaceOperator;
import me.prettyprint.cassandra.model.Mutator;
import me.prettyprint.cassandra.model.Result;
import me.prettyprint.cassandra.serializers.StringSerializer;
import me.prettyprint.cassandra.service.CassandraClient;
import me.prettyprint.cassandra.service.CassandraClientPool;
import me.prettyprint.cassandra.service.CassandraClientPoolFactory;
import me.prettyprint.cassandra.service.Cluster;
import me.prettyprint.cassandra.service.Keyspace;
import me.prettyprint.cassandra.utils.StringUtils;

Expand All @@ -21,25 +30,26 @@
*/
public class InsertSingleColumn {

private static StringSerializer stringSerializer = StringSerializer.get();

public static void main(String[] args) throws Exception {

CassandraClientPool pool = CassandraClientPoolFactory.INSTANCE.get();
CassandraClient client = pool.borrowClient("localhost", 9160);
Keyspace keyspace = null;
Cluster cluster = HFactory.getOrCreateCluster("TestCluster", "localhost:9160");

KeyspaceOperator keyspaceOperator = HFactory.createKeyspaceOperator("Keyspace1", cluster);
try {
keyspace = client.getKeyspace("Keyspace1");
ColumnPath columnPath = new ColumnPath("Standard1");
columnPath.setColumn(StringUtils.bytes("first"));
keyspace.insert("jsmith", columnPath, StringUtils.bytes("John"));

Column col = keyspace.getColumn("jsmith", columnPath);
String columnValue = StringUtils.string(col.getValue());
Mutator<String> mutator = HFactory.createMutator(keyspaceOperator, stringSerializer);
mutator.insert("jsmith", "Standard1", HFactory.createStringColumn("first", "John"));

System.out.println("Read from cassandra: " + columnValue);
ColumnQuery<String, String, String> columnQuery = HFactory.createStringColumnQuery(keyspaceOperator);
columnQuery.setColumnFamily("Standard1");
columnQuery.setKey("jsmith");
columnQuery.setName("first");
Result<HColumn<String, String>> result = columnQuery.execute();
System.out.println("Read HColumn from cassandra: " + result.get());
System.out.println("Verify on CLI with: get Keyspace1.Standard1['jsmith'] ");

} finally {
pool.releaseClient(keyspace.getClient());
}
} catch (HectorException e) {
e.printStackTrace();
}
}
}
Loading

0 comments on commit b886352

Please sign in to comment.