Author: jbellis
Date: Wed Feb 10 19:53:56 2010
New Revision: 908652

URL: http://svn.apache.org/viewvc?rev=908652&view=rev
Log:
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

Added:
    incubator/cassandra/trunk/conf/log4j-tools.properties   (with props)
Modified:
    incubator/cassandra/trunk/bin/clustertool
    incubator/cassandra/trunk/bin/json2sstable
    incubator/cassandra/trunk/bin/nodetool
    incubator/cassandra/trunk/bin/sstable2json
    incubator/cassandra/trunk/bin/sstablekeys
    
incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/SSTableExport.java

Modified: incubator/cassandra/trunk/bin/clustertool
URL: 
http://svn.apache.org/viewvc/incubator/cassandra/trunk/bin/clustertool?rev=908652&r1=908651&r2=908652&view=diff
==============================================================================
--- incubator/cassandra/trunk/bin/clustertool (original)
+++ incubator/cassandra/trunk/bin/clustertool Wed Feb 10 19:53:56 2010
@@ -50,6 +50,8 @@
     ;;
 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

Modified: incubator/cassandra/trunk/bin/json2sstable
URL: 
http://svn.apache.org/viewvc/incubator/cassandra/trunk/bin/json2sstable?rev=908652&r1=908651&r2=908652&view=diff
==============================================================================
--- incubator/cassandra/trunk/bin/json2sstable (original)
+++ incubator/cassandra/trunk/bin/json2sstable Wed Feb 10 19:53:56 2010
@@ -44,6 +44,7 @@
 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

Modified: incubator/cassandra/trunk/bin/nodetool
URL: 
http://svn.apache.org/viewvc/incubator/cassandra/trunk/bin/nodetool?rev=908652&r1=908651&r2=908652&view=diff
==============================================================================
--- incubator/cassandra/trunk/bin/nodetool (original)
+++ incubator/cassandra/trunk/bin/nodetool Wed Feb 10 19:53:56 2010
@@ -56,6 +56,7 @@
 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

Modified: incubator/cassandra/trunk/bin/sstable2json
URL: 
http://svn.apache.org/viewvc/incubator/cassandra/trunk/bin/sstable2json?rev=908652&r1=908651&r2=908652&view=diff
==============================================================================
--- incubator/cassandra/trunk/bin/sstable2json (original)
+++ incubator/cassandra/trunk/bin/sstable2json Wed Feb 10 19:53:56 2010
@@ -45,6 +45,7 @@
 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

Modified: incubator/cassandra/trunk/bin/sstablekeys
URL: 
http://svn.apache.org/viewvc/incubator/cassandra/trunk/bin/sstablekeys?rev=908652&r1=908651&r2=908652&view=diff
==============================================================================
--- incubator/cassandra/trunk/bin/sstablekeys (original)
+++ incubator/cassandra/trunk/bin/sstablekeys Wed Feb 10 19:53:56 2010
@@ -49,6 +49,7 @@
 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

Added: incubator/cassandra/trunk/conf/log4j-tools.properties
URL: 
http://svn.apache.org/viewvc/incubator/cassandra/trunk/conf/log4j-tools.properties?rev=908652&view=auto
==============================================================================
--- incubator/cassandra/trunk/conf/log4j-tools.properties (added)
+++ incubator/cassandra/trunk/conf/log4j-tools.properties Wed Feb 10 19:53:56 
2010
@@ -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

Propchange: incubator/cassandra/trunk/conf/log4j-tools.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/SSTableExport.java
URL: 
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/SSTableExport.java?rev=908652&r1=908651&r2=908652&view=diff
==============================================================================
--- 
incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/SSTableExport.java
 (original)
+++ 
incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/SSTableExport.java
 Wed Feb 10 19:53:56 2010
@@ -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 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 @@
             System.exit(1);
         }
         
-        String outFile = cmd.getOptionValue(OUTFILE_OPTION);
 
         if (cmd.getArgs().length != 1)
         {
@@ -354,27 +345,13 @@
         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);
     }


Reply via email to