diff --git a/cassandra/README.md b/cassandra/README.md index bee44c8d8c41a36f459d0b38b54d35422dddac1a..a25b18e6426edb6a0382de705ddf38ce0f6e2a0a 100644 --- a/cassandra/README.md +++ b/cassandra/README.md @@ -77,4 +77,7 @@ For keyspace `ycsb`, table `usertable`: * Defaults for max and core connections can be found here: https://datastax.github.io/java-driver/2.1.8/features/pooling/#pool-size. Cassandra 2.0.X falls under protocol V2, Cassandra 2.1+ falls under protocol V3. * `cassandra.connecttimeoutmillis` * `cassandra.readtimeoutmillis` - * Defaults for connect and read timeouts can be found here: https://docs.datastax.com/en/drivers/java/2.0/com/datastax/driver/core/SocketOptions.html. \ No newline at end of file + * Defaults for connect and read timeouts can be found here: https://docs.datastax.com/en/drivers/java/2.0/com/datastax/driver/core/SocketOptions.html. +* `cassandra.tracing` + * Default is false + * https://docs.datastax.com/en/cql/3.3/cql/cql_reference/tracing_r.html \ No newline at end of file diff --git a/cassandra/pom.xml b/cassandra/pom.xml index 15a145eafc896387a6045d05a3fecdae04350936..570e010f1f6da2381df92e13b62643f95197fb8c 100644 --- a/cassandra/pom.xml +++ b/cassandra/pom.xml @@ -62,6 +62,14 @@ LICENSE file. <version>4.12</version> <scope>test</scope> </dependency> + <!-- only for Cassandra test (Cassandra 2.2+ uses Sigar for collecting system information, and Sigar requires some native lib files) --> + <dependency> + <groupId>org.hyperic</groupId> + <artifactId>sigar-dist</artifactId> + <version>1.6.4.129</version> + <type>zip</type> + <scope>test</scope> + </dependency> </dependencies> <profiles> @@ -78,4 +86,56 @@ LICENSE file. </properties> </profile> </profiles> + <!-- sigar-dist can be downloaded from jboss repository --> + <repositories> + <repository> + <id>central2</id> + <name>sigar Repository</name> + <url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url> + <layout>default</layout> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + <!-- unzip sigar-dist/lib files. + References: + http://stackoverflow.com/questions/5388661/unzip-dependency-in-maven + https://arviarya.wordpress.com/2013/09/22/sigar-access-operating-system-and-hardware-level-information/ + --> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>unpack-sigar</id> + <phase>process-test-resources<!-- or any other valid maven phase --></phase> + <goals> + <goal>unpack-dependencies</goal> + </goals> + <configuration> + <includeGroupIds>org.hyperic</includeGroupIds> + <includeArtifactIds>sigar-dist</includeArtifactIds> + <includes>**/sigar-bin/lib/*</includes> + <excludes>**/sigar-bin/lib/*jar</excludes> + <outputDirectory> + ${project.build.directory}/cassandra-dependency + </outputDirectory> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.8</version> + <configuration> + <argLine>-Djava.library.path=${project.build.directory}/cassandra-dependency/hyperic-sigar-1.6.4/sigar-bin/lib</argLine> + </configuration> + </plugin> + + </plugins> + </build> </project> diff --git a/cassandra/src/main/java/com/yahoo/ycsb/db/CassandraCQLClient.java b/cassandra/src/main/java/com/yahoo/ycsb/db/CassandraCQLClient.java index d4dc8c7707b429f090561967d35acaa5052c4cac..ee2dd8f5417ec38be9b1667c8b78238f4e0812f9 100644 --- a/cassandra/src/main/java/com/yahoo/ycsb/db/CassandraCQLClient.java +++ b/cassandra/src/main/java/com/yahoo/ycsb/db/CassandraCQLClient.java @@ -85,6 +85,9 @@ public class CassandraCQLClient extends DB { public static final String READ_TIMEOUT_MILLIS_PROPERTY = "cassandra.readtimeoutmillis"; + public static final String TRACING_PROPERTY = "cassandra.tracing"; + public static final String TRACING_PROPERTY_DEFAULT = "false"; + /** * Count the number of times initialized to teardown on the last * {@link #cleanup()}. @@ -93,6 +96,8 @@ public class CassandraCQLClient extends DB { private static boolean debug = false; + private static boolean trace = false; + /** * Initialize any state for this DB. Called once per DB instance; there is one * DB instance per client thread. @@ -116,7 +121,8 @@ public class CassandraCQLClient extends DB { debug = Boolean.parseBoolean(getProperties().getProperty("debug", "false")); - + trace = Boolean.valueOf(getProperties().getProperty(TRACING_PROPERTY, TRACING_PROPERTY_DEFAULT)); + String host = getProperties().getProperty(HOSTS_PROPERTY); if (host == null) { throw new DBException(String.format( @@ -254,7 +260,10 @@ public class CassandraCQLClient extends DB { if (debug) { System.out.println(stmt.toString()); } - + if (trace) { + stmt.enableTracing(); + } + ResultSet rs = session.execute(stmt); if (rs.isExhausted()) { @@ -343,7 +352,10 @@ public class CassandraCQLClient extends DB { if (debug) { System.out.println(stmt.toString()); } - + if (trace) { + stmt.enableTracing(); + } + ResultSet rs = session.execute(stmt); HashMap<String, ByteIterator> tuple; @@ -432,7 +444,10 @@ public class CassandraCQLClient extends DB { if (debug) { System.out.println(insertStmt.toString()); } - + if (trace) { + insertStmt.enableTracing(); + } + session.execute(insertStmt); return Status.OK; @@ -465,7 +480,10 @@ public class CassandraCQLClient extends DB { if (debug) { System.out.println(stmt.toString()); } - + if (trace) { + stmt.enableTracing(); + } + session.execute(stmt); return Status.OK;