Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Console/3.3/ServiceLocator.cs @ 4267

Last change on this file since 4267 was 4267, checked in by cneumuel, 14 years ago

renamed all database entities from "Client" to "Slave" (#1157)
made slave-heartbeats synchronous, also they send HBs when timetable disallows them to calculate. they will appear on the server as Idle bis IsAllowedToCalculate will be false (#1159)

File size: 1.7 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6using HeuristicLab.Hive.Contracts.Interfaces;
7using System.ServiceModel;
8using HeuristicLab.Hive.Contracts;
9
10namespace HeuristicLab.Hive.Server.ServerConsole {
11  internal class ServiceLocator {
12    private static IServerConsoleFacade serverConsoleFacade = null;
13
14    internal static string Address { get; set; }
15    internal static string Port { get; set; }
16
17    internal static ISlaveManager GetSlaveManager() {
18      return GetServerConsoleFacade() as ISlaveManager;
19    }
20
21    internal static IJobManager GetJobManager() {
22      return GetServerConsoleFacade() as IJobManager;
23    }
24
25    internal static IServerConsoleFacade GetServerConsoleFacade() {
26      if (serverConsoleFacade == null &&
27        Address != String.Empty &&
28        Port != String.Empty) {
29
30        ChannelFactory<IServerConsoleFacade> factory =
31          new ChannelFactory<IServerConsoleFacade>(
32            WcfSettings.GetBinding(),
33            new EndpointAddress("net.tcp://" + Address + ":" + Port + "/HiveServerConsole/ServerConsoleFacade"));
34                         
35        serverConsoleFacade = factory.CreateChannel();
36        ((ICommunicationObject)serverConsoleFacade).Faulted += ServiceLocator_Faulted;
37      }
38     
39      return serverConsoleFacade;
40    }
41
42    static void ServiceLocator_Faulted(object sender, EventArgs e) {
43      ((ICommunicationObject)serverConsoleFacade).Abort();
44      ((ICommunicationObject)serverConsoleFacade).Faulted -= ServiceLocator_Faulted;
45      serverConsoleFacade = null;
46    }
47
48    internal static void ShutDownFacade() {
49      serverConsoleFacade = null;
50    }
51  }
52}
Note: See TracBrowser for help on using the repository browser.