mirror of https://github.com/apache/cassandra
have sstable import/export load schema from local storage. Patch by Matthew Dennis, reviewed by Gary Dusbabek. CASSANDRA-1128
git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@949167 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
101b210280
commit
dd02495654
|
|
@ -24,6 +24,7 @@ import java.io.PrintStream;
|
|||
import java.util.*;
|
||||
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.config.ConfigurationException;
|
||||
import org.apache.cassandra.db.ColumnFamily;
|
||||
import org.apache.cassandra.db.DecoratedKey;
|
||||
import org.apache.cassandra.db.IColumn;
|
||||
|
|
@ -339,7 +340,7 @@ public class SSTableExport
|
|||
* @param args command lines arguments
|
||||
* @throws IOException on failure to open/read/write files or output streams
|
||||
*/
|
||||
public static void main(String[] args) throws IOException
|
||||
public static void main(String[] args) throws IOException, ConfigurationException
|
||||
{
|
||||
String usage = String.format("Usage: %s <sstable> [-k key [-k key [...]] -x key [-x key [...]]]%n", SSTableExport.class.getName());
|
||||
|
||||
|
|
@ -366,7 +367,15 @@ public class SSTableExport
|
|||
String[] keys = cmd.getOptionValues(KEY_OPTION);
|
||||
String[] excludes = cmd.getOptionValues(EXCLUDEKEY_OPTION);
|
||||
String ssTableFileName = new File(cmd.getArgs()[0]).getAbsolutePath();
|
||||
|
||||
|
||||
DatabaseDescriptor.loadSchemas();
|
||||
if (DatabaseDescriptor.getNonSystemTables().size() < 1)
|
||||
{
|
||||
String msg = "no non-system tables are defined";
|
||||
System.err.println(msg);
|
||||
throw new ConfigurationException(msg);
|
||||
}
|
||||
|
||||
if (cmd.hasOption(ENUMERATEKEYS_OPTION))
|
||||
enumeratekeys(ssTableFileName, System.out);
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import java.io.IOException;
|
|||
import java.util.*;
|
||||
import org.apache.cassandra.config.CFMetaData;
|
||||
import org.apache.cassandra.config.DatabaseDescriptor;
|
||||
import org.apache.cassandra.config.ConfigurationException;
|
||||
import org.apache.cassandra.db.ColumnFamily;
|
||||
import org.apache.cassandra.db.DecoratedKey;
|
||||
import org.apache.cassandra.db.SuperColumn;
|
||||
|
|
@ -195,7 +196,7 @@ public class SSTableImport
|
|||
* @throws IOException on failure to open/read/write files or output streams
|
||||
* @throws ParseException on failure to parse JSON input
|
||||
*/
|
||||
public static void main(String[] args) throws IOException, ParseException
|
||||
public static void main(String[] args) throws IOException, ParseException, ConfigurationException
|
||||
{
|
||||
String usage = String.format("Usage: %s -K keyspace -c column_family <json> <sstable>%n",
|
||||
SSTableImport.class.getName());
|
||||
|
|
@ -222,6 +223,14 @@ public class SSTableImport
|
|||
String keyspace = cmd.getOptionValue(KEYSPACE_OPTION);
|
||||
String cfamily = cmd.getOptionValue(COLFAM_OPTION);
|
||||
|
||||
DatabaseDescriptor.loadSchemas();
|
||||
if (DatabaseDescriptor.getNonSystemTables().size() < 1)
|
||||
{
|
||||
String msg = "no non-system tables are defined";
|
||||
System.err.println(msg);
|
||||
throw new ConfigurationException(msg);
|
||||
}
|
||||
|
||||
importJson(json, keyspace, cfamily, ssTable);
|
||||
|
||||
System.exit(0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue