com.martiansoftware.jsap.FlaggedOption Java Examples

The following examples show how to use com.martiansoftware.jsap.FlaggedOption. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BranchLauncher.java    From repairnator with MIT License 6 votes vote down vote up
public static JSAP defineBasicArgs() throws JSAPException {
	JSAP jsap = new JSAP();

	FlaggedOption opt2 = new FlaggedOption("launcherMode");
       opt2.setShortFlag('l');
       opt2.setLongFlag("launcherMode");
       opt2.setStringParser(JSAP.STRING_PARSER);
       opt2.setDefault(LauncherMode.REPAIR.name());
       opt2.setHelp("specify launcherMode." 
       	+ "REPAIR: standard repairnator repair with Travis build ids. BEARS: analyze pairs of bugs and human-produced patches. "
       	+ "CHECKSTYLE: analyze build failing because of checkstyle. "
       	+ "GIT_REPOSITORY: repairnator repair with Git instead of standard Travis. "
       	+ "KUBERNETES_LISTENER: run repairnator as a Activemq server listening for Travis build ids. ");
       jsap.registerParameter(opt2);

       return jsap;
}
 
Example #2
Source File: TestPipeline.java    From repairnator with MIT License 6 votes vote down vote up
@Test
public void testPipelineArgs() throws Exception {
    Launcher launcher = new Launcher();
    // the default repair tool
    assertEquals(1, ((FlaggedOption)launcher.defineArgs().getByLongFlag("repairTools")).getDefault().length);
    assertEquals("NPEFix", ((FlaggedOption)launcher.defineArgs().getByLongFlag("repairTools")).getDefault()[0]);

    // by default the activemq username and password should be blank
    assertEquals("", ((FlaggedOption)launcher.defineArgs().getByLongFlag("activemqusername")).getDefault()[0]);
    assertEquals("", ((FlaggedOption)launcher.defineArgs().getByLongFlag("activemqpassword")).getDefault()[0]);

    // non default value is accepted
    assertEquals("NopolAllTests", ((FlaggedOption)launcher.defineArgs().getByLongFlag("repairTools")).getStringParser().parse("NopolAllTests"));

    // incorrect values are rejected
    try {
        ((FlaggedOption)launcher.defineArgs().getByLongFlag("repairTools")).getStringParser().parse("garbage");
        fail();
    } catch (Exception expected) {}

}
 
Example #3
Source File: TestPipelinebTravisMode.java    From repairnator with MIT License 6 votes vote down vote up
@Test
public void testPipelineArgs() throws Exception {
    JSAP defaultJsap = (new DefaultDefineJSAPArgs()).defineArgs();

    // the default repair tool
    assertEquals(1, ((FlaggedOption)defaultJsap.getByLongFlag("repairTools")).getDefault().length);
    assertEquals("NPEFix", ((FlaggedOption)defaultJsap.getByLongFlag("repairTools")).getDefault()[0]);

    // by default the activemq username and password should be blank
    assertEquals("", ((FlaggedOption)defaultJsap.getByLongFlag("activemqusername")).getDefault()[0]);
    assertEquals("", ((FlaggedOption)defaultJsap.getByLongFlag("activemqpassword")).getDefault()[0]);

    // non default value is accepted
    assertEquals("NopolAllTests", ((FlaggedOption)defaultJsap.getByLongFlag("repairTools")).getStringParser().parse("NopolAllTests"));

    // incorrect values are rejected
    try {
        ((FlaggedOption)defaultJsap.getByLongFlag("repairTools")).getStringParser().parse("garbage");
        fail();
    } catch (Exception expected) {}

}
 
Example #4
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgGithubUserName() {
    FlaggedOption opt = new FlaggedOption("githubUserName");
    opt.setLongFlag("githubUserName");
    opt.setDefault("repairnator");
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setHelp("Specify the name of the user who commits");
    return opt;
}
 
Example #5
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgSmtpServer() {
    FlaggedOption opt = new FlaggedOption("smtpServer");
    opt.setLongFlag("smtpServer");
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setHelp("Specify SMTP server to use for Email notification");
    return opt;
}
 
Example #6
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgSmtpPort() {
    FlaggedOption opt = new FlaggedOption("smtpPort");
    opt.setLongFlag("smtpPort");
    opt.setStringParser(JSAP.INTEGER_PARSER);
    opt.setDefault("25");
    opt.setHelp("The port on which to contact the SMTP server. Default 25");
    return opt;
}
 
Example #7
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgSmtpUsername() {
    FlaggedOption opt = new FlaggedOption("smtpUsername");
    opt.setLongFlag("smtpUsername");
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setHelp("Username for authorized server");
    return opt;
}
 
Example #8
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgSmtpPassword() {
    FlaggedOption opt = new FlaggedOption("smtpPassword");
    opt.setLongFlag("smtpPassword");
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setHelp("Password for authorized server");
    return opt;
}
 
Example #9
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgNotifyto() {
    FlaggedOption opt = new FlaggedOption("notifyto");
    opt.setLongFlag("notifyto");
    opt.setList(true);
    opt.setListSeparator(',');
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setHelp("Specify email addresses to notify");
    return opt;
}
 
Example #10
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgNbThreads() {
    FlaggedOption opt = new FlaggedOption("threads");
    opt.setShortFlag('t');
    opt.setLongFlag("threads");
    opt.setStringParser(JSAP.INTEGER_PARSER);
    opt.setDefault("1");
    opt.setHelp("Specify the number of threads to run in parallel");
    return opt;
}
 
Example #11
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgGlobalTimeout() {
    FlaggedOption opt = new FlaggedOption("globalTimeout");
    opt.setShortFlag('g');
    opt.setLongFlag("globalTimeout");
    opt.setStringParser(JSAP.INTEGER_PARSER);
    opt.setDefault("1");
    opt.setHelp("Specify the number of day before killing the whole pool.");
    return opt;
}
 
Example #12
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgPushUrl() {
    FlaggedOption opt = new FlaggedOption("pushUrl");
    opt.setLongFlag("pushurl");
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setHelp("Specify repository URL to push data on the format https://github.com/user/repo.");
    return opt;
}
 
Example #13
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgDockerImageName() {
    FlaggedOption opt = new FlaggedOption("imageName");
    opt.setShortFlag('n');
    opt.setLongFlag("name");
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setDefault("repairnator/pipeline:latest");
    opt.setHelp("Specify the docker image name to use.");
    return opt;
}
 
Example #14
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgGithubOAuth() {
    FlaggedOption opt = new FlaggedOption("ghOauth");
    opt.setLongFlag("ghOauth");
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setDefault(System.getenv("GITHUB_OAUTH"));
    opt.setHelp("Specify Github Token to use");
    return opt;
}
 
Example #15
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgMongoDBHost() {
    FlaggedOption opt = new FlaggedOption("mongoDBHost");
    opt.setLongFlag("dbhost");
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setHelp("Specify mongodb host.");
    return opt;
}
 
Example #16
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgGithubUserEmail() {
    FlaggedOption opt = new FlaggedOption("githubUserEmail");
    opt.setLongFlag("githubUserEmail");
    opt.setDefault("[email protected]");
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setHelp("Specify the email of the user who commits");
    return opt;
}
 
