use of org.kohsuke.args4j.CmdLineParser in project opennms by OpenNMS.
the class ResourceCli method parseArguments.
public void parseArguments(final String[] args) {
// Parse the arguments
final CmdLineParser cmdLineParser = new CmdLineParser(this);
try {
cmdLineParser.parseArgument(args);
} catch (final CmdLineException e) {
System.err.println("Error: " + e.getMessage() + "\n");
displayHelp(cmdLineParser);
System.exit(-1);
}
// Display help message if "--help" was used
if (help) {
displayHelp(cmdLineParser);
System.exit(0);
}
}
use of org.kohsuke.args4j.CmdLineParser in project opennms by OpenNMS.
the class Init method execute.
@Override
public void execute() throws Exception {
if (showHelp) {
System.out.println("Usage: $OPENNMS_HOME/bin/newts init");
CmdLineParser parser = new CmdLineParser(new Init());
parser.printUsage(System.out);
return;
}
String keyspace = System.getProperty("org.opennms.newts.config.keyspace", "newts");
String hostname = System.getProperty("org.opennms.newts.config.hostname", "localhost");
int port = Integer.getInteger("org.opennms.newts.config.port", 9042);
String username = System.getProperty("org.opennms.newts.config.username");
String password = System.getProperty("org.opennms.newts.config.password");
boolean ssl = Boolean.getBoolean("org.opennms.newts.config.ssl");
System.out.println(String.format("Initializing the '%s' keyspaces on %s:%d", keyspace, hostname, port));
try (SchemaManager m = new SchemaManager(keyspace, hostname, port, username, password, ssl)) {
m.setReplicationFactor(replicationFactor);
for (Schema s : s_schemas) {
m.create(s, true, printOnly);
}
}
if (!printOnly) {
System.out.println("The keyspace was succesfully created.");
}
}
use of org.kohsuke.args4j.CmdLineParser in project gerrit by GerritCodeReview.
the class DocIndexer method invoke.
private void invoke(String... parameters) throws IOException {
CmdLineParser parser = new CmdLineParser(this);
try {
parser.parseArgument(parameters);
if (inputFiles.isEmpty()) {
throw new CmdLineException(parser, "FAILED: input file missing");
}
} catch (CmdLineException e) {
System.err.println(e.getMessage());
parser.printUsage(System.err);
System.exit(1);
return;
}
try (JarOutputStream jar = new JarOutputStream(Files.newOutputStream(Paths.get(outFile)))) {
byte[] compressedIndex = zip(index());
JarEntry entry = new JarEntry(String.format("%s/%s", Constants.PACKAGE, Constants.INDEX_ZIP));
entry.setSize(compressedIndex.length);
jar.putNextEntry(entry);
jar.write(compressedIndex);
jar.closeEntry();
}
}
use of org.kohsuke.args4j.CmdLineParser in project asterixdb by apache.
the class AsterixCLI method main.
public static void main(String[] args) throws Exception {
Options options = new Options();
CmdLineParser parser = new CmdLineParser(options);
parser.parseArgument(args);
ILangCompilationProvider compilationProvider = new AqlCompilationProvider();
setUp(options);
try {
for (String queryFile : options.args) {
Reader in = new FileReader(queryFile);
AsterixJavaClient ajc = new AsterixJavaClient((ICcApplicationContext) integrationUtil.cc.getApplicationContext(), integrationUtil.getHyracksClientConnection(), in, compilationProvider, new DefaultStatementExecutorFactory(), new StorageComponentProvider());
try {
ajc.compile(true, false, false, false, false, true, false);
} finally {
in.close();
}
ajc.execute();
}
} finally {
tearDown();
}
System.exit(0);
}
use of org.kohsuke.args4j.CmdLineParser in project asterixdb by apache.
the class SyntheticDataGeneratorForSpatialIndexEvaluation method main.
public static void main(String[] args) throws Exception {
SyntheticDataGeneratorConfig config = new SyntheticDataGeneratorConfig();
CmdLineParser clp = new CmdLineParser(config);
try {
clp.parseArgument(args);
} catch (CmdLineException e) {
System.err.println(e.getMessage());
clp.printUsage(System.err);
System.exit(1);
}
//prepare data generator
GULongIDGenerator uidGenerator = new GULongIDGenerator(config.getPartitionId(), (byte) (0));
String pointSourceFilePath = config.getPointSourceFile();
int pointSampleInterval = config.getpointSamplingInterval();
DataGeneratorForSpatialIndexEvaluation dataGenerator = new DataGeneratorForSpatialIndexEvaluation(new InitializationInfo(), pointSourceFilePath, pointSampleInterval);
//get record count to be generated
long maxRecordCount = config.getRecordCount();
long recordCount = 0;
//prepare timer
long startTS = System.currentTimeMillis();
//prepare tweetIterator which acutally generates tweet
TweetMessageIterator tweetIterator = dataGenerator.new TweetMessageIterator(0, uidGenerator);
FileOutputStream fos = null;
try {
//prepare output file
fos = openOutputFile(config.getOutputFilePath());
while (recordCount < maxRecordCount) {
//get a tweet and append newline at the end
String tweet = tweetIterator.next().toString() + "\n";
//write to file
fos.write(tweet.getBytes());
recordCount++;
if (recordCount % 1000000 == 0) {
System.out.println("... generated " + recordCount + " records");
}
}
System.out.println("Done: generated " + recordCount + " records in " + ((System.currentTimeMillis() - startTS) / 1000) + " in seconds!");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
closeOutputFile(fos);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Aggregations