*/
public static void main(String[] args) throws Exception {
if (args.length == 0) {
args = new String[] { "7002", "7003" };
}
Protocol protocol = Protocol.parse("{\"protocol\": \"sleepy\", "
+ "\"messages\": { \"sleep\": {"
+ " \"request\": [{\"name\": \"millis\", \"type\": \"long\"}," +
"{\"name\": \"data\", \"type\": \"bytes\"}], "
+ " \"response\": \"null\"} } }");
Log.info("Using protocol: " + protocol.toString());
Responder r = new SleepyResponder(protocol);
StatsPlugin p = new StatsPlugin();
r.addRPCPlugin(p);
// Start Avro server
HttpServer avroServer = new HttpServer(r, Integer.parseInt(args[0]));
avroServer.start();
StatsServer ss = new StatsServer(p, 8080);
HttpTransceiver trans = new HttpTransceiver(
new URL("http://localhost:" + Integer.parseInt(args[0])));
GenericRequestor req = new GenericRequestor(protocol, trans);
while(true) {
Thread.sleep(1000);
GenericRecord params = new GenericData.Record(protocol.getMessages().get(
"sleep").getRequest());
Random rand = new Random();
params.put("millis", Math.abs(rand.nextLong()) % 1000);
int payloadSize = Math.abs(rand.nextInt()) % 10000;
byte[] payload = new byte[payloadSize];