// Logger configuration: log to the console
BasicConfigurator.configure();
LOG.setLevel(Level.DEBUG);
SparrowFrontendClient client = new SparrowFrontendClient();
int schedulerPort = SchedulerThrift.DEFAULT_SCHEDULER_THRIFT_PORT;
client.initialize(new InetSocketAddress("localhost", schedulerPort), APPLICATION_ID, this);
// Generate list of tasks.
ByteBuffer message = ByteBuffer.allocate(8);
message.putInt(DEFAULT_TASK_BENCHMARK);
// Just one iteration!
message.putInt(1);
List<TTaskSpec> tasks = new ArrayList<TTaskSpec>();
int numTasks = Integer.parseInt(args[0]);
LOG.info("Launching " + numTasks + " tasks");
for (int taskId = 0; taskId < numTasks; taskId++) {
TTaskSpec spec = new TTaskSpec();
spec.setTaskId(Integer.toString(taskId));
spec.setMessage(message.array());
tasks.add(spec);
}
TUserGroupInfo userInfo = new TUserGroupInfo("User", "*", 0);
while(true) {
client.submitJob(APPLICATION_ID, tasks, userInfo);
tasksLaunched.addAndGet(tasks.size());
LOG.info(tasksLaunched.get() + " tasks launched");
Thread.sleep(1000);
}