...
The below example logs INFO level messages by adding line: LOG.info(peer.getPeerName() + ": Logging test: " + data);
within bsp() method of PiEstimator example.
Code Block | ||
---|---|---|
| ||
public static class MyEstimator extends
BSP<NullWritable, NullWritable, Text, DoubleWritable, DoubleWritable> {
...
public static final Log LOG = LogFactory.getLog(MyEstimator.class);
...
@Override
public void bsp(
BSPPeer<NullWritable, NullWritable, Text, DoubleWritable, DoubleWritable> peer)
throws IOException, SyncException, InterruptedException {
int in = 0;
for (int i = 0; i < iterations; i++) {
double x = 2.0 * Math.random() - 1.0, y = 2.0 * Math.random() - 1.0;
if ((Math.sqrt(x * x + y * y) < 1.0)) {
in++;
}
}
double data = 4.0 * in / iterations;
LOG.info(peer.getPeerName() + ": Logging test: " + data);
peer.send(masterTask, new DoubleWritable(data));
peer.sync();
}
|
...