private ReduceAnswerMessage WorkReduceMessage(ReduceMessage message) { ReduceAnswerMessage ram = new ReduceAnswerMessage(); try { Assembly assembly = Assembly.Load(message.ReduceDLL); var type = typeof(IReduce); var types = assembly.GetTypes().Where(x => type.IsAssignableFrom(x)).ToArray(); IReduce instanceOfMyType = (IReduce)Activator.CreateInstance(types[0]); MappedAnswer[] answer = instanceOfMyType.Reduce(message.Data); if (message.Data[0].isFromMapPart) { foreach (var item in answer) { item.isFromMapPart = true; } } ram.ReduceID = message.ReduceID; ram.TaskNumber = message.TaskID; ram.Port = message.Port; ram.ReturnIP = message.ReturnIP; ram.Result = answer; } catch(Exception ex) { Console.WriteLine(ex.Message); } finally { this.Message = null; } return ram; }
private void CreateAndSendMessage(MappedAnswer[] ma, TaskInfoCurrentlyWorking ticw, Routing Route) { ReduceMessage rm = new ReduceMessage(); rm.Port = ManagerActor.LocalPort; rm.ReduceDLL = ticw.WorkDLL; rm.TaskID = ticw.ID; rm.Data = ma; rm.ReduceID = ma[0].ReduceKey; new NetworkResponseActor(rm, Route.Port, Route.IP).Start(); }