Example #17
Source File: ShiftAddXorSignedStringMap.java    From database with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static void main( final String[] arg ) throws NoSuchMethodException, IOException, JSAPException, ClassNotFoundException {

	final SimpleJSAP jsap = new SimpleJSAP( ShiftAddXorSignedStringMap.class.getName(), "Builds a shift-add-xor signed string map by reading a newline-separated list of strings and a function built on the same list of strings.",
			new Parameter[] {
		new FlaggedOption( "bufferSize", JSAP.INTSIZE_PARSER, "64Ki", JSAP.NOT_REQUIRED, 'b',  "buffer-size", "The size of the I/O buffer used to read strings." ),
		new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The string file encoding." ),
		new Switch( "zipped", 'z', "zipped", "The string list is compressed in gzip format." ),
		new FlaggedOption( "width", JSAP.INTEGER_PARSER, Integer.toString( Integer.SIZE ), JSAP.NOT_REQUIRED, 'w', "width", "The signature width in bits." ),
		new UnflaggedOption( "function", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the function to be signed." ),
		new UnflaggedOption( "map", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the resulting serialised signed string map." ),
		new UnflaggedOption( "stringFile", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, JSAP.NOT_GREEDY, "Read strings from this file instead of standard input." ),
	});

	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) return;

	final int bufferSize = jsapResult.getInt( "bufferSize" );
	final String functionName = jsapResult.getString( "function" );
	final String mapName = jsapResult.getString( "map" );
	final String stringFile = jsapResult.getString( "stringFile" );
	final Charset encoding = (Charset)jsapResult.getObject( "encoding" );
	final int width = jsapResult.getInt( "width" );
	final boolean zipped = jsapResult.getBoolean( "zipped" );

	final InputStream inputStream = stringFile != null ? new FileInputStream( stringFile ) : System.in;
	final Iterator<MutableString> iterator = new LineIterator( new FastBufferedReader( new InputStreamReader( zipped ? new GZIPInputStream( inputStream ) : inputStream, encoding ), bufferSize ) );
	final Object2LongFunction<CharSequence> function = (Object2LongFunction<CharSequence>)BinIO.loadObject( functionName );
	LOGGER.info( "Signing..." );
	BinIO.storeObject( new ShiftAddXorSignedStringMap( iterator, function, width ), mapName );
	LOGGER.info( "Completed." );
}
 
Example #18
Source File: FrontCodedStringList.java    From database with GNU General Public License v2.0 5 votes vote down vote up
public static void main( final String[] arg ) throws IOException, JSAPException, NoSuchMethodException {
	
	final SimpleJSAP jsap = new SimpleJSAP( FrontCodedStringList.class.getName(), "Builds a front-coded string list reading from standard input a newline-separated ordered list of terms.",
			new Parameter[] {
				new FlaggedOption( "bufferSize", IntSizeStringParser.getParser(), "64Ki", JSAP.NOT_REQUIRED, 'b',  "buffer-size", "The size of the I/O buffer used to read terms." ),
				new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term file encoding." ),
				new FlaggedOption( "ratio", IntSizeStringParser.getParser(), "4", JSAP.NOT_REQUIRED, 'r',  "ratio", "The compression ratio." ),
				new Switch( "utf8", 'u', "utf8", "Store the strings as UTF-8 byte arrays." ),
				new Switch( "zipped", 'z', "zipped", "The term list is compressed in gzip format." ),
				new UnflaggedOption( "frontCodedList", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised front-coded list." )
	});
	
	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) return;
	
	final int bufferSize = jsapResult.getInt( "bufferSize" );
	final int ratio = jsapResult.getInt( "ratio" );
	final boolean utf8 = jsapResult.getBoolean( "utf8" );
	final boolean zipped = jsapResult.getBoolean( "zipped" );
	final String listName = jsapResult.getString( "frontCodedList" );
	final Charset encoding = (Charset)jsapResult.getObject( "encoding" );
	
	final ProgressLogger pl = new ProgressLogger();
	pl.itemsName = "words";
	pl.start( "Reading words..." );
	final FrontCodedStringList frontCodedStringList = new FrontCodedStringList( new LineIterator( new FastBufferedReader( 
			new InputStreamReader( zipped ? new GZIPInputStream( System.in ) : System.in, encoding ), bufferSize ), pl ), ratio, utf8 );
	pl.done();

	System.err.print( "Writing to file..." );
	BinIO.storeObject( frontCodedStringList, listName );
	System.err.println( " done." );
}
 
Example #19
Source File: TernaryIntervalSearchTree.java    From database with GNU General Public License v2.0 5 votes vote down vote up
public static void main( final String[] arg ) throws IOException, JSAPException, NoSuchMethodException {

		final SimpleJSAP jsap = new SimpleJSAP( TernaryIntervalSearchTree.class.getName(), "Builds a ternary interval search tree reading from standard input a newline-separated list of terms.",
			new Parameter[] {
				new FlaggedOption( "bufferSize", JSAP.INTSIZE_PARSER, "64Ki", JSAP.NOT_REQUIRED, 'b',  "buffer-size", "The size of the I/O buffer used to read terms." ),
				new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term file encoding." ),
				new UnflaggedOption( "tree", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised tree." )
		});

		JSAPResult jsapResult = jsap.parse( arg );
		if ( jsap.messagePrinted() ) return;

		final TernaryIntervalSearchTree tree = new TernaryIntervalSearchTree();
		
		MutableString term = new MutableString();
		final ProgressLogger pl = new ProgressLogger();
		pl.itemsName = "terms";
		final FastBufferedReader terms = new FastBufferedReader( new InputStreamReader( System.in, (Charset)jsapResult.getObject( "encoding" ) ), jsapResult.getInt( "bufferSize" ) );
				
		pl.start( "Reading terms..." );

		while( terms.readLine( term ) != null ) {
			pl.update();
			tree.add( term );
		}

		pl.done();

		BinIO.storeObject( tree, jsapResult.getString( "tree" ) );
	}
 
Example #20
Source File: LiterallySignedStringMap.java    From database with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static void main( final String[] arg ) throws IOException, JSAPException, ClassNotFoundException, SecurityException, NoSuchMethodException {

	final SimpleJSAP jsap = new SimpleJSAP( LiterallySignedStringMap.class.getName(), "Builds a shift-add-xor signed string map by reading a newline-separated list of strings and a function built on the same list of strings.",
			new Parameter[] {
		new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The string file encoding." ),
		new Switch( "zipped", 'z', "zipped", "The string list is compressed in gzip format." ),
		new Switch( "text", 't', "text", "The string list actually a text file, with one string per line." ),
		new UnflaggedOption( "function", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the function to be signed." ),
		new UnflaggedOption( "list", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the serialised list of strings, or of a text file containing a list of strings, if -t is specified." ),
		new UnflaggedOption( "map", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename of the resulting map." ),
	});

	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) return;

	final String functionName = jsapResult.getString( "function" );
	final String listName = jsapResult.getString( "list" );
	final String mapName = jsapResult.getString( "map" );

	
	final Charset encoding = (Charset)jsapResult.getObject( "encoding" );
	final boolean zipped = jsapResult.getBoolean( "zipped" );
	final boolean text = jsapResult.getBoolean( "text" );
	
	ObjectList<MutableString> list = text ? new FileLinesCollection( listName, encoding.toString(), zipped ).allLines() : (ObjectList)BinIO.loadObject( listName );
	
	LOGGER.info( "Signing..." );
	BinIO.storeObject( new LiterallySignedStringMap( (Object2LongFunction)BinIO.loadObject( functionName ), list ), mapName );
	LOGGER.info( "Completed." );
}
 
Example #21
Source File: BloomFilter.java    From database with GNU General Public License v2.0 5 votes vote down vote up
public static void main( final String[] arg ) throws IOException, JSAPException, NoSuchMethodException {
	
	final SimpleJSAP jsap = new SimpleJSAP( BloomFilter.class.getName(), "Creates a Bloom filter reading from standard input a newline-separated list of terms.",
			new Parameter[] {
				new FlaggedOption( "bufferSize", IntSizeStringParser.getParser(), "64Ki", JSAP.NOT_REQUIRED, 'b',  "buffer-size", "The size of the I/O buffer used to read terms." ),
				new FlaggedOption( "encoding", ForNameStringParser.getParser( Charset.class ), "UTF-8", JSAP.NOT_REQUIRED, 'e', "encoding", "The term file encoding." ),
				new UnflaggedOption( "bloomFilter", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The filename for the serialised front-coded list." ),
				new UnflaggedOption( "size", JSAP.INTSIZE_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The size of the filter (i.e., the expected number of elements in the filter; usually, the number of terms)." ),
				new UnflaggedOption( "precision", JSAP.INTEGER_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, JSAP.NOT_GREEDY, "The precision of the filter." )
	});
	
	JSAPResult jsapResult = jsap.parse( arg );
	if ( jsap.messagePrinted() ) return;
	
	final int bufferSize = jsapResult.getInt( "bufferSize" );
	final String filterName = jsapResult.getString( "bloomFilter" );
	final Charset encoding = (Charset)jsapResult.getObject( "encoding" );

	BloomFilter filter = new BloomFilter( jsapResult.getInt( "size" ), jsapResult.getInt( "precision" ) );
	final ProgressLogger pl = new ProgressLogger();
	pl.itemsName = "terms";
	pl.start( "Reading terms..." );
	MutableString s = new MutableString();
	FastBufferedReader reader = new FastBufferedReader( new InputStreamReader( System.in, encoding ), bufferSize );
	while( reader.readLine( s ) != null ) { 
		filter.add( s );
		pl.lightUpdate();
	}
	pl.done();

	BinIO.storeObject( filter, filterName );
}
 
Example #22
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgMongoDBName() {
    FlaggedOption opt = new FlaggedOption("mongoDBName");
    opt.setLongFlag("dbname");
    opt.setDefault("repairnator");
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setHelp("Specify mongodb DB name.");
    return opt;
}
 
Example #23
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgOutput(LauncherType launcherType, String helpMessage) {
    FlaggedOption opt = new FlaggedOption("output");
    opt.setShortFlag('o');
    opt.setLongFlag("output");
    // we don't assume the presence of "/tmp" (eg on windows) and the it is writable
    opt.setDefault("./repairnator-output");
    if (launcherType == LauncherType.DOCKERPOOL || launcherType == LauncherType.CHECKBRANCHES) {
        opt.setRequired(true);
    }

    opt.setHelp(helpMessage);

    return opt;
}
 
Example #24
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgBranchInput() {
    /* ./branches.txt contain one branch per line
        typically from https://github.com/Spirals-Team/librepair-experiments/
     */
    FlaggedOption opt = new FlaggedOption("input");
    opt.setShortFlag('i');
    opt.setLongFlag("input");
    opt.setDefault("./projects.txt");
    opt.setHelp("Specify the input file containing the list of branches to reproduce (one branch per line)");
    return opt;
}
 
Example #25
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgProjectInput() {
    /* ./projects.txt contain one slug per line

    INRIA/spoon
    rails/rails
    ....
     */
    FlaggedOption opt = new FlaggedOption("input");
    opt.setShortFlag('i');
    opt.setLongFlag("input");
    opt.setDefault("./projects.txt");
    opt.setHelp("Specify where to find the list of projects to scan.");
    return opt;
}
 
Example #26
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgInput() {
    /* ./builds.txt contain one build id per line

        346537408
        347223109
        348887356
        349620528
        351046304
        353774072
        358555930
        361311603
        368867994
        369727490
        369854684
        369859631
        370885458
        371144762
        371488143
        374841318
        376812142

        (this is the list from Expedition 2)
     */
    FlaggedOption opt = new FlaggedOption("input");
    opt.setShortFlag('i');
    opt.setLongFlag("input");
    opt.setDefault("./builds.txt");
    opt.setHelp("Specify the input file containing the list of build ids.");
    return opt;
}
 
Example #27
Source File: LauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgRunId() {
    FlaggedOption opt = new FlaggedOption("runId");
    opt.setLongFlag("runId");
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setDefault("1234");
    opt.setHelp("Specify the run id for this launch.");
    return opt;
}
 
Example #28
Source File: Agent.java    From BUbiNG with Apache License 2.0 5 votes vote down vote up
public static void main(final String arg[]) throws Exception {
	final SimpleJSAP jsap = new SimpleJSAP(Agent.class.getName(), "Starts a BUbiNG agent (note that you must enable JMX by means of the standard Java system properties).",
			new Parameter[] {
				new FlaggedOption("weight", JSAP.INTEGER_PARSER, "1", JSAP.NOT_REQUIRED, 'w', "weight", "The agent weight."),
				new FlaggedOption("group", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'g', "group", "The JGroups group identifier (must be the same for all cooperating agents)."),
				new FlaggedOption("jmxHost", JSAP.STRING_PARSER, InetAddress.getLocalHost().getHostAddress(), JSAP.REQUIRED, 'h', "jmx-host", "The IP address (possibly specified by a host name) that will be used to expose the JMX RMI connector to other agents."),
				new FlaggedOption("rootDir", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.NOT_REQUIRED, 'r', "root-dir", "The root directory."),
				new Switch("new", 'n', "new", "Start a new crawl"),
				new FlaggedOption("properties", JSAP.STRING_PARSER, JSAP.NO_DEFAULT, JSAP.REQUIRED, 'P', "properties", "The properties used to configure the agent."),
				new UnflaggedOption("name", JSAP.STRING_PARSER, JSAP.REQUIRED, "The agent name (an identifier that must be unique across the group).")
		});

		final JSAPResult jsapResult = jsap.parse(arg);
		if (jsap.messagePrinted()) System.exit(1);

		// JMX *must* be set up.
		final String portProperty = System.getProperty(JMX_REMOTE_PORT_SYSTEM_PROPERTY);
		if (portProperty == null) throw new IllegalArgumentException("You must specify a JMX service port using the property " + JMX_REMOTE_PORT_SYSTEM_PROPERTY);

		final String name = jsapResult.getString("name");
		final int weight = jsapResult.getInt("weight");
		final String group = jsapResult.getString("group");
		final String host = jsapResult.getString("jmxHost");
		final int port = Integer.parseInt(portProperty);

		final BaseConfiguration additional = new BaseConfiguration();
		additional.addProperty("name", name);
		additional.addProperty("group", group);
		additional.addProperty("weight", Integer.toString(weight));
		additional.addProperty("crawlIsNew", Boolean.valueOf(jsapResult.getBoolean("new")));
		if (jsapResult.userSpecified("rootDir")) additional.addProperty("rootDir", jsapResult.getString("rootDir"));

		new Agent(host, port, new RuntimeConfiguration(new StartupConfiguration(jsapResult.getString("properties"), additional)));
		System.exit(0); // Kills remaining FetchingThread instances, if any.
}
 
Example #29
Source File: GitRepositoryLauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgGitRepositoryIdCommit() {
    FlaggedOption opt = new FlaggedOption("gitRepositoryIdCommit");
    opt.setLongFlag("gitrepoidcommit");
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setHelp("Specify the commit id of the given repository (only in GIT_REPOSITORY mode).");
    return opt;
}
 
Example #30
Source File: GitRepositoryLauncherUtils.java    From repairnator with MIT License 5 votes vote down vote up
public static FlaggedOption defineArgGitRepositoryBranch() {
    FlaggedOption opt = new FlaggedOption("gitRepositoryBranch");
    opt.setLongFlag("gitrepobranch");
    opt.setStringParser(JSAP.STRING_PARSER);
    opt.setHelp("Specify a branch of the given repository (only in GIT_REPOSITORY mode)");
    return opt;
}