Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/27/10 11:46:46 (14 years ago)
Author:
cneumuel
Message:

changed Slave.Core WCF-Proxy to stateless object

Location:
branches/3.3-HiveMigration/sources/HeuristicLab.Hive
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Calendar/3.3/Properties/AssemblyInfo.cs

    r4333 r4337  
    5858// [assembly: AssemblyVersion("1.0.*")]
    5959[assembly: AssemblyVersion("3.3.0.0")]
    60 [assembly: AssemblyFileVersion("3.3.0.4320")]
     60[assembly: AssemblyFileVersion("3.3.0.4333")]
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Contracts/3.3/WcfSettings.cs

    r4316 r4337  
    100100    }
    101101
     102    /// <summary>
     103    /// Securely disposes a WCF client proxy object
     104    /// </summary>
     105    /// <param name="obj"></param>
     106    public static void DisposeWcfClient(ICommunicationObject obj) {
     107      if (obj != null) {
     108        if (obj.State != CommunicationState.Faulted &&
     109            obj.State != CommunicationState.Closed) {
     110          try { obj.Close(); }
     111          catch (CommunicationObjectFaultedException) { obj.Abort(); }
     112          catch (TimeoutException) { obj.Abort(); }
     113          catch (Exception) {
     114            obj.Abort();
     115            throw;
     116          }
     117        } else
     118          obj.Abort();
     119      }
     120    }
     121
    102122  }
    103123
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/ServiceLocator.cs

    r4316 r4337  
    5454
    5555    public static void DisposeClientFacade(IClientFacade clientFacade) {
    56       ICommunicationObject obj = (ICommunicationObject)clientFacade;
    57       if (obj != null) {
    58         if (obj.State != CommunicationState.Faulted &&
    59             obj.State != CommunicationState.Closed) {
    60           try { obj.Close(); }
    61           catch (CommunicationObjectFaultedException) { obj.Abort(); }
    62           catch (TimeoutException) { obj.Abort(); }
    63           catch (Exception) {
    64             obj.Abort();
    65             throw;
    66           }
    67         } else
    68           obj.Abort();
    69       }
     56      WcfSettings.DisposeWcfClient((ICommunicationObject)clientFacade);     
    7057    }
    7158  }
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Experiment/3.3/app.config

    r4333 r4337  
    3232            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
    3333            transactionFlow="false" transferMode="Streamed" transactionProtocol="OleTransactions"
    34             hostNameComparisonMode="StrongWildcard" listenBacklog="100"
    35             maxBufferPoolSize="104857600" maxBufferSize="104857600" maxConnections="100"
     34            hostNameComparisonMode="StrongWildcard"
     35            maxBufferPoolSize="104857600" maxBufferSize="104857600"
    3636            maxReceivedMessageSize="104857600">
    3737          <readerQuotas maxDepth="32" maxStringContentLength="104857600" maxArrayLength="104857600"
     
    4747            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
    4848            transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
    49             hostNameComparisonMode="StrongWildcard" listenBacklog="100"
    50             maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="100"
     49            hostNameComparisonMode="StrongWildcard"
     50            maxBufferPoolSize="524288" maxBufferSize="65536"
    5151            maxReceivedMessageSize="65536">
    5252          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Authorization/AuthorizationManager.cs

    r4333 r4337  
    1414    private IContextFactory contextFactory = ServiceLocator.GetContextFactory();
    1515
    16     public void AuthorizeForJobs(params Guid[] jobId) {
    17       if (!(Identity.IsAuthenticated && IsAuthorizedForJobs(jobId))) {
    18         throw new SecurityException();
     16    public void AuthorizeForJobs(params Guid[] jobIds) {
     17      if (!(Identity.IsAuthenticated && IsAuthorizedForJobs(jobIds))) {
     18        throw new SecurityException("User '" + Identity.Name + "' is not authorized to access job (Id: " + string.Join(", ", jobIds.Select(x => x.ToString()).ToArray()) + ")");
    1919      }
    2020    }
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Facades/SlaveFacade.cs

    r4333 r4337  
    9494    public Response IsJobStillNeeded(Guid jobId) {
    9595      using (contextFactory.GetContext()) {
    96         ServiceLocator.GetAuthorizationManager().AuthorizeForJobs(jobId);
    9796        return slaveCommunicator.IsJobStillNeeded(jobId);
    9897      }
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/app.config

    r4333 r4337  
    5353        <binding name="TcpStreamedBinding" sendTimeout="00:10:00" transferMode="Streamed"
    5454          maxBufferPoolSize="104857600" maxBufferSize="104857600"
    55           maxReceivedMessageSize="104857600" maxConnections="100" listenBacklog="100">
     55          maxReceivedMessageSize="104857600">
    5656          <readerQuotas maxStringContentLength="104857600" maxArrayLength="104857600" />
    5757          <security mode="TransportWithMessageCredential">
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Communication/3.3/ServiceLocator.cs

    r4316 r4337  
    55using HeuristicLab.Hive.Slave.Communication.SlaveService;
    66using HeuristicLab.Hive.Contracts;
     7using System.ServiceModel;
     8using HeuristicLab.Hive.Slave.Communication.Properties;
     9using HeuristicLab.Tracing;
    710
    811namespace HeuristicLab.Hive.Slave.Communication {
    912  internal static class ServiceLocator {
    10     internal static SlaveFacadeClient CreateSlaveFacade(string hostAddress) {
     13    /// <summary>
     14    /// Cache of SlaveFacadeClients, to check if all get disposed
     15    /// </summary>
     16    private static List<ISlaveFacade> clientCache = new List<ISlaveFacade>();
     17
     18    internal static ISlaveFacade CreateSlaveFacade(string hostAddress) {
    1119      SlaveFacadeClient client = new SlaveFacadeClient("SlaveHttpEndpoint");
    1220      WcfSettings.SetEndpointAddress(client.Endpoint, hostAddress);
     21      SetCredentials(client);
     22      client.Open();
     23      clientCache.Add(client);
     24      Logger.Debug("Created SlaveFacadeClients. Currently existing SlaveFacadeClients: " + clientCache.Count);
    1325      return client;
    1426    }
    1527
    16     internal static SlaveFacadeClient CreateStreamedSlaveFacade(string hostAddress) {
     28    internal static ISlaveFacade CreateStreamedSlaveFacade(string hostAddress) {
    1729      SlaveFacadeClient client = new SlaveFacadeClient("SlaveTcpStreamedEndpoint");
    1830      WcfSettings.SetEndpointAddress(client.Endpoint, hostAddress);
     31      SetCredentials(client);
     32      client.Open();
     33      clientCache.Add(client);
     34      Logger.Debug("Created SlaveFacadeClients. Currently existing SlaveFacadeClients: " + clientCache.Count);
    1935      return client;
     36    }
     37
     38    private static void SetCredentials(SlaveFacadeClient client) {
     39      client.ClientCredentials.UserName.UserName = Settings.Default.HiveUsername;
     40      client.ClientCredentials.UserName.Password = Settings.Default.HivePassword;
     41    }
     42
     43    public static void DisposeSlaveClient(ISlaveFacade slaveFacade) {
     44      WcfSettings.DisposeWcfClient((ICommunicationObject)slaveFacade);
     45      clientCache.Remove(slaveFacade);
     46      Logger.Debug("Disposing SlaveFacadeClients. Currently existing SlaveFacadeClients: " + clientCache.Count);
    2047    }
    2148  }
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Communication/3.3/WcfService.cs

    r4333 r4337  
    6161    public NetworkEnum.WcfConnState ConnState { get; private set; }
    6262    public bool LoggedIn { get; set; }
    63     public string ServerIP { get; private set; }
     63
     64    private string serverIp;
     65    public string ServerIp {
     66      get { return serverIp; }
     67      set {
     68        if (serverIp != value) {
     69          serverIp = value;
     70          if (ServerChanged != null)
     71            ServerChanged(this, new EventArgs());
     72        }
     73      }
     74    }
    6475
    6576    public event EventHandler ConnectionRestored;
     
    6778    public event EventHandler Connected;
    6879
    69     public SlaveFacadeClient proxy = null;
    70 
    7180    /// <summary>
    7281    /// Constructor
     
    8190    /// </summary>
    8291    public void Connect() {
     92      SlaveService.ISlaveFacade client = null;
    8393      try {
    8494        Logger.Debug("Starting the Connection Process");
    85         if (String.Empty.Equals(ServerIP)) {
     95        if (String.Empty.Equals(ServerIp)) {
    8696          Logger.Info("No Server IP set!");
    8797          return;
     
    8999
    90100        Logger.Debug("Creating the new connection proxy");
    91         proxy = ServiceLocator.CreateStreamedSlaveFacade(ServerIP);
     101        client = ServiceLocator.CreateStreamedSlaveFacade(ServerIp);
    92102        Logger.Debug("Created the new connection proxy");
    93103
    94         Logger.Debug("Registring new Events");
    95         proxy.GetStreamedJobCompleted += new EventHandler<GetStreamedJobCompletedEventArgs>(proxy_GetStreamedJobCompleted);
    96         proxy.StoreFinishedJobResultStreamedCompleted += new EventHandler<StoreFinishedJobResultStreamedCompletedEventArgs>(proxy_StoreFinishedJobResultStreamedCompleted);
    97         proxy.ProcessSnapshotStreamedCompleted += new EventHandler<ProcessSnapshotStreamedCompletedEventArgs>(proxy_ProcessSnapshotStreamedCompleted);
    98         proxy.ProcessHeartBeatCompleted += new EventHandler<ProcessHeartBeatCompletedEventArgs>(proxy_ProcessHeartBeatCompleted);
    99         Logger.Debug("Registered new Events");
    100         Logger.Debug("Opening the Connection");
    101         proxy.ClientCredentials.UserName.UserName = Settings.Default.HiveUsername;
    102         proxy.ClientCredentials.UserName.Password = Settings.Default.HivePassword;
    103         proxy.Open();
    104         Logger.Debug("Opened the Connection");
    105        
    106104        ConnState = NetworkEnum.WcfConnState.Connected;
    107105        ConnectedSince = DateTime.Now;
    108         LoggedIn = false;
    109106
    110107        if (Connected != null) {
    111           Logger.Debug("Calling the connected Event");
    112108          Connected(this, new EventArgs());
    113           //Todo: This won't be hit. EVER       
    114109        }
    115110        if (ConnState == NetworkEnum.WcfConnState.Failed) {
    116111          ConnectionRestored(this, new EventArgs());
    117112        }
    118       } catch (Exception ex) {
     113      }
     114      catch (Exception ex) {
    119115        HandleNetworkError(ex);
    120116      }
    121     }
    122 
    123     /// <summary>
    124     /// Changes the Connectionsettings (serverIP) and reconnects
    125     /// </summary>
    126     /// <param name="serverIP">current Server IP</param>
    127     public void Connect(String serverIP) {
    128       Logger.Debug("Called Connected with " + serverIP);
    129       String oldIp = this.ServerIP;
    130       this.ServerIP = serverIP;
    131       Connect();
    132       if (oldIp != serverIP)
    133         if (ServerChanged != null)
    134           ServerChanged(this, new EventArgs());
    135     }
    136 
    137     public void SetIP(String serverIP) {
    138       Logger.Debug("Called with " + serverIP);
    139       this.ServerIP = serverIP;
    140     }
    141 
    142     /// <summary>
    143     /// Disconnects the Slave from the Server
    144     /// </summary>
     117      finally {
     118        ServiceLocator.DisposeSlaveClient(client);
     119      }
     120    }
     121
     122    ///// <summary>
     123    ///// Disconnects the Slave from the Server
     124    ///// </summary>
    145125    public void Disconnect() {
    146126      ConnState = NetworkEnum.WcfConnState.Disconnected;
     
    161141    /// Methods for the Server Login
    162142    /// </summary>
    163     public void LoginSync(SlaveDto slaveInfo) {
     143    public void Login(SlaveDto slaveInfo) {
     144      SlaveService.ISlaveFacade client = null;
    164145      try {
    165146        if (ConnState == NetworkEnum.WcfConnState.Connected) {
    166147          Logger.Debug("STARTED: Login Sync");
    167           Response res = proxy.Login(slaveInfo);
     148          client = ServiceLocator.CreateSlaveFacade(ServerIp);
     149          Response res = client.Login(slaveInfo);
    168150          if (res.StatusMessage != ResponseStatus.Ok) {
    169151            Logger.Error("FAILED: Login Failed! " + res.StatusMessage);
     
    174156          }
    175157        }
    176       } catch (Exception e) {
    177         HandleNetworkError(e);
    178       }
    179     }
    180    
     158      }
     159      catch (Exception e) {
     160        HandleNetworkError(e);
     161      }
     162      finally {
     163        ServiceLocator.DisposeSlaveClient(client);
     164      }
     165    }
     166
    181167    /// <summary>
    182168    /// Pull a Job from the Server
     
    187173      if (LoggedIn) {
    188174        Logger.Debug("STARTED: Fetching of Jobs from Server for Slave");
    189         proxy.GetStreamedJobAsync(guid);
    190       }
    191     }
    192 
    193     void proxy_GetStreamedJobCompleted(object sender, GetStreamedJobCompletedEventArgs e) {
    194       if (e.Error == null) {
    195         Logger.Debug("ENDED: Fetching of Jobs from Server for Slave");
    196         Stream stream = null;
    197         MemoryStream memStream = null;
    198 
    199         try {
    200           stream = (Stream)e.Result;
    201 
    202           //first deserialize the response
    203           BinaryFormatter formatter = new BinaryFormatter();
    204           ResponseObject<JobDto> response = (ResponseObject<JobDto>)formatter.Deserialize(stream);
    205 
    206           //second deserialize the BLOB
    207           memStream = new MemoryStream();
    208 
    209           byte[] buffer = new byte[3024];
    210           int read = 0;
    211           while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) {
    212             memStream.Write(buffer, 0, read);
    213           }
    214 
    215           memStream.Close();
    216 
    217           GetJobCompletedEventArgs completedEventArgs = new GetJobCompletedEventArgs(new object[] { response, memStream.GetBuffer() }, e.Error, e.Cancelled, e.UserState);
    218           GetJobCompleted(sender, completedEventArgs);
    219         } catch (Exception ex) {
    220           Logger.Error(ex);
    221         } finally {
    222           if (stream != null)
    223             stream.Dispose();
    224 
    225           if (memStream != null)
    226             memStream.Dispose();
    227         }
    228       } else
    229         HandleNetworkError(e.Error);
     175        SlaveService.ISlaveFacade client = ServiceLocator.CreateStreamedSlaveFacade(ServerIp);
     176        //client.GetStreamedJobAsync(guid);
     177        client.BeginGetStreamedJob(guid, (ar => {
     178          if (ar.IsCompleted) {
     179            Stream stream = null;
     180            MemoryStream memStream = null;
     181            try {
     182              Logger.Debug("ENDED: Fetching of Jobs from Server for Slave");
     183              stream = client.EndGetStreamedJob(ar);
     184
     185              //first deserialize the response
     186              BinaryFormatter formatter = new BinaryFormatter();
     187              ResponseObject<JobDto> response = (ResponseObject<JobDto>)formatter.Deserialize(stream);
     188
     189              //second deserialize the BLOB
     190              memStream = new MemoryStream();
     191
     192              byte[] buffer = new byte[3024];
     193              int read = 0;
     194              while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) {
     195                memStream.Write(buffer, 0, read);
     196              }
     197
     198              memStream.Close();
     199
     200              GetJobCompletedEventArgs completedEventArgs = new GetJobCompletedEventArgs(new object[] { response, memStream.GetBuffer() }, null, !ar.IsCompleted, ar.AsyncState);
     201              GetJobCompleted(this, completedEventArgs);
     202            }
     203            catch (Exception ex) {
     204              Logger.Error(ex);
     205            }
     206            finally {
     207              if (stream != null)
     208                stream.Dispose();
     209
     210              if (memStream != null)
     211                memStream.Dispose();
     212            }
     213          } else
     214            HandleNetworkError(new FaultException("GetJobAsync did not complete"));
     215
     216          ServiceLocator.DisposeSlaveClient(client);
     217        }), null);
     218      }
    230219    }
    231220
     
    244233        Logger.Debug("Builded stream");
    245234        Logger.Debug("Making the call");
    246         proxy.StoreFinishedJobResultStreamedAsync(stream, stream);
    247       }
    248     }
    249 
    250     private void proxy_StoreFinishedJobResultStreamedCompleted(object sender, StoreFinishedJobResultStreamedCompletedEventArgs e) {
    251       Logger.Debug("Finished storing the job");
    252       Stream stream = (Stream)e.UserState;
    253       if (stream != null) {
    254         Logger.Debug("Stream not null, disposing it");
    255         stream.Dispose();
    256       }
    257       if (e.Error == null) {
    258         StoreFinishedJobResultCompletedEventArgs args = new StoreFinishedJobResultCompletedEventArgs(new object[] { e.Result }, e.Error, e.Cancelled, e.UserState);
    259         Logger.Debug("calling the Finished Job Event");
    260         GetFinishedJobResultCompleted(sender, args);
    261         Logger.Debug("ENDED: Sending back the finished job results");
    262       } else {
    263         HandleNetworkError(e.Error);
     235        //proxy.StoreFinishedJobResultStreamedAsync(stream, stream);
     236        SlaveService.ISlaveFacade client = ServiceLocator.CreateStreamedSlaveFacade(ServerIp);
     237        client.BeginStoreFinishedJobResultStreamed(stream, (ar => {
     238          Logger.Debug("Finished storing the job");
     239          if (stream != null)
     240            stream.Dispose();
     241
     242          if (ar.IsCompleted) {
     243            var res = client.EndStoreFinishedJobResultStreamed(ar);
     244            StoreFinishedJobResultCompletedEventArgs args = new StoreFinishedJobResultCompletedEventArgs(new object[] { res }, null, false, null);
     245            Logger.Debug("calling the Finished Job Event");
     246            GetFinishedJobResultCompleted(this, args);
     247            Logger.Debug("ENDED: Sending back the finished job results");
     248          } else {
     249            HandleNetworkError(new FaultException("GetFinishedJobResultAsync did not complete"));
     250          }
     251          ServiceLocator.DisposeSlaveClient(client);
     252        }), null);
    264253      }
    265254    }
     
    272261      if (LoggedIn) {
    273262        Stream stream = GetStreamedJobResult(clientId, jobId, result, percentage, exception);
    274         proxy.ProcessSnapshotStreamedAsync(stream, stream);
    275       }
    276     }
    277 
    278     void proxy_ProcessSnapshotStreamedCompleted(object sender, ProcessSnapshotStreamedCompletedEventArgs e) {
    279       Stream stream =
    280         (Stream)e.UserState;
    281       if (stream != null)
    282         stream.Dispose();
    283 
    284       if (e.Error == null) {
    285         ProcessSnapshotCompletedEventArgs args =
    286           new ProcessSnapshotCompletedEventArgs(
    287             new object[] { e.Result }, e.Error, e.Cancelled, e.UserState);
    288 
    289         ProcessSnapshotCompleted(sender, args);
    290       } else
    291         HandleNetworkError(e.Error);
     263        //proxy.ProcessSnapshotStreamedAsync(stream, stream);
     264        SlaveService.ISlaveFacade client = ServiceLocator.CreateStreamedSlaveFacade(ServerIp);
     265        client.BeginProcessSnapshotStreamed(stream, (ar => {
     266          if (stream != null)
     267            stream.Dispose();
     268
     269          if (ar.IsCompleted) {
     270            var res = client.EndStoreFinishedJobResultStreamed(ar);
     271            ProcessSnapshotCompletedEventArgs args = new ProcessSnapshotCompletedEventArgs(new object[] { res }, null, false, null);
     272            ProcessSnapshotCompleted(this, args);
     273          } else {
     274            HandleNetworkError(new FaultException("ProcessSnapshotAsync did not complete"));
     275          }
     276          ServiceLocator.DisposeSlaveClient(client);
     277        }), null);
     278      }
    292279    }
    293280
     
    301288    public event System.EventHandler<ProcessHeartBeatCompletedEventArgs> ProcessHeartBeatCompleted;
    302289    public void ProcessHeartBeatAsync(HeartBeatData hbd) {
    303       if (LoggedIn)
     290      if (LoggedIn) {
    304291        Logger.Debug("STARTING: sending heartbeat");
    305       proxy.ProcessHeartBeatAsync(hbd);
    306     }
    307 
    308     private void proxy_ProcessHeartBeatCompleted(object sender, ProcessHeartBeatCompletedEventArgs e) {
    309       if (e.Error == null && e.Result.StatusMessage == ResponseStatus.Ok) {
    310         ProcessHeartBeatCompleted(sender, e);
    311         Logger.Debug("ENDED: sending heartbeats");
    312       } else {
    313         try {
    314           Logger.Error("Error: " + e.Result.StatusMessage);
    315         } catch (Exception ex) {
    316           Logger.Error("Error: ", ex);
    317         }
    318         HandleNetworkError(e.Error);
     292        //proxy.ProcessHeartBeatAsync(hbd);
     293        SlaveService.ISlaveFacade client = ServiceLocator.CreateStreamedSlaveFacade(ServerIp);
     294        client.BeginProcessHeartBeat(hbd, (ar => {
     295          if (ar.IsCompleted) {
     296            var res = client.EndProcessHeartBeat(ar);
     297            if (res.StatusMessage == ResponseStatus.Ok) {
     298              ProcessHeartBeatCompleted(this, new ProcessHeartBeatCompletedEventArgs(new object[] { res }, null, false, null));
     299              Logger.Debug("ENDED: sending heartbeats");
     300            } else {
     301              Logger.Error("FAILED: sending heartbeats: " + res.StatusMessage.ToString());
     302            }
     303          } else {
     304            HandleNetworkError(new FaultException("ProcessHeartBeatAsync did not complete"));
     305          }
     306          ServiceLocator.DisposeSlaveClient(client);
     307        }), null);
    319308      }
    320309    }
     
    345334
    346335    public ResponseResultReceived StoreFinishedJobResultsSync(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception, bool finished) {
    347       return proxy.StoreFinishedJobResultStreamed(GetStreamedJobResult(clientId, jobId, result, percentage, exception));
     336      SlaveService.ISlaveFacade client = ServiceLocator.CreateStreamedSlaveFacade(ServerIp);
     337      ResponseResultReceived res = client.StoreFinishedJobResultStreamed(GetStreamedJobResult(clientId, jobId, result, percentage, exception));
     338      ServiceLocator.DisposeSlaveClient(client);
     339      return res;
    348340    }
    349341
     
    351343      try {
    352344        Logger.Debug("STARTING: Sync call: IsJobStillNeeded");
    353         Response res = proxy.IsJobStillNeeded(jobId);
     345        SlaveService.ISlaveFacade client = ServiceLocator.CreateStreamedSlaveFacade(ServerIp);
     346        Response res = client.IsJobStillNeeded(jobId);
     347        ServiceLocator.DisposeSlaveClient(client);
    354348        Logger.Debug("ENDED: Sync call: IsJobStillNeeded");
    355349        return res;
    356       } catch (Exception e) {
     350      }
     351      catch (Exception e) {
    357352        HandleNetworkError(e);
    358353        return null;
     
    362357    public ResponseResultReceived ProcessSnapshotSync(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception) {
    363358      try {
    364         return proxy.ProcessSnapshotStreamed(GetStreamedJobResult(clientId, jobId, result, percentage, exception));
    365       } catch (Exception e) {
     359        SlaveService.ISlaveFacade client = ServiceLocator.CreateStreamedSlaveFacade(ServerIp);
     360        var res = client.ProcessSnapshotStreamed(GetStreamedJobResult(clientId, jobId, result, percentage, exception));
     361        ServiceLocator.DisposeSlaveClient(client);
     362        return res;
     363      }
     364      catch (Exception e) {
    366365        HandleNetworkError(e);
    367366        return null;
     
    373372        Logger.Debug("STARTED: Requesting Plugins for Job");
    374373        Logger.Debug("STARTED: Getting the stream");
    375         Stream stream = proxy.GetStreamedPlugins(requestedPlugins.ToArray());
     374        SlaveService.ISlaveFacade client = ServiceLocator.CreateStreamedSlaveFacade(ServerIp);
     375        Stream stream = client.GetStreamedPlugins(requestedPlugins.ToArray());
     376        ServiceLocator.DisposeSlaveClient(client);
    376377        Logger.Debug("ENDED: Getting the stream");
    377378        BinaryFormatter formatter = new BinaryFormatter();
     
    382383          stream.Dispose();
    383384        return response.List;
    384       } catch (Exception e) {
     385      }
     386      catch (Exception e) {
    385387        HandleNetworkError(e);
    386388        return null;
     
    391393      try {
    392394        Logger.Debug("STARTED: Logout");
    393         proxy.Logout(guid);
     395        SlaveService.ISlaveFacade client = ServiceLocator.CreateStreamedSlaveFacade(ServerIp);
     396        client.Logout(guid);
     397        ServiceLocator.DisposeSlaveClient(client);
    394398        Logger.Debug("ENDED: Logout");
    395       } catch (Exception e) {
     399      }
     400      catch (Exception e) {
    396401        HandleNetworkError(e);
    397402      }
     
    401406      try {
    402407        Logger.Debug("STARTED: Syncing Calendars");
    403         ResponseCalendar cal = proxy.GetCalendar(clientId);
     408        SlaveService.ISlaveFacade client = ServiceLocator.CreateStreamedSlaveFacade(ServerIp);
     409        ResponseCalendar cal = client.GetCalendar(clientId);
     410        ServiceLocator.DisposeSlaveClient(client);
    404411        Logger.Debug("ENDED: Syncing Calendars");
    405412        return cal;
    406       } catch (Exception e) {
     413      }
     414      catch (Exception e) {
    407415        HandleNetworkError(e);
    408416        return null;
     
    413421      try {
    414422        Logger.Debug("STARTED: Setting Calendar status to: " + state);
    415         Response resp = proxy.SetCalendarStatus(clientId, state);
     423        SlaveService.ISlaveFacade client = ServiceLocator.CreateStreamedSlaveFacade(ServerIp);
     424        Response resp = client.SetCalendarStatus(clientId, state);
     425        ServiceLocator.DisposeSlaveClient(client);
    416426        Logger.Debug("ENDED: Setting Calendar status to: " + state);
    417427        return resp;
    418       } catch (Exception e) {
     428      }
     429      catch (Exception e) {
    419430        HandleNetworkError(e);
    420431        return null;
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Communication/3.3/app.config

    r4333 r4337  
    2424          transactionFlow="false" transferMode="Streamed" transactionProtocol="OleTransactions"
    2525          hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="104857600"
    26           maxBufferSize="104857600" maxConnections="100" listenBacklog="100" maxReceivedMessageSize="104857600">
     26          maxBufferSize="104857600" maxReceivedMessageSize="104857600">
    2727          <readerQuotas maxDepth="32" maxStringContentLength="104857600" maxArrayLength="104857600"
    2828            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
     
    3838          transferMode="Buffered" transactionProtocol="OleTransactions"
    3939          hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
    40           maxBufferSize="65536" maxConnections="100" listenBacklog="100" maxReceivedMessageSize="65536">
     40          maxBufferSize="65536" maxReceivedMessageSize="65536">
    4141          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
    4242            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Console/3.3/app.config

    r4333 r4337  
    1919          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
    2020          transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
    21           hostNameComparisonMode="StrongWildcard" listenBacklog="100" maxBufferPoolSize="524288"
    22           maxBufferSize="65536" maxConnections="100" maxReceivedMessageSize="65536">
     21          hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288"
     22          maxBufferSize="65536" maxReceivedMessageSize="65536">
    2323          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
    2424            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Core/3.3/Core.cs

    r4333 r4337  
    8989      ConnectionContainer cc = ConfigManager.Instance.GetServerIP();
    9090      if (cc.IPAdress != String.Empty) {
    91         wcfService.SetIP(cc.IPAdress);
     91        wcfService.ServerIp = cc.IPAdress;
    9292      }
    9393    }
     
    112112      wcfService.ProcessSnapshotCompleted += new EventHandler<ProcessSnapshotCompletedEventArgs>(wcfService_ProcessSnapshotCompleted);
    113113      wcfService.ConnectionRestored += new EventHandler(wcfService_ConnectionRestored);
    114       wcfService.ServerChanged += new EventHandler(wcfService_ServerChanged);
     114      //wcfService.ServerChanged += new EventHandler(wcfService_ServerChanged);
    115115      wcfService.Connected += new EventHandler(wcfService_Connected);
    116116    }
     
    121121      wcfService.ProcessSnapshotCompleted -= new EventHandler<ProcessSnapshotCompletedEventArgs>(wcfService_ProcessSnapshotCompleted);
    122122      wcfService.ConnectionRestored -= new EventHandler(wcfService_ConnectionRestored);
    123       wcfService.ServerChanged -= new EventHandler(wcfService_ServerChanged);
     123      //wcfService.ServerChanged -= new EventHandler(wcfService_ServerChanged);
    124124      wcfService.Connected -= new EventHandler(wcfService_Connected);
    125125    }
     
    244244        } else {
    245245          Logger.Info("Storing the finished job with id: " + jId + " to hdd");
    246           JobStorageManager.PersistObjectToDisc(wcfService.ServerIP, 0, jId, sJob); // [chn] Port is not unique anymore (since we need two ports for http and net.tcp-streaming). also the port is now specified only in app.config. use port 0 for the moment
     246          JobStorageManager.PersistObjectToDisc(wcfService.ServerIp, 0, jId, sJob); // [chn] Port is not unique anymore (since we need two ports for http and net.tcp-streaming). also the port is now specified only in app.config. use port 0 for the moment
    247247          KillAppDomain(jId);
    248248        }
     
    382382    }
    383383
    384     /// <summary>
    385     /// The server has been changed. All Appdomains and Jobs must be aborted!
    386     /// </summary>
    387     /// <param name="sender"></param>
    388     /// <param name="e"></param>
    389     void wcfService_ServerChanged(object sender, EventArgs e) {
    390       Logger.Info("ServerChanged has been called");
    391       lock (engines) {
    392         foreach (KeyValuePair<Guid, Executor> entries in engines) {
    393           engines[entries.Key].Abort();
    394           //appDomains[entries.Key].UnhandledException -= new UnhandledExceptionEventHandler(appDomain_UnhandledException);
    395           //AppDomain.Unload(appDomains[entries.Key]);
    396         }
    397         //appDomains = new Dictionary<Guid, AppDomain>();
    398         //engines = new Dictionary<Guid, Executor>();
    399         //jobs = new Dictionary<Guid, Job>();
    400       }
    401     }
    402384
    403385    /// <summary>
     
    417399      Logger.Info("CalendarAvailable is " + UptimeManager.Instance.CalendarAvailable + " and IsOnline is: " + UptimeManager.Instance.IsAllowedToCalculate());
    418400      Logger.Info("Setting client online");
    419       wcfService.LoginSync(ConfigManager.Instance.GetClientInfo());
     401      wcfService.Login(ConfigManager.Instance.GetClientInfo());
    420402      JobStorageManager.CheckAndSubmitJobsFromDisc();
    421403      CurrentlyFetching = false;
    422       //}
    423404    }
    424405
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Core/3.3/HeartbeatManager.cs

    r4335 r4337  
    8484              }
    8585              if (!wcfService.LoggedIn) {
    86                 wcfService.LoginSync(ConfigManager.Instance.GetClientInfo()); // if login faild previously try again
     86                wcfService.Login(ConfigManager.Instance.GetClientInfo()); // if login faild previously try again
    8787              }
    8888
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Core/3.3/JobStorage/JobStorageManager.cs

    r4316 r4337  
    4545    public static void CheckAndSubmitJobsFromDisc() {
    4646      for (int index = storedJobsList.Count; index > 0; index--) {
    47         if (WcfService.Instance.LoggedIn && (storedJobsList[index - 1].ServerIP == WcfService.Instance.ServerIP)) {
     47        if (WcfService.Instance.LoggedIn && (storedJobsList[index - 1].ServerIP == WcfService.Instance.ServerIp)) {
    4848          String filename = storedJobsList[index - 1].ServerIP + "." + storedJobsList[index - 1].ServerPort + "." + storedJobsList[index - 1].JobID.ToString();
    4949          Logger.Info("Sending stored job " + storedJobsList[index - 1].JobID + " to the server");
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Core/3.3/SlaveConsoleService/Interfaces/ISlaveConsoleCommunicator.cs

    r4320 r4337  
    4848    /// Signals the client to disconnect from the server
    4949    /// </summary>
    50     [OperationContract]
    51     void Disconnect();
     50    //[OperationContract]
     51    //void Disconnect();
    5252    /// <summary>
    5353    /// Get the current connection details
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Core/3.3/SlaveConsoleService/SlaveConsoleCommunicator.cs

    r4320 r4337  
    2020    public void SetConnection(ConnectionContainer container) {
    2121      ConfigManager.Instance.SetServerIP(container);
    22       WcfService.Instance.Connect(container.IPAdress);
     22      //WcfService.Instance.Connect(container.IPAdress);
     23      WcfService.Instance.ServerIp = container.IPAdress;
    2324    }
    2425
    25     public void Disconnect() {
    26       WcfService.Instance.Disconnect();
    27     }   
     26    //public void Disconnect() {
     27    //  WcfService.Instance.Disconnect();
     28    //}   
    2829
    2930    public ConnectionContainer GetCurrentConnection() {
    30       return new ConnectionContainer { IPAdress = WcfService.Instance.ServerIP };
     31      return new ConnectionContainer { IPAdress = WcfService.Instance.ServerIp };
    3132    }
    3233
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.Core/3.3/app.config

    r4333 r4337  
    2626    <bindings>
    2727      <netTcpBinding>
    28         <binding name="SlaveConsoleTcpBinding" listenBacklog="100" maxConnections="100">
     28        <binding name="SlaveConsoleTcpBinding">
    2929          <security mode="None">
    3030            <transport/>
Note: See TracChangeset for help on using the changeset viewer.