Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Console/3.3/ServiceLocator.cs @ 4772

Last change on this file since 4772 was 4772, checked in by cneumuel, 13 years ago

#1260

  • added LogServiceReader to display log for slave without writing to local files
  • aborted jobs with childjobs now got back to state WaitForChildJob (instead of Offline)
  • lifecyclemanager now knows about available plugins (does not yet work perfectly)
File size: 1.7 KB
Line 
1using System;
2using System.ServiceModel;
3using HeuristicLab.Hive.Contracts;
4using HeuristicLab.Hive.Contracts.Interfaces;
5
6namespace HeuristicLab.Hive.Server.ServerConsole {
7
8  internal class ServiceLocator {
9    private static IServerConsoleFacade serverConsoleFacade = null;
10
11    internal static string Username { get; set; }
12    internal static string Password { get; set; } // [chn] TODO: Don't store plaintext password in memory!
13
14    internal static ISlaveManager GetSlaveManager() {
15      return GetServerConsoleFacade() as ISlaveManager;
16    }
17
18    internal static IJobManager GetJobManager() {
19      return GetServerConsoleFacade() as IJobManager;
20    }
21
22    internal static IServerConsoleFacade GetServerConsoleFacade() {
23      if (serverConsoleFacade == null) {
24        ChannelFactory<IServerConsoleFacade> factory = new ChannelFactory<IServerConsoleFacade>("ServerConsoleHttpEndpoint");
25        //WcfSettings.SetEndpointAddress(factory.Endpoint, Address);
26
27        factory.Credentials.UserName.UserName = Username;
28        factory.Credentials.UserName.Password = Password;
29
30        IServerConsoleFacade client = factory.CreateChannel();
31
32        ((ICommunicationObject)client).Faulted += ServiceLocator_Faulted;
33        serverConsoleFacade = client;
34      }
35      return serverConsoleFacade;
36    }
37
38    static void ServiceLocator_Faulted(object sender, EventArgs e) {
39      ((ICommunicationObject)serverConsoleFacade).Abort();
40      ((ICommunicationObject)serverConsoleFacade).Faulted -= ServiceLocator_Faulted;
41      serverConsoleFacade = null;
42    }
43
44    internal static void ShutDownFacade() {
45      serverConsoleFacade = null;
46    }
47  }
48}
Note: See TracBrowser for help on using the repository browser.