public static void main ( String [ ] args ) throws ParseException , ConfigurationException { CommandLineParser parser = new PosixParser ( ) ; try { cmd = parser . parse ( options , args ) ; } catch ( org . apache . commons . cli . ParseException e ) { System . err . println ( e . getMessage ( ) ) ; printProgramUsage ( ) ; System . exit ( 1 ) ; } if ( cmd . getArgs ( ) . length != 2 ) { printProgramUsage ( ) ; System . exit ( 1 ) ; } String json = cmd . getArgs ( ) [ 0 ] ; String ssTable = cmd . getArgs ( ) [ 1 ] ; String keyspace = cmd . getOptionValue ( KEYSPACE_OPTION ) ; String cfamily = cmd . getOptionValue ( COLUMN_FAMILY_OPTION ) ; Integer keyCountToImport = null ; boolean isSorted = false ; if ( cmd . hasOption ( KEY_COUNT_OPTION ) ) { keyCountToImport = Integer . valueOf ( cmd . getOptionValue ( KEY_COUNT_OPTION ) ) ; } if ( cmd . hasOption ( IS_SORTED_OPTION ) ) { isSorted = true ; } DatabaseDescriptor . loadSchemas ( false ) ; if ( Schema . instance . getNonSystemKeyspaces ( ) . size ( ) < 1 ) { String msg = "no non-system keyspaces are defined" ; System . err . println ( msg ) ; throw new ConfigurationException ( msg ) ; } try { new SSTableImport ( keyCountToImport , isSorted ) . importJson ( json , keyspace , cfamily , ssTable ) ; } catch ( Exception e ) { JVMStabilityInspector . inspectThrowable ( e ) ; e . printStackTrace ( ) ; System . err . println ( "ERROR: " + e . getMessage ( ) ) ; System . exit ( - 1 ) ; } System . exit ( 0 ) ; }
Converts JSON to an SSTable file . JSON input can either be a file specified using an optional command line argument or supplied on standard in .