-
-
Save jasonbronson/0a40ba698ae9bfd5d26d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package crawler_worker; | |
import java.io.IOException; | |
import org.gearman.*; | |
import org.gearman.impl.*; | |
import crawler_worker.WorkerClient; | |
public class Main { | |
public static void main(String[] args) { | |
if (args.length == 0 || args.length > 3) { | |
usage(); | |
return; | |
} | |
String host = Constants.GEARMAN_DEFAULT_TCP_HOST; | |
int port = Constants.GEARMAN_DEFAULT_TCP_PORT; | |
String payload = args[args.length - 1]; | |
for (String arg : args) { | |
if (arg.startsWith("-h")) { | |
host = arg.substring(2); | |
} else if (arg.startsWith("-p")) { | |
port = Integer.parseInt(arg.substring(2)); | |
} | |
} | |
GearmanFunctionTest gearmanFunctionTest = new GearmanFunctionTest(); | |
try { | |
WorkerClient worker; | |
worker = new WorkerClient(host, port, "testPayload", gearmanFunctionTest ); | |
System.out.println(worker.testPayload(payload)); | |
worker.shutdown(); | |
} catch (IOException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} | |
} | |
public static void usage() { | |
String[] usage = { | |
"usage: org.gearman.example.ReverseClient [-h<host>] [-p<port>] " + | |
"<string>", | |
"\t-h<host> - job server host", | |
"\t-p<port> - job server port", | |
"\n\tExample: java org.gearman.example.ReverseClient Foo", | |
"\tExample: java org.gearman.example.ReverseClient -h127.0.0.1 " + | |
"-p4730 Bar", // | |
}; | |
for (String line : usage) { | |
System.err.println(line); //NOPMD | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment