public static void main(String[] args) {
try {
log.info("GridNode Starting...");
StopWatch sw = new StopWatch();
sw.start();
GridNode node = Grid.startLightGridNode();
log.info("GridNode ID : " + node.getId());
sw.stop();
log.info("GridNode Started Up. [" + sw.getLastTaskTimeMillis()
+ " ms]");
// Create App Instance
final MandelbrotApp app = new MandelbrotApp(node);
app.requestFocus();
// Create Mandelbrot Job
MandelbrotJob mandelbrotJob = new MandelbrotJob(app.getWidth(), app
.getHeight());
// Start Job Submission
sw.start();
GridJobFuture future = node.getJobSubmissionService()
.submitJob(mandelbrotJob, new ResultCallback() {
public void onResult(Serializable result) {
MandelbrotResult mResult = (MandelbrotResult) result;
app.displayResult(mResult);
app.setProgress(app.getProgress()
+ mResult.getLines());
}
});
app.setFuture(future);
// Block till job finishes
future.getResult();
app.setDone(true);
sw.stop();
log.info("GridJob Finished. Duration " + sw.getLastTaskTimeMillis()
+ " ms");
log.debug("Press any key to unregister GridNode and terminate");
System.in.read();
node.getNodeRegistrationService().unregister();