private void applyUpdate(UpdateData data) { pingData = data; Console.WriteLine("Ping Seq: " +lastPingId); if (data.createdPadIntsMap.Count != 0) { foreach (KeyValuePair<int, PadIntData> entry in data.createdPadIntsMap) { if (!createdPadIntsMap.ContainsKey(entry.Key)) { ServerPadInt sp = new ServerPadInt(entry.Key); sp.log.setReadData(entry.Value.lRead); sp.log.setWriteData(entry.Value.lWrite); sp.log.setTentativeData(entry.Value.lTentative); sp.log.setTentativeValueData(entry.Value.lTentativeVal); sp.log.setTentativeReadData(entry.Value.lTentativeRead); sp.setValueData(entry.Value.value); createdPadIntsMap.Add(entry.Key, sp); } allPingData.createdPadInt(entry.Key, entry.Value); } } if (data.removedCreatedPadInts.Count != 0) { foreach (int key in data.removedCreatedPadInts) { if (createdPadIntsMap.ContainsKey(key)) { createdPadIntsMap.Remove(key); } allPingData.removeCreatedPadInt(key); } } if (data.commitedPadIntsMap.Count != 0) { foreach (KeyValuePair<int, PadIntData> entry in data.commitedPadIntsMap) { ServerPadInt sp; if (padIntsMap.ContainsKey(entry.Key)) { sp = padIntsMap[entry.Key]; } else { sp = new ServerPadInt(entry.Key); } sp.log.setReadData(entry.Value.lRead); sp.log.setWriteData(entry.Value.lWrite); sp.log.setTentativeData(entry.Value.lTentative); sp.log.setTentativeValueData(entry.Value.lTentativeVal); sp.setValueData(entry.Value.value); if (!padIntsMap.ContainsKey(entry.Key)) { padIntsMap.Add(entry.Key, sp); } allPingData.commitedPadIntsMap.Add(entry.Key, entry.Value); } int actualOccupation = padIntsMap.Count; int actualNumberTransactions = tIdPadIntMap.Count; Monitor.Exit(this); new Thread(delegate() { master.updateChargeServer(serverURL, actualOccupation, actualNumberTransactions); }).Start(); Monitor.Enter(this); } if (data.modifiedPadIntsMap.Count != 0) { foreach (KeyValuePair<int, PadIntData> entry in data.modifiedPadIntsMap) { padIntsMap[entry.Key].log.setReadData(entry.Value.lRead); padIntsMap[entry.Key].log.setWriteData(entry.Value.lWrite); padIntsMap[entry.Key].log.setTentativeData(entry.Value.lTentative); padIntsMap[entry.Key].log.setTentativeValueData(entry.Value.lTentativeVal); padIntsMap[entry.Key].setValueData(entry.Value.value); allPingData.addModifiedPadInt(entry.Key, entry.Value); } } if (data.tIdPadIntMap.Count != 0) { foreach (KeyValuePair<IdTransaction, ISet<int>> entry in data.tIdPadIntMap) { if (!tIdPadIntMap.ContainsKey(entry.Key)) { tIdPadIntMap.Add(entry.Key, new HashSet<int>()); } tIdPadIntMap[entry.Key] = entry.Value; foreach (int padInt in entry.Value) { allPingData.addNewTransaction(entry.Key, padInt); } } } if (data.removedTransactions.Count != 0) { foreach (IdTransaction t in data.removedTransactions) { if (tIdPadIntMap.ContainsKey(t)) { tIdPadIntMap.Remove(t); } allPingData.removeTransaction(t); } } }