mirror of https://github.com/apache/cassandra
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
This commit is contained in:
parent
509d6308c7
commit
ef6f0238ef
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -46,7 +46,6 @@ public class SSTableExport
|
|||
{
|
||||
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 @@ public class SSTableExport
|
|||
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 class SSTableExport
|
|||
*/
|
||||
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 class SSTableExport
|
|||
System.exit(1);
|
||||
}
|
||||
|
||||
String outFile = cmd.getOptionValue(OUTFILE_OPTION);
|
||||
|
||||
if (cmd.getArgs().length != 1)
|
||||
{
|
||||
|
|
@ -354,27 +345,13 @@ public class SSTableExport
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue