Permalink
Browse files

finish r/m of -f option. use log4j of WARN,stderr so that doesn't get…

… in the way of redirecting stdout.

patch by jbellis; reviewed by eevans for CASSANDRA-766

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@908652 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 509d630 commit ef6f0238ef5dbb439e85ee3c8988319c375e65df @jbellis jbellis committed Feb 10, 2010
View
4 bin/clustertool
@@ -50,6 +50,8 @@ case "`uname`" in
;;
esac
-$JAVA -cp $CLASSPATH org.apache.cassandra.tools.ClusterCmd $@
+$JAVA -cp $CLASSPATH \
+ -Dlog4j.configuration=log4j-tools.properties \
+ org.apache.cassandra.tools.ClusterCmd $@
# vi:ai sw=4 ts=4 tw=0 et
View
1 bin/json2sstable
@@ -44,6 +44,7 @@ if [ -z $CLASSPATH ]; then
fi
$JAVA -cp $CLASSPATH -Dstorage-config=$CASSANDRA_CONF \
+ -Dlog4j.configuration=log4j-tools.properties \
org.apache.cassandra.tools.SSTableImport "$@"
# vi:ai sw=4 ts=4 tw=0 et
View
1 bin/nodetool
@@ -56,6 +56,7 @@ case "`uname`" in
esac
$JAVA -cp $CLASSPATH -Dstorage-config=$CASSANDRA_CONF \
+ -Dlog4j.configuration=log4j-tools.properties \
org.apache.cassandra.tools.NodeCmd $@
# vi:ai sw=4 ts=4 tw=0 et
View
1 bin/sstable2json
@@ -45,6 +45,7 @@ if [ -z $CLASSPATH ]; then
fi
$JAVA -cp $CLASSPATH -Dstorage-config=$CASSANDRA_CONF \
+ -Dlog4j.configuration=log4j-tools.properties \
org.apache.cassandra.tools.SSTableExport "$@"
# vi:ai sw=4 ts=4 tw=0 et
View
1 bin/sstablekeys
@@ -49,6 +49,7 @@ if [ $# -eq "0" ]; then
fi
$JAVA -cp $CLASSPATH -Dstorage-config=$CASSANDRA_CONF \
+ -Dlog4j.configuration=log4j-tools.properties \
org.apache.cassandra.tools.SSTableExport "$1" -e
# vi:ai sw=4 ts=4 tw=0 et
View
27 conf/log4j-tools.properties
@@ -0,0 +1,27 @@
+# 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.
+
+# for production, you should probably set the root to INFO
+# and the pattern to %c instead of %l. (%l is slower.)
+
+# output messages into a rolling log file as well as stdout
+log4j.rootLogger=WARN,stderr
+
+# stderr
+log4j.appender.stderr=org.apache.log4j.ConsoleAppender
+log4j.appender.stderr.target=System.err
+log4j.appender.stderr.layout=org.apache.log4j.PatternLayout
+log4j.appender.stderr.layout.ConversionPattern=%5p %d{HH:mm:ss,SSS} %m%n
View
41 src/java/org/apache/cassandra/tools/SSTableExport.java
@@ -46,7 +46,6 @@
{
private static int INPUT_FILE_BUFFER_SIZE = 8 * 1024 * 1024;
- private static final String OUTFILE_OPTION = "f";
private static final String KEY_OPTION = "k";
private static final String ENUMERATEKEYS_OPTION = "e";
private static Options options;
@@ -55,19 +54,13 @@
static
{
options = new Options();
- Option optOutfile = new Option(OUTFILE_OPTION, true, "output file");
- optOutfile.setRequired(false);
- options.addOption(optOutfile);
-
+
Option optKey = new Option(KEY_OPTION, true, "Row key");
// Number of times -k <key> can be passed on the command line.
optKey.setArgs(500);
- optKey.setRequired(false);
options.addOption(optKey);
- options = new Options();
Option optEnumerate = new Option(ENUMERATEKEYS_OPTION, false, "enumerate keys only");
- optOutfile.setRequired(false);
options.addOption(optEnumerate);
}
@@ -327,8 +320,7 @@ public static void export(String ssTableFile) throws IOException
*/
public static void main(String[] args) throws IOException
{
- String usage = String.format("Usage: %s [-f outfile] <sstable> [-k key [-k key [...]]]%n",
- SSTableExport.class.getName());
+ String usage = String.format("Usage: %s <sstable> [-k key [-k key [...]]]%n", SSTableExport.class.getName());
CommandLineParser parser = new PosixParser();
try
@@ -341,7 +333,6 @@ public static void main(String[] args) throws IOException
System.exit(1);
}
- String outFile = cmd.getOptionValue(OUTFILE_OPTION);
if (cmd.getArgs().length != 1)
{
@@ -354,27 +345,13 @@ public static void main(String[] args) throws IOException
String[] keys = cmd.getOptionValues(KEY_OPTION);
String ssTableFileName = new File(cmd.getArgs()[0]).getAbsolutePath();
- if (outFile != null)
- {
- if (cmd.hasOption(ENUMERATEKEYS_OPTION))
- enumeratekeys(ssTableFileName, outFile);
- else {
- if ((keys != null) && (keys.length > 0))
- export(ssTableFileName, outFile, keys);
- else
- export(ssTableFileName, outFile);
- }
- }
- else
- {
- if (cmd.hasOption(ENUMERATEKEYS_OPTION))
- enumeratekeys(ssTableFileName, System.out);
- else {
- if ((keys != null) && (keys.length > 0))
- export(ssTableFileName, System.out, keys);
- else
- export(ssTableFileName);
- }
+ if (cmd.hasOption(ENUMERATEKEYS_OPTION))
+ enumeratekeys(ssTableFileName, System.out);
+ else {
+ if ((keys != null) && (keys.length > 0))
+ export(ssTableFileName, System.out, keys);
+ else
+ export(ssTableFileName);
}
System.exit(0);
}

0 comments on commit ef6f023

Please sign in to comment.