- Timestamp:
- 06/28/16 17:03:36 (8 years ago)
- Location:
- branches/thasling/DistributedGA
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/thasling/DistributedGA/DistributedGA.ContactServer/ContactServiceImpl.cs
r13924 r13943 18 18 19 19 private Object logLock = new Object(); 20 21 private Object timerLock = new Object();//if elapsed takes too long, another thread also enters the method 20 22 21 23 public ContactServiceImpl() { … … 78 80 79 81 private void CleanUpContactTable(object sender, ElapsedEventArgs e) { 80 DateTime deadline = DateTime.Now; 81 //collect items to remove 82 List<PeerInfo> itemsToDelete = new List<PeerInfo>(); 83 foreach (PeerInfo pi in allPeers.Keys) { 84 DateTime tmp; 85 if (allPeers.TryGetValue(pi, out tmp)) { 86 //if (tmp.AddHours(1f) < deadline) 87 if (tmp.AddMinutes(1) < deadline) //TODO 82 lock (timerLock) { 83 DateTime deadline = DateTime.Now; 84 //collect items to remove 85 List<PeerInfo> itemsToDelete = new List<PeerInfo>(); 86 foreach (PeerInfo pi in allPeers.Keys) { 87 DateTime tmp; 88 if (allPeers.TryGetValue(pi, out tmp)) { 89 //if (tmp.AddHours(1f) < deadline) 90 if (tmp.AddMinutes(1) < deadline) //TODO 88 91 { 89 //if (tmp < deadline.AddHours(1f)) { 90 itemsToDelete.Add(pi); 92 //if (tmp < deadline.AddHours(1f)) { 93 itemsToDelete.Add(pi); 94 } 91 95 } 92 96 } 93 }94 //remove items95 foreach (PeerInfo pi in itemsToDelete) {96 DateTime tmp;97 allPeers.TryRemove(pi, out tmp);98 Console.WriteLine(string.Format("Removed peer {0}:{1} from dictionary because last access was: {2}", pi.IpAddress, pi.Port, tmp));97 //remove items 98 foreach (PeerInfo pi in itemsToDelete) { 99 DateTime tmp; 100 allPeers.TryRemove(pi, out tmp); 101 Console.WriteLine(string.Format("Removed peer {0}:{1} from dictionary because last access was: {2}", pi.IpAddress, pi.Port, tmp)); 102 } 99 103 } 100 104 } -
branches/thasling/DistributedGA/DistributedGA.ContactServer/DistributedGA.ContactServer.csproj
r13524 r13943 55 55 </ItemGroup> 56 56 <ItemGroup> 57 <None Include="App.config" /> 57 <None Include="App.config"> 58 <SubType>Designer</SubType> 59 </None> 58 60 </ItemGroup> 59 61 <ItemGroup> -
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfMessageSender.cs
r13937 r13943 18 18 private Timer timer; //sends cached messages to network in background 19 19 20 private Object timerLock = new Object(); 21 20 22 public void Init(PeerInfo source) { 21 23 myself = source; 22 24 bufferedMessages = new SizedConcurrentQueue<KeyValuePair<PeerInfo, byte[][]>>(); 23 bufferedMessages.Limit = 1000 ;25 bufferedMessages.Limit = 100000; 24 26 timer = new Timer(1000 * 60); //each 5 minutes 25 27 timer.Elapsed += GenerateSendingTasks; … … 52 54 /// <param name="data">data to send</param> 53 55 private void SendDataFromQueue(PeerInfo destination, byte[][] data) { 54 try { 55 Console.WriteLine(string.Format("Sending data to {0}:{1} in the background...", destination.IpAddress, destination.Port)); 56 var serviceUrl = "DistributedGA.svc"; 57 var baseUri = new Uri(string.Concat("net.tcp://", destination.IpAddress, ":", destination.Port, "/DistributedGA")); 58 var serviceUri = new Uri(baseUri, serviceUrl); 56 lock (timerLock) { 57 try { 58 Console.WriteLine(string.Format("Sending data to {0}:{1} in the background...", destination.IpAddress, destination.Port)); 59 var serviceUrl = "DistributedGA.svc"; 60 var baseUri = new Uri(string.Concat("net.tcp://", destination.IpAddress, ":", destination.Port, "/DistributedGA")); 61 var serviceUri = new Uri(baseUri, serviceUrl); 59 62 60 var binding = new NetTcpBinding(); 61 var endpoint = new EndpointAddress(serviceUri); 62 using (var myChannelFactory = new ChannelFactory<IMessageContract>(binding, endpoint)) { 63 using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel()) { 64 ((IMessageContract)client).SendData(myself, data); //maybe timout exception... 63 var binding = new NetTcpBinding(); 64 var endpoint = new EndpointAddress(serviceUri); 65 using (var myChannelFactory = new ChannelFactory<IMessageContract>(binding, endpoint)) { 66 using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel()) { 67 ((IMessageContract)client).SendData(myself, data); //maybe timout exception... 68 } 65 69 } 66 70 } 71 catch { } //if maybe sending failed (because of connection lost, etc.): just ignore 67 72 } 68 catch { } //if maybe sending failed (because of connection lost, etc.): just ignore69 73 } 70 74 } -
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs
r13937 r13943 15 15 16 16 private Timer timer = null; //sends heartbeat to contact-server 17 18 private Object timerLock = new Object(); 17 19 18 20 private ChannelFactory<IContactService> myChannelFactory; … … 73 75 res.Add(allPeers.ElementAt(index)); 74 76 } 75 return res;77 return allPeers; 76 78 } 77 79 … … 90 92 91 93 private void SendHeartbeatToServer(object sender, ElapsedEventArgs e) { 92 try { 93 heartbeatClient.UpdateHeartbeat(myself); 94 lock (timerLock) { 95 try { 96 heartbeatClient.UpdateHeartbeat(myself); 97 } 98 catch { } //nothing to do 94 99 } 95 catch { } //nothing to do96 100 } 97 101 -
branches/thasling/DistributedGA/DistributedGA.Hive/P2PMigrationAnalyzer.cs
r13905 r13943 97 97 // init P2P 98 98 h = new PeerNetworkMessageHandler(); 99 var peer = h.GetPeerInfo();100 peer.ProblemInstance = ((StringValue)Parameters["JobGUID"].ActualValue).Value;101 99 var lanIpPrefix = ((StringValue)(Parameters["LanIpPrefix"].ActualValue)).Value; 102 100 var contactServerUri = ((StringValue)(Parameters["ContactServerURL"].ActualValue)).Value; 103 101 h.Init(lanIpPrefix, contactServerUri); 102 var peer = h.GetPeerInfo(); 103 peer.ProblemInstance = ((StringValue)Parameters["JobGUID"].ActualValue).Value; 104 104 } 105 105
Note: See TracChangeset
for help on using the changeset viewer.