Changeset 14060


Ignore:
Timestamp:
07/13/16 15:37:29 (9 months ago)
Author:
thasling
Message:

#2615:
changed parameter in P2PMigrationAnalyzer, so that there is no invalid cast ExceptionThrown
other parameters still TBD
made WcfPeerListManager stateless by removing a stored ChannelFactory and creating a new one by each method call

Location:
branches/thasling/DistributedGA
Files:
2 edited

Legend:

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

    r14009 r14060  
    1818    private Object timerLock = new Object();
    1919
    20     private ChannelFactory<IContactService> myChannelFactory;
    21 
    22     private IContactService client;
    23 
    2420    private List<PeerInfo> cachedPeerList;
    2521
     
    3430      cachedPeerList = new List<PeerInfo>();
    3531      rand = new Random();
    36       //Init ChannelFactory and Client
    37       var binding = new NetTcpBinding();
    38       var endpoint = new EndpointAddress(serverString);
    39       myChannelFactory = new ChannelFactory<IContactService>(binding, endpoint);
    40       client = myChannelFactory.CreateChannel();
    41       //Register Peer
    42       client.RegisterPeer(myself);
    4332      //Start heartbeat timer
    4433      timer = new Timer(1000 * 20); //each 20 seconds
     
    5241
    5342    public void SendLogToServer(string msg) {
    54       client.MakeLog(myself, msg);
     43      var binding = new NetTcpBinding();
     44      var endpoint = new EndpointAddress(serverString);
     45      using (var myChannelFactory = new ChannelFactory<IContactService>(binding, endpoint)) {
     46        using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel()) {
     47          ((IContactService)client).MakeLog(myself, msg);     
     48        }
     49      }
    5550    }
    5651
     
    5853      timer.Stop();
    5954      timer.Dispose();
    60       ((IClientChannel)client).Close();
    61       myChannelFactory.Close();
    62       myChannelFactory = null;
    6355    }
    6456
     
    8678      lock (timerLock) {
    8779        try {
    88           var allPeers = client.GetPeerList(myself);
     80          List<PeerInfo> allPeers = new List<PeerInfo>();
     81          var binding = new NetTcpBinding();
     82          var endpoint = new EndpointAddress(serverString);
     83          using (var myChannelFactory = new ChannelFactory<IContactService>(binding, endpoint)) {
     84            using (IClientChannel client = (IClientChannel)myChannelFactory.CreateChannel()) {
     85              allPeers = ((IContactService)client).GetPeerList(myself);           
     86            }
     87          }
    8988          cachedPeerList = ChoosePeersForMessaging(ref allPeers);
    9089        }
  • branches/thasling/DistributedGA/DistributedGA.Hive/P2PMigrationAnalyzer.cs

    r14033 r14060  
    7474      get { return (IValueParameter<ILog>)Parameters["Log"]; }
    7575    }
    76     public ILookupParameter<StringValue> JobGuidParameter {
    77       get { return (ILookupParameter<StringValue>)Parameters["JobGUID"]; }
     76    public IValueParameter<StringValue> JobGuidParameter {
     77      get { return (IValueParameter<StringValue>)Parameters["JobGUID"]; }
    7878    }
    7979
     
    118118      Parameters.Add(new ValueParameter<StringValue>("ContactServerURL", "", new StringValue("net.tcp://10.42.1.150:9090/DistributedGA.ContactServer/ContactService")));
    119119      Parameters.Add(new ValueParameter<StringValue>("JobGUID", "", new StringValue(Guid.NewGuid().ToString())));
     120    //public ILookupParameter<StringValue> JobGuidParameter {
     121    //  get { return (ILookupParameter<StringValue>)Parameters["JobGUID"]; }
     122    //}
     123
    120124      Parameters.Add(new ValueParameter<ILog>("Log", "The log", new Log(1000)));
    121125
Note: See TracChangeset for help on using the changeset viewer.