Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/17/16 11:10:34 (8 years ago)
Author:
thasling
Message:

Peers only communicate with 10% of the network

Location:
branches/thasling/DistributedGA/DistributedGA.Core
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/PeerNetworkMessageHandler.cs

    r13524 r13528  
    5151
    5252                peerListManager = new WcfPeerListManager();
     53                //peerListManager = new TestPeerListManager();
    5354                peerListManager.Init(ownInstance);
    5455
     
    7273                    try
    7374                    {
    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"
    7577                        if(peer.IpAddress.Equals(ownInstance.IpAddress))
    7678                        {
  • branches/thasling/DistributedGA/DistributedGA.Core/Implementation/WcfPeerListManager.cs

    r13524 r13528  
    1212    public class WcfPeerListManager : IPeerListManager
    1313    {
    14         //private const string SERVER_STRING = "http://localhost:9002/DistributedGA.ContactServer/ContactService";
    1514        private const string SERVER_STRING = "http://localhost:9090/DistributedGA.ContactServer/ContactService";
    1615
     
    3130        public List<PeerInfo> GetPeerList()
    3231        {
    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)
    3434            {
    35                 allPeers =  client.GetPeerList(myself);
     35                allPeers = client.GetPeerList(myself);
    3636                peersForMessaging = ChoosePeersForMessaging(allPeers);
    3737            }
    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
    4040        }
    4141
     
    5858        private List<PeerInfo> ChoosePeersForMessaging(List<PeerInfo> allPeers)
    5959        {
    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);
    6263            List<PeerInfo> res = new List<PeerInfo>();
     64            foreach (Int32 index in indexList)
     65            {
     66                res.Add(allPeers.ElementAt(index));
     67            }
     68            return allPeers;
     69        }
    6370
    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;
    6585        }
    6686
  • branches/thasling/DistributedGA/DistributedGA.Core/obj/Debug/DistributedGA.Core.csproj.FileListAbsolute.txt

    r13524 r13528  
    33M:\FHOOE_02_Master\_MasterArbeit\_Implementierung\MAKK_20151116a\MAKK\02_Implementierung\VS\DistributedGA\DistributedGA.Core\obj\Debug\DistributedGA.Core.dll
    44M:\FHOOE_02_Master\_MasterArbeit\_Implementierung\MAKK_20151116a\MAKK\02_Implementierung\VS\DistributedGA\DistributedGA.Core\obj\Debug\DistributedGA.Core.pdb
     5P:\_DATA\SVN\thasling\DistributedGA\DistributedGA.Core\bin\Debug\DistributedGA.Core.dll
     6P:\_DATA\SVN\thasling\DistributedGA\DistributedGA.Core\bin\Debug\DistributedGA.Core.pdb
     7P:\_DATA\SVN\thasling\DistributedGA\DistributedGA.Core\obj\Debug\DistributedGA.Core.csprojResolveAssemblyReference.cache
     8P:\_DATA\SVN\thasling\DistributedGA\DistributedGA.Core\obj\Debug\DistributedGA.Core.dll
     9P:\_DATA\SVN\thasling\DistributedGA\DistributedGA.Core\obj\Debug\DistributedGA.Core.pdb
Note: See TracChangeset for help on using the changeset viewer.