Changeset 13528 for branches/thasling/DistributedGA/DistributedGA.Core
- Timestamp:
- 01/17/16 11:10:34 (8 years ago)
- Location:
- branches/thasling/DistributedGA/DistributedGA.Core
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/PeerNetworkMessageHandler.cs
r13524 r13528 51 51 52 52 peerListManager = new WcfPeerListManager(); 53 //peerListManager = new TestPeerListManager(); 53 54 peerListManager.Init(ownInstance); 54 55 … … 72 73 try 73 74 { 74 //HACK: If IP is same as own: it is a "localhost" 75 //TODO: NEEDED WHEN PEER IS IN LAN, TOO???? 76 //Note: If IP is same as own: it is a "localhost" 75 77 if(peer.IpAddress.Equals(ownInstance.IpAddress)) 76 78 { -
branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs
r13524 r13528 12 12 public class WcfPeerListManager : IPeerListManager 13 13 { 14 //private const string SERVER_STRING = "http://localhost:9002/DistributedGA.ContactServer/ContactService";15 14 private const string SERVER_STRING = "http://localhost:9090/DistributedGA.ContactServer/ContactService"; 16 15 … … 31 30 public List<PeerInfo> GetPeerList() 32 31 { 33 if(allPeers == null) 32 //TODO: maybe always request a new list from the contact server so that he can refresh the heartbeat... 33 if (allPeers == null) 34 34 { 35 allPeers = 35 allPeers = client.GetPeerList(myself); 36 36 peersForMessaging = ChoosePeersForMessaging(allPeers); 37 37 } 38 // TODO: maybe always request a new list from the contact server so that he can refresh the heartbeat...39 return peersForMessaging;38 //return peersForMessaging; 39 return allPeers; //TODO: Enable 10% list communication 40 40 } 41 41 … … 58 58 private List<PeerInfo> ChoosePeersForMessaging(List<PeerInfo> allPeers) 59 59 { 60 //TODO: strategy: 10% of list random choosen 61 int noOfPeers = allPeers.Count / 10; //communicate with 10% of the network 60 //communicate with 10% of the network 61 int noOfPeers = allPeers.Count / 10; 62 List<Int32> indexList = GetRandomItemIndexes(noOfPeers, 0, allPeers.Count - 1); 62 63 List<PeerInfo> res = new List<PeerInfo>(); 64 foreach (Int32 index in indexList) 65 { 66 res.Add(allPeers.ElementAt(index)); 67 } 68 return allPeers; 69 } 63 70 64 return allPeers; 71 private List<Int32> GetRandomItemIndexes(int noOfItems, int minValue, int maxValue) 72 { 73 List<Int32> res = new List<Int32>(); 74 Random rnd = new Random(); 75 int tmp = -1; 76 while (res.Count < noOfItems) 77 { 78 tmp = rnd.Next(minValue, maxValue); 79 if (!res.Contains(tmp)) 80 { 81 res.Add(tmp); 82 } 83 } 84 return res; 65 85 } 66 86 -
branches/thasling/DistributedGA/DistributedGA.Core/obj/Debug/DistributedGA.Core.csproj.FileListAbsolute.txt
r13524 r13528 3 3 M:\FHOOE_02_Master\_MasterArbeit\_Implementierung\MAKK_20151116a\MAKK\02_Implementierung\VS\DistributedGA\DistributedGA.Core\obj\Debug\DistributedGA.Core.dll 4 4 M:\FHOOE_02_Master\_MasterArbeit\_Implementierung\MAKK_20151116a\MAKK\02_Implementierung\VS\DistributedGA\DistributedGA.Core\obj\Debug\DistributedGA.Core.pdb 5 P:\_DATA\SVN\thasling\DistributedGA\DistributedGA.Core\bin\Debug\DistributedGA.Core.dll 6 P:\_DATA\SVN\thasling\DistributedGA\DistributedGA.Core\bin\Debug\DistributedGA.Core.pdb 7 P:\_DATA\SVN\thasling\DistributedGA\DistributedGA.Core\obj\Debug\DistributedGA.Core.csprojResolveAssemblyReference.cache 8 P:\_DATA\SVN\thasling\DistributedGA\DistributedGA.Core\obj\Debug\DistributedGA.Core.dll 9 P:\_DATA\SVN\thasling\DistributedGA\DistributedGA.Core\obj\Debug\DistributedGA.Core.pdb
Note: See TracChangeset
for help on using the changeset viewer.