/** Starts the computation. */
public void Start()
{
//invoke map
try {
Channel map_res = new Channel(1);
map_res.CloseEvent += this.MapHandler;
if (LogEnabled)
{
ProtocolLog.Write(ProtocolLog.MapReduce,
String.Format("MapReduce: {0}, about to call Map", _node.Address));
}
_mr_task.Map(map_res, _mr_args.MapArg);
}
catch (Exception x) {
//Simulate the above except with the Exception enqueued
if (LogEnabled)
{
ProtocolLog.Write(ProtocolLog.MapReduce,
String.Format("MapReduce: {0}, Exception in Map: {1}", _node.Address, x));
}
HandleException(null, x);
}
if (_state.Done)
{
return;
}
/* Our local Map was not enough
* to finish the computation, look
* for children
*/
try {
Channel gentree_res = new Channel(1);
gentree_res.CloseEvent += this.GenTreeHandler;
if (LogEnabled)
{
ProtocolLog.Write(ProtocolLog.MapReduce,
String.Format("MapReduce: {0}, about to call GenerateTree", _node.Address));
}
_mr_task.GenerateTree(gentree_res, _mr_args);
}
catch (Exception x) {
if (LogEnabled)
{
ProtocolLog.Write(ProtocolLog.MapReduce,
String.Format("MapReduce: {0}, Exception in GenerateTree: {1}", _node.Address, x));
}
HandleException(null, x);
}
}