internal override void PerformAction(Scheduling.Scheduler.WorkItem workItem) { var epoch = new Epoch().InitializeFrom(workItem.Requirement, 1).t; for (int i = nextSendEpoch; i <= epoch; i++) { var sendTime = new Epoch(i); Instruction nextInstruction; inputQueue.TryDequeue(out nextInstruction); if (nextInstruction.payload != null) { //Console.WriteLine("Sending " + nextInstruction.payload.Length); for (int j = 0; j < nextInstruction.payload.Length; j++) { this.Output.Buffer.payload[this.Output.Buffer.length++] = new Pair <S, Epoch>(nextInstruction.payload[j], sendTime); if (this.Output.Buffer.length == this.Output.Buffer.payload.Length) { this.Output.SendBuffer(); } } Flush(); } if (!nextInstruction.isLast) { this.Scheduler.State(this.Stage.InternalGraphManager).Producer.UpdateRecordCounts(new Scheduling.Pointstamp(this.Stage.StageId, new int[] { i + 1 }), +1); } else { Logging.Progress("Completing input {0}", this.VertexId); } this.scheduler.State(this.Stage.InternalGraphManager).Producer.UpdateRecordCounts(new Scheduling.Pointstamp(this.Stage.StageId, new int[] { i }), -1); } nextSendEpoch = epoch + 1; }
internal override void PerformAction(Scheduling.Scheduler.WorkItem workItem) { var epoch = new Epoch().InitializeFrom(workItem.Requirement, 1).epoch; for (int i = nextSendEpoch; i <= epoch; i++) { var sendTime = new Epoch(i); var output = this.Output.GetBufferForTime(sendTime); Instruction nextInstruction; inputQueue.TryDequeue(out nextInstruction); if (nextInstruction.payload != null) { for (int j = 0; j < nextInstruction.payload.Length; j++) { output.Send(nextInstruction.payload[j]); } Flush(); } if (!nextInstruction.isLast) { this.Scheduler.State(this.Stage.InternalComputation).Producer.UpdateRecordCounts(new Runtime.Progress.Pointstamp(this.Stage.StageId, new int[] { i + 1 }), +1); } else { Logging.Progress("Completing input {0}", this.VertexId); } this.scheduler.State(this.Stage.InternalComputation).Producer.UpdateRecordCounts(new Runtime.Progress.Pointstamp(this.Stage.StageId, new int[] { i }), -1); } nextSendEpoch = epoch + 1; }
internal abstract void PerformAction(Scheduling.Scheduler.WorkItem workItem);
internal override void PerformAction(Scheduling.Scheduler.WorkItem workItem) { var epoch = new Epoch().InitializeFrom(workItem.Requirement, 1).epoch; Instruction nextInstruction; bool success = inputQueue.TryDequeue(out nextInstruction); Debug.Assert(success); if (nextInstruction.Epoch == int.MaxValue) { Logging.Progress("[{0}] Performing OnCompleted", this.Stage.ToString()); // OnCompleted logic. lock (this) { if (!this.isCompleted) { this.scheduler.State(this.Stage.InternalComputation).Producer.UpdateRecordCounts(new Runtime.Progress.Pointstamp(this.Stage.StageId, new int[] { this.currentVertexHold }), -1); this.isCompleted = true; } else { Logging.Error("WARNING: input ignored redundant shutdown when already shutdown."); } } } else if (nextInstruction.Payload == null) { Logging.Progress("[{1}] Performing OnNotify({0})", nextInstruction.Epoch, this.Stage.ToString()); // OnNotify logic. lock (this) { this.maximumValidEpoch = Math.Max(this.maximumValidEpoch, nextInstruction.Epoch); if (nextInstruction.Epoch >= this.currentVertexHold) { this.scheduler.State(this.Stage.InternalComputation).Producer.UpdateRecordCounts(new Runtime.Progress.Pointstamp(this.Stage.StageId, new int[] { nextInstruction.Epoch + 1 }), +1); this.scheduler.State(this.Stage.InternalComputation).Producer.UpdateRecordCounts(new Runtime.Progress.Pointstamp(this.Stage.StageId, new int[] { this.currentVertexHold }), -1); this.currentVertexHold = nextInstruction.Epoch + 1; } else { Logging.Error("WARNING: input ignored redundant notification for epoch {0} when current epoch was {1}.", nextInstruction.Epoch, this.currentVertexHold); } } } else { Logging.Progress("[{0}] Performing OnRecv", this.Stage.ToString()); // OnRecv logic. lock (this) { this.maximumValidEpoch = Math.Max(this.maximumValidEpoch, nextInstruction.Epoch); if (nextInstruction.Epoch >= this.currentVertexHold) { var sendTime = new Epoch(nextInstruction.Epoch); var output = this.output.GetBufferForTime(sendTime); for (int i = 0; i < nextInstruction.Payload.Length; ++i) { output.Send(nextInstruction.Payload[i]); } this.Flush(); } else { Logging.Error("WARNING: input ignored invalid data for epoch {0} when current epoch was {1}", nextInstruction.Epoch, this.currentVertexHold); } } } }