You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2012/01/10 18:45:20 UTC
git commit: Remove contrib/javautils. Patch by brandonwilliams
reviewed by jbellis for CASSANDRA-3717
Updated Branches:
refs/heads/trunk 6c2bd5152 -> a3f2e9c3b
Remove contrib/javautils.
Patch by brandonwilliams reviewed by jbellis for CASSANDRA-3717
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a3f2e9c3
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a3f2e9c3
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a3f2e9c3
Branch: refs/heads/trunk
Commit: a3f2e9c3bf59b31bdb122a24527904b8ca27ada0
Parents: 6c2bd51
Author: Brandon Williams <br...@apache.org>
Authored: Tue Jan 10 11:37:14 2012 -0600
Committer: Brandon Williams <br...@apache.org>
Committed: Tue Jan 10 11:37:14 2012 -0600
----------------------------------------------------------------------
contrib/javautils/README | 8 -
contrib/javautils/build.xml | 93 ---------
.../utils/service/CassandraServiceDataCleaner.java | 94 ---------
.../utils/service/CassandraServiceTest.java | 154 ---------------
4 files changed, 0 insertions(+), 349 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a3f2e9c3/contrib/javautils/README
----------------------------------------------------------------------
diff --git a/contrib/javautils/README b/contrib/javautils/README
deleted file mode 100644
index ed30423..0000000
--- a/contrib/javautils/README
+++ /dev/null
@@ -1,8 +0,0 @@
-Java utilities for cassandra clients
-
-BUILD and test:
-
-1. ant the top-level cassandra project
-2. cd here
-3. ant test
-
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a3f2e9c3/contrib/javautils/build.xml
----------------------------------------------------------------------
diff --git a/contrib/javautils/build.xml b/contrib/javautils/build.xml
deleted file mode 100644
index a58e18e..0000000
--- a/contrib/javautils/build.xml
+++ /dev/null
@@ -1,93 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-~ 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.
--->
-<project basedir="." default="build" name="apache-cassandra-javautils">
- <property name="cassandra.dir" value="../.." />
- <property name="cassandra.lib" value="${cassandra.dir}/lib" />
- <property name="test.lib" value="${cassandra.dir}/build/lib" />
- <property name="cassandra.classes" value="${cassandra.dir}/build/classes" />
- <property name="build.src" value="${basedir}/src/main/java" />
- <property name="test.src" value="${basedir}/src/test/java" />
- <property name="test.reports" value="${basedir}/reports" />
- <property name="build.out" value="${basedir}/build" />
- <property name="build.classes" value="${build.out}/classes" />
- <property name="final.name" value="cassandra-javautils" />
-
- <path id="classpath">
- <path>
- <fileset dir="${cassandra.lib}">
- <include name="**/*.jar" />
- </fileset>
- <pathelement location="${cassandra.classes}/main" />
- <pathelement location="${cassandra.classes}/thrift" />
- </path>
- </path>
- <path id="test.classpath">
- <path refid="classpath"/>
- <path>
- <pathelement location="${build.classes}" />
- <fileset dir="${test.lib}">
- <exclude name="**/ant-1.6.5.jar" />
- <include name="**/*.jar" />
- </fileset>
- </path>
- </path>
-
- <target name="init">
- <mkdir dir="${build.classes}" />
- </target>
-
- <target depends="init" name="build">
- <javac destdir="${build.classes}">
- <src path="${build.src}" />
- <classpath refid="classpath"/>
- </javac>
- </target>
-
- <target name="jar" depends="build">
- <mkdir dir="${build.classes}/META-INF" />
- <jar jarfile="${build.out}/${final.name}.jar" basedir="${build.classes}" />
- </target>
-
- <target name="build-tests" depends="build" description="Builds the test files">
- <javac debug="true" srcdir="${test.src}" destdir="${build.classes}">
- <classpath refid="test.classpath"/>
- </javac>
- </target>
-
- <target name="test" depends="build-tests">
- <delete dir="${test.reports}" failonerror="yes"/>
- <mkdir dir="${test.reports}"/>
- <junit showoutput="true" printsummary="yes" dir="${basedir}" timeout="600000" fork="yes" includeantruntime="yes">
- <classpath refid="test.classpath"/>
- <formatter type="plain"/>
- <batchtest todir="${test.reports}">
- <fileset dir="${test.src}">
- <include name="**/*Test*.java"/>
- </fileset>
- </batchtest>
- </junit>
- </target>
-
- <target name="clean">
- <delete dir="${build.out}" />
- <delete dir="${test.reports}" />
- </target>
-</project>
-
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a3f2e9c3/contrib/javautils/src/main/java/org/apache/cassandra/contrib/utils/service/CassandraServiceDataCleaner.java
----------------------------------------------------------------------
diff --git a/contrib/javautils/src/main/java/org/apache/cassandra/contrib/utils/service/CassandraServiceDataCleaner.java b/contrib/javautils/src/main/java/org/apache/cassandra/contrib/utils/service/CassandraServiceDataCleaner.java
deleted file mode 100644
index 984e62c..0000000
--- a/contrib/javautils/src/main/java/org/apache/cassandra/contrib/utils/service/CassandraServiceDataCleaner.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-package org.apache.cassandra.contrib.utils.service;
-
-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.db.commitlog.CommitLog;
-import org.apache.cassandra.io.util.FileUtils;
-
-/**
- * A cleanup utility that wipes the cassandra data directories.
- *
- * @author Ran Tavory (rantav@gmail.com)
- *
- */
-public class CassandraServiceDataCleaner {
-
- /**
- * Creates all data dir if they don't exist and cleans them
- * @throws IOException
- */
- public void prepare() throws IOException {
- makeDirsIfNotExist();
- cleanupDataDirectories();
- CommitLog.instance.resetUnsafe();
- }
-
- /**
- * Deletes all data from cassandra data directories, including the commit log.
- * @throws IOException in case of permissions error etc.
- */
- public void cleanupDataDirectories() throws IOException {
- for (String s: getDataDirs()) {
- cleanDir(s);
- }
- }
- /**
- * Creates the data diurectories, if they didn't exist.
- * @throws IOException if directories cannot be created (permissions etc).
- */
- public void makeDirsIfNotExist() throws IOException {
- DatabaseDescriptor.createAllDirectories();
- }
-
- /**
- * Collects all data dirs and returns a set of String paths on the file system.
- *
- * @return
- */
- private Set<String> getDataDirs() {
- Set<String> dirs = new HashSet<String>();
- for (String s : DatabaseDescriptor.getAllDataFileLocations()) {
- dirs.add(s);
- }
- dirs.add(DatabaseDescriptor.getCommitLogLocation());
- return dirs;
- }
-
- /**
- * Removes all directory content from the file system
- *
- * @param dir
- * @throws IOException
- */
- private void cleanDir(String dir) throws IOException {
- File dirFile = new File(dir);
- if (dirFile.exists() && dirFile.isDirectory()) {
- for (File f : dirFile.listFiles()) {
- FileUtils.deleteRecursive(f);
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/a3f2e9c3/contrib/javautils/src/test/java/org/apache/cassandra/contrib/utils/service/CassandraServiceTest.java
----------------------------------------------------------------------
diff --git a/contrib/javautils/src/test/java/org/apache/cassandra/contrib/utils/service/CassandraServiceTest.java b/contrib/javautils/src/test/java/org/apache/cassandra/contrib/utils/service/CassandraServiceTest.java
deleted file mode 100644
index 36d66e5..0000000
--- a/contrib/javautils/src/test/java/org/apache/cassandra/contrib/utils/service/CassandraServiceTest.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements. See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership. The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing,
-* software distributed under the License is distributed on an
-* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-* KIND, either express or implied. See the License for the
-* specific language governing permissions and limitations
-* under the License.
-*/
-
-package org.apache.cassandra.contrib.utils.service;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.nio.ByteBuffer;
-
-import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.ConfigurationException;
-import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.config.KSMetaData;
-import org.apache.cassandra.service.EmbeddedCassandraService;
-import org.apache.cassandra.thrift.AuthenticationException;
-import org.apache.cassandra.thrift.AuthorizationException;
-import org.apache.cassandra.thrift.Cassandra;
-import org.apache.cassandra.thrift.Column;
-import org.apache.cassandra.thrift.ColumnOrSuperColumn;
-import org.apache.cassandra.thrift.ColumnParent;
-import org.apache.cassandra.thrift.ColumnPath;
-import org.apache.cassandra.thrift.ConsistencyLevel;
-import org.apache.cassandra.thrift.InvalidRequestException;
-import org.apache.cassandra.thrift.NotFoundException;
-import org.apache.cassandra.thrift.TimedOutException;
-import org.apache.cassandra.thrift.UnavailableException;
-import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.thrift.TException;
-import org.apache.thrift.protocol.TBinaryProtocol;
-import org.apache.thrift.protocol.TProtocol;
-import org.apache.thrift.transport.TFramedTransport;
-import org.apache.thrift.transport.TSocket;
-import org.apache.thrift.transport.TTransport;
-import org.apache.thrift.transport.TTransportException;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Example how to use an embedded and a data cleaner.
- *
- * @author Ran Tavory (rantav@gmail.com)
- *
- */
-public class CassandraServiceTest {
-
- private static EmbeddedCassandraService cassandra;
- private static CassandraServiceDataCleaner cleaner;
-
- /**
- * Set embedded cassandra up and spawn it in a new thread.
- *
- * @throws TTransportException
- * @throws IOException
- * @throws InterruptedException
- */
- @BeforeClass
- public static void setup() throws TTransportException, IOException,
- InterruptedException, ConfigurationException {
- // Tell cassandra where the configuration files are.
- // Use the test configuration file.
- System.setProperty("cassandra.config", "file:../../test/conf/cassandra.yaml");
- System.setProperty("log4j.configuration", "file:../../test/conf/log4j-junit.properties");
- //String configUrl = System.getProperty("cassandra.config");
- loadYamlTables();
- initCleaner();
- }
-
- private static void initCleaner() throws IOException, TTransportException, ConfigurationException {
- cleaner = new CassandraServiceDataCleaner();
- cleaner.prepare();
-
- cassandra = new EmbeddedCassandraService();
- cassandra.start();
- }
-
-
- /** Manually load tables from the test configuration file.
- * @throws ConfigurationException */
- private static void loadYamlTables() throws ConfigurationException {
- for (KSMetaData table : DatabaseDescriptor.readTablesFromYaml()) {
- for (CFMetaData cfm : table.cfMetaData().values()) {
- CFMetaData.map(cfm);
- }
- DatabaseDescriptor.setTableDefinition(table, DatabaseDescriptor.getDefsVersion());
- }
- }
-
-
- @Test
- public void testInProcessCassandraServer()
- throws UnsupportedEncodingException, InvalidRequestException,
- UnavailableException, TimedOutException, TException,
- NotFoundException, AuthenticationException, AuthorizationException {
- Cassandra.Client client = getClient();
-
- client.set_keyspace("Keyspace1");
-
- String key_user_id = "1";
-
- long timestamp = System.currentTimeMillis();
-
- // insert
- ColumnParent colParent = new ColumnParent("Standard1");
- Column column = new Column(ByteBufferUtil.bytes("name"),
- ByteBufferUtil.bytes("Ran"), timestamp);
-
- client.insert(ByteBufferUtil.bytes(key_user_id), colParent, column, ConsistencyLevel.ONE);
-
- // read
- ColumnPath cp = new ColumnPath("Standard1");
- cp.setColumn(ByteBufferUtil.bytes("name"));
-
- ColumnOrSuperColumn got = client.get(ByteBufferUtil.bytes(key_user_id), cp,
- ConsistencyLevel.ONE);
-
- // assert
- assertNotNull("Got a null ColumnOrSuperColumn", got);
- assertEquals("Ran", new String(got.getColumn().getValue(), "utf-8"));
- }
-
-
- /**
- * Gets a connection to the localhost client
- *
- * @return
- * @throws TTransportException
- */
- private Cassandra.Client getClient() throws TTransportException {
- TTransport tr = new TFramedTransport(new TSocket("localhost", 9170));
- TProtocol proto = new TBinaryProtocol(tr);
- Cassandra.Client client = new Cassandra.Client(proto);
- tr.open();
- return client;
- }
-}