def notifyProcessesAboutANewOperation(self): processes = dsProcessManager.GetParticipants() val = ('', '') for p in processes: res = p.DSSocket.SendMessage(DSMessage(DSMessageType.InitRequest, self.Id)) # by passing the Id of the transactin we can follow up the transaction if needed if res == 'timeout': val = ('timeout', p.Id) break return val
def sendVoteRequest(self): processes = dsProcessManager.GetParticipants() self.ProcessesVoteRequestIsSentTo = processes val = ('', '') for p in processes: res = p.DSSocket.SendMessage(DSMessage(DSMessageType.VoteRequest, self.Operation, self.Id)) if res == 'timeout': val = ('timeout', p.Id) break return val
def onReadyTimeout(self): # in the case of timeout when the participant is in the ready state, we should contact # other participants to find their state. we are deciding as follow based on the other prticipant's state: # if other participant's State is INIT => this participant will be ABORT # if other participant's State is ABORT => this participant will be ABORT # if other participant's State is PRECOMMIT => this participant will be COMMIT # if other participant's State is COMMIT => this participant will be COMMIT # if other participant's State is READY => we will reach another participant, if all others are in ready state, # we need to wait for the coordinator to be recovered if self.State == DSParticipantOperationStatus.READY: processes = dsProcessManager.GetParticipants() for p in processes: if p.Id != self.DSProcess.Id: state = p.DSSocket.SendMessage(DSMessage(DSMessageType.GetParticipantState, self.CoordinatorTransactionId)) if state == DSParticipantOperationStatus.INIT or state == DSParticipantOperationStatus.ABORT: self.Abort() elif state == DSParticipantOperationStatus.COMMIT or state == DSParticipantOperationStatus.PRECOMMIT: self.Commit()
def sendGlobalAbort(self): processes = dsProcessManager.GetParticipants() for p in processes: p.DSSocket.SendMessage(DSMessage(DSMessageType.GlobalAbort, self.Id))
def sendPreCommit(self): processes = dsProcessManager.GetParticipants() for p in processes: p.DSSocket.SendMessage(DSMessage(DSMessageType.PreCommit, self.Id))