//Recovery public async Task <Task> CompleteOneOperatorRecovery(BarrierOrCommitMsgTrackingInfo msgInfo) { if (!recoveryTrackingMap.ContainsKey(msgInfo.BatchID)) { //Multiple batch has that problem PrettyConsole.Line("The recovery key " + msgInfo.BatchID + " is not exist"); } else { //PrettyConsole.Line("Finish Tracking one message in batchID: " + msgInfo.BatchID); StreamBatch targetBatch = recoveryTrackingMap[msgInfo.BatchID]; targetBatch.CompleteOneMessageTracking(msgInfo); if (targetBatch.readForCommitting) { if (batchCoordinator != null) { PrettyConsole.Line("Batch: " + msgInfo.BatchID + " commit has been successfully recoveryed"); await batchCoordinator.CompleteRecovery(msgInfo.BatchID); recoveryTrackingMap.Remove(msgInfo.BatchID); } } } return(Task.CompletedTask); }
//If it is special message, it has to send to all the operators. //If it is barrier message, batch manager will start to track it //by using BarrierMsgTrackingInfo which keep and ID and the number of //client it sent to. private async Task <Task> ProcessSpecialMessage(StreamMessage msg, IAsyncStream <StreamMessage> stream) { BarrierOrCommitMsgTrackingInfo info = new BarrierOrCommitMsgTrackingInfo(msg.barrierOrCommitInfo.GetID(), msg.barrierOrCommitInfo.numberOfClientSent); info.BatchID = msg.BatchID; if (msg.Value == Constants.Barrier_Value && msg.BatchID - currentBatchID < 2) { currentBatchID = msg.BatchID + 1; PrettyConsole.Line("Increment ID " + currentBatchID); await TrackingBarrierMessages(msg); await BroadcastSpecialMessage(msg, stream); await batchTracker.CompleteOneOperatorBarrier(info); } return(Task.CompletedTask); }
protected async Task <Task> ProcessSpecialMessageAsync(StreamMessage msg, IAsyncStream <StreamMessage> stream) { BarrierOrCommitMsgTrackingInfo info = new BarrierOrCommitMsgTrackingInfo(msg.barrierOrCommitInfo.GetID(), msg.barrierOrCommitInfo.numberOfClientSent); info.BatchID = msg.BatchID; if (msg.Value == Constants.Barrier_Value) { if (CheckCount(msg)) { await HandleBarrierMessages(msg); batchTracker.CompleteOneOperatorBarrier(info); } } else { throw new NotImplementedException("Unrecgonizable system message in stateless operator"); } await BroadcastSpecialMessage(msg, stream); return(Task.CompletedTask); }
//Should find the target task in the currentBatch public Task CompleteOneOperatorBarrier(BarrierOrCommitMsgTrackingInfo msgInfo) { if (!batchTrackingMap.ContainsKey(msgInfo.BatchID)) { PrettyConsole.Line("Complete Barrier, but The key " + msgInfo.BatchID + " is not exist"); } else { //PrettyConsole.Line("Finish Tracking one message in batchID: " + msgInfo.BatchID); StreamBatch targetBatch = batchTrackingMap[msgInfo.BatchID]; targetBatch.CompleteOneMessageTracking(msgInfo); if (targetBatch.readForCommitting) { if (batchCoordinator != null) { PrettyConsole.Line("Commit Batch: " + msgInfo.BatchID); SetBatchAsCompleted(msgInfo.BatchID); batchCoordinator.StartCommit(msgInfo.BatchID); batchTrackingMap.Remove(msgInfo.BatchID); } } } return(Task.CompletedTask); }