Changeset 4285


Ignore:
Timestamp:
08/23/10 13:07:11 (12 years ago)
Author:
cneumuel
Message:
  • changed Hive.Server WCF services to be configurable in app.config
  • changed endpoints to wsHttpBinding
  • changed project type of Hive.Server.Core to WCF Service Library, so that it can be started directly to be able to test the service (and update references) (#1159)
Location:
branches/3.3-HiveMigration/sources/HeuristicLab.Hive
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive 3.3.sln

    r4253 r4285  
    492492  EndGlobalSection
    493493  GlobalSection(NestedProjects) = preSolution
    494     {89F4BC52-C174-481E-9BD2-3814171020E8} = {DC8C63A5-7B57-4B3A-A74A-6F42C7DD1668}
    495     {AEB51212-CDBA-4FC6-A2EE-02359AA53ECE} = {DC8C63A5-7B57-4B3A-A74A-6F42C7DD1668}
    496     {8B14A35E-DBDF-43EB-B019-23E9FBC5A35E} = {DC8C63A5-7B57-4B3A-A74A-6F42C7DD1668}
    497     {5010BD86-23B7-4F8C-888A-76D21AD5266A} = {DC8C63A5-7B57-4B3A-A74A-6F42C7DD1668}
    498     {1605256A-1CB3-44AB-AAFF-577093EE5789} = {DC8C63A5-7B57-4B3A-A74A-6F42C7DD1668}
    499494    {A04AE929-D0E1-466D-A9D3-BF3C4B2C209F} = {E7D8EFDA-B0CB-4B62-8EAE-2CF473F14D74}
    500495    {42A1D075-6C12-4DD9-B0C2-C6F5210A8119} = {E7D8EFDA-B0CB-4B62-8EAE-2CF473F14D74}
     
    516511    {5CDACE54-5FB2-4344-A21C-963F63CB7C2B} = {BD1DE6F6-A188-4D1F-9681-BA7104818370}
    517512    {D17A4D6A-4CAA-4470-8A19-F42463C021FD} = {BD1DE6F6-A188-4D1F-9681-BA7104818370}
     513    {89F4BC52-C174-481E-9BD2-3814171020E8} = {DC8C63A5-7B57-4B3A-A74A-6F42C7DD1668}
     514    {AEB51212-CDBA-4FC6-A2EE-02359AA53ECE} = {DC8C63A5-7B57-4B3A-A74A-6F42C7DD1668}
     515    {8B14A35E-DBDF-43EB-B019-23E9FBC5A35E} = {DC8C63A5-7B57-4B3A-A74A-6F42C7DD1668}
     516    {5010BD86-23B7-4F8C-888A-76D21AD5266A} = {DC8C63A5-7B57-4B3A-A74A-6F42C7DD1668}
     517    {1605256A-1CB3-44AB-AAFF-577093EE5789} = {DC8C63A5-7B57-4B3A-A74A-6F42C7DD1668}
    518518    {55B89815-F3E7-4D09-9442-273F849141DD} = {4F2D8149-D608-42B3-BB1C-6909BDA2B350}
    519519  EndGlobalSection
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Contracts/3.3/Interfaces/IServerConsoleFacade.cs

    r4263 r4285  
    3232  /// Facade for the server management console
    3333  /// </summary>
    34   [ServiceContract(SessionMode=SessionMode.Required)]
     34  [ServiceContract()]
    3535  public interface IServerConsoleFacade : ISlaveManager,
    3636    IJobManager {
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Contracts/3.3/WcfSettings.cs

    r2607 r4285  
    7373    /// </summary>
    7474    /// <returns></returns>
    75     public static string GetActiveIP() {
    76       return System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections()[0].LocalEndPoint.Address.ToString();
     75    public static IPAddress GetActiveIP() {
     76      //return System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections()[0].LocalEndPoint.Address.ToString();
     77      IPAddress[] addresses;
     78      addresses = Dns.GetHostAddresses(Dns.GetHostName());
     79      int index = 0;
     80      if (System.Environment.OSVersion.Version.Major >= 6) {
     81        for (index = addresses.Length - 1; index >= 0; index--)
     82          if (addresses[index].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
     83            break;
     84      }
     85      return addresses[index];
    7786    }
    7887
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/DefaultScheduler.cs

    r4267 r4285  
    3131        using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = ApplicationConstants.ISOLATION_LEVEL_SCOPE })) {
    3232          SlaveDto slave = DaoLocator.SlaveDao.FindById(slaveId);
    33           LinkedList<JobDto> allOfflineJobsForSlave = new LinkedList<JobDto>(DaoLocator.JobDao.FindFittingJobsForSlave(JobState.Offline, slave.NrOfFreeCores, slave.FreeMemory, slave.Id));
    34           if (allOfflineJobsForSlave != null && allOfflineJobsForSlave.Count > 0) {
    35             jobToCalculate = allOfflineJobsForSlave.First.Value;
    36             jobToCalculate.State = JobState.Calculating;
    37             jobToCalculate.Slave = slave;
    38             jobToCalculate.Slave.State = SlaveState.Calculating;
    39             jobToCalculate.DateCalculated = DateTime.Now;
    40             DaoLocator.JobDao.AssignSlaveToJob(slave.Id, jobToCalculate.Id);
    41             DaoLocator.JobDao.Update(jobToCalculate);
    42             DaoLocator.SlaveDao.Update(jobToCalculate.Slave);
     33          if (slave != null) {
     34            LinkedList<JobDto> allOfflineJobsForSlave = new LinkedList<JobDto>(DaoLocator.JobDao.FindFittingJobsForSlave(JobState.Offline, slave.NrOfFreeCores, slave.FreeMemory, slave.Id));
     35            if (allOfflineJobsForSlave != null && allOfflineJobsForSlave.Count > 0) {
     36              jobToCalculate = allOfflineJobsForSlave.First.Value;
     37              jobToCalculate.State = JobState.Calculating;
     38              jobToCalculate.Slave = slave;
     39              jobToCalculate.Slave.State = SlaveState.Calculating;
     40              jobToCalculate.DateCalculated = DateTime.Now;
     41              DaoLocator.JobDao.AssignSlaveToJob(slave.Id, jobToCalculate.Id);
     42              DaoLocator.JobDao.Update(jobToCalculate);
     43              DaoLocator.SlaveDao.Update(jobToCalculate.Slave);
     44            }
    4345          }
    4446          scope.Complete();
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/HeuristicLab.Hive.Server.Core-3.3.csproj

    r4267 r4285  
    1111    <RootNamespace>HeuristicLab.Hive.Server.Core</RootNamespace>
    1212    <AssemblyName>HeuristicLab.Hive.Server.Core-3.3</AssemblyName>
     13    <ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    1314    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
    1415    <FileAlignment>512</FileAlignment>
     
    9697    </Reference>
    9798    <Reference Include="System.Drawing" />
     99    <Reference Include="System.Runtime.Serialization" />
    98100    <Reference Include="System.ServiceModel">
    99101      <RequiredTargetFramework>3.0</RequiredTargetFramework>
     
    143145  </ItemGroup>
    144146  <ItemGroup>
     147    <None Include="app.config" />
    145148    <None Include="HeuristicLab.snk" />
    146149    <EmbeddedResource Include="Authorization\HivePermissionSet.xsd">
     
    185188    </ProjectReference>
    186189  </ItemGroup>
    187   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
     190  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
     191  <ProjectExtensions>
     192    <VisualStudio>
     193      <FlavorProperties GUID="{3D9AD99F-2412-4246-B90B-4EAA41C64699}">
     194        <WcfProjectProperties>
     195          <AutoStart>False</AutoStart>
     196        </WcfProjectProperties>
     197      </FlavorProperties>
     198    </VisualStudio>
     199  </ProjectExtensions>
    188200  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
    189201       Other similar extension points exist, see Microsoft.Common.targets.
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/SlaveCommunicator.cs

    r4267 r4285  
    3434using HeuristicLab.Tracing;
    3535using HeuristicLab.Hive.Contracts.ResponseObjects;
     36using System.Security.Permissions;
    3637
    3738namespace HeuristicLab.Hive.Server.Core {
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server/3.3/HeuristicLab.Hive.Server-3.3.csproj

    r4254 r4285  
    109109      <RequiredTargetFramework>3.0</RequiredTargetFramework>
    110110    </Reference>
     111    <Reference Include="System.ServiceProcess" />
    111112    <Reference Include="System.Transactions" />
    112113    <Reference Include="System.Xml.Linq">
     
    149150    </ProjectReference>
    150151  </ItemGroup>
    151   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
     152  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
    152153  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
    153154       Other similar extension points exist, see Microsoft.Common.targets.
     
    165166call PreBuildEvent.cmd</PreBuildEvent>
    166167  </PropertyGroup>
     168  <PropertyGroup>
     169    <PostBuildEvent>
     170    </PostBuildEvent>
     171  </PropertyGroup>
    167172</Project>
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server/3.3/HeuristicLabHiveServerApplication.cs

    r4267 r4285  
    3535  [Application("Hive Server", "Server application for the distributed hive engine.", true)]
    3636  public class HeuristicLabHiveServerApplication : ApplicationBase {
    37     public const string STR_SlaveCommunicator = "SlaveCommunicator";
     37    public const string STR_SlaveCommunicator = "HiveServer";
    3838    public const string STR_ServerConsoleFacade = "ServerConsoleFacade";
    3939    public const string STR_ExecutionEngineFacade = "ExecutionEngineFacade";
    40 
    41     private Dictionary<string, ServiceHost> runningServices = new Dictionary<string, ServiceHost>();
    42     private NetTcpBinding binding = (NetTcpBinding)WcfSettings.GetBinding();
    43     private NetTcpBinding streamedBinding = (NetTcpBinding)WcfSettings.GetStreamedBinding();
    44 
    45     private enum Services {
    46       SlaveCommunicator,
    47       ServerConsoleFacade,
    48       ExecutionEngineFacade,
    49       All
    50     }
    51 
    52     private bool AddMexEndpoint(ServiceHost serviceHost) {
    53       if (serviceHost != null) {
    54         ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();
    55         serviceHost.Description.Behaviors.Add(behavior);
    56 
    57         return serviceHost.AddServiceEndpoint(
    58           typeof(IMetadataExchange),
    59           MetadataExchangeBindings.CreateMexTcpBinding(),
    60           "mex") != null;
    61       } else
    62         return false;
    63     }
    64 
    65     private Uri StartService(Services svc, IPAddress ipAddress, int port) {
    66       string curServiceHost = "";
    67       Uri uriTcp;
    68       ISlaveFacade clientCommunicatorInstance = ApplicationManager.Manager.GetInstances<ISlaveFacade>().First();
    69       IServerConsoleFacade serverConsoleInstance = ApplicationManager.Manager.GetInstances<IServerConsoleFacade>().First();
    70       IExecutionEngineFacade executionEngineInstance = ApplicationManager.Manager.GetInstances<IExecutionEngineFacade>().First();
    71       //SpringServiceHost serviceHost = null;
    72       ServiceHost serviceHost = null;
    73 
    74       switch (svc) {
    75         case Services.SlaveCommunicator:
    76           //  if (clientCommunicatorInstances.Count() > 0) {
    77           uriTcp = new Uri("net.tcp://" + ipAddress + ":" + port + "/HiveServer/");
    78           serviceHost = new ServiceHost(clientCommunicatorInstance.GetType(), uriTcp);
    79           //serviceHost = new ServiceHost(typeof(SlaveFacade), uriTcp);
    80           //serviceHost = new SpringServiceHost("clientFacade", uriTcp);
    81           serviceHost.AddServiceEndpoint(typeof(ISlaveFacade), streamedBinding, STR_SlaveCommunicator);
    82 
    83           ServiceDebugBehavior sdb = serviceHost.Description.Behaviors.Find<ServiceDebugBehavior>();
    84           if (sdb == null) {
    85             sdb = new ServiceDebugBehavior();
    86             serviceHost.Description.Behaviors.Add(sdb);
    87           }
    88           sdb.IncludeExceptionDetailInFaults = true;
    89 
    90 
    91 
    92           curServiceHost = STR_SlaveCommunicator;
    93           //  }
    94           break;
    95         case Services.ServerConsoleFacade:
    96           //  if (serverConsoleInstances.Count() > 0) {
    97           uriTcp = new Uri("net.tcp://" + ipAddress + ":" + port + "/HiveServerConsole/");
    98           serviceHost = new ServiceHost(serverConsoleInstance.GetType(), uriTcp);
    99           //serviceHost = new SpringServiceHost("serverConsoleFacade", uriTcp);
    100           serviceHost.AddServiceEndpoint(typeof(IServerConsoleFacade), binding, STR_ServerConsoleFacade);
    101           curServiceHost = STR_ServerConsoleFacade;
    102           //  }
    103           break;
    104         case Services.ExecutionEngineFacade:
    105           //  if (executionEngineInstances.Count() > 0) {
    106           uriTcp = new Uri("net.tcp://" + ipAddress + ":" + port + "/ExecutionEngine/");
    107           serviceHost = new ServiceHost(executionEngineInstance.GetType(), uriTcp);
    108           //serviceHost = new SpringServiceHost("executionEngineFacade", uriTcp);
    109           serviceHost.AddServiceEndpoint(typeof(IExecutionEngineFacade), streamedBinding, STR_ExecutionEngineFacade);
    110           curServiceHost = STR_ExecutionEngineFacade;
    111           //  }
    112           break;
    113         case Services.All:
    114           throw new InvalidOperationException("Not supported!");
    115         default:
    116           return null;
    117       }
    118       if (!String.IsNullOrEmpty(curServiceHost)) {
    119         AddMexEndpoint(serviceHost);
    120         //WcfSettings.SetServiceCertificate(serviceHost);
    121         serviceHost.Open();
    122         runningServices.Add(curServiceHost, serviceHost);
    123         return serviceHost.BaseAddresses[0];
    124       } else
    125         return null;
    126     }
    127 
    128     private void StopService(Services svc) {
    129       ServiceHost svcHost = null;
    130       switch (svc) {
    131         case Services.SlaveCommunicator:
    132           runningServices.TryGetValue(STR_SlaveCommunicator, out svcHost);
    133           break;
    134         case Services.ServerConsoleFacade:
    135           runningServices.TryGetValue(STR_ServerConsoleFacade, out svcHost);
    136           break;
    137         case Services.ExecutionEngineFacade:
    138           runningServices.TryGetValue(STR_ExecutionEngineFacade, out svcHost);
    139           break;
    140         case Services.All:
    141           foreach (KeyValuePair<string, ServiceHost> item in runningServices)
    142             item.Value.Close();
    143           return;
    144         default:
    145           throw new InvalidOperationException("Not supported!");
    146       }
    147       svcHost.Close();
    148     }
     40    Dictionary<string, Uri> baseAddrDict = new Dictionary<string, Uri>();
    14941
    15042    public override void Run() {
    151       IPAddress[] addresses = Dns.GetHostAddresses(Dns.GetHostName());
    152       int index = 0;
    153       if (System.Environment.OSVersion.Version.Major >= 6) {
    154         for (index = addresses.Length - 1; index >= 0; index--)
    155           if (addresses[index].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
    156             break;
    157       }
     43      ServiceHost slaveHost = new ServiceHost(ApplicationManager.Manager.GetTypes(typeof(ISlaveFacade)).First(), GetUri(STR_SlaveCommunicator));
     44      slaveHost.Open();
    15845
    159       //Start services and record their base address
    160       Dictionary<string, Uri> baseAddrDict = new Dictionary<string, Uri>();
    161       baseAddrDict.Add(STR_SlaveCommunicator, StartService(Services.SlaveCommunicator, addresses[index], WcfSettings.DEFAULTPORT));
    162       baseAddrDict.Add(STR_ServerConsoleFacade, StartService(Services.ServerConsoleFacade, addresses[index], WcfSettings.DEFAULTPORT));
    163       baseAddrDict.Add(STR_ExecutionEngineFacade, StartService(Services.ExecutionEngineFacade, addresses[index], WcfSettings.DEFAULTPORT));
     46      ServiceHost serverConsoleHost = new ServiceHost(ApplicationManager.Manager.GetTypes(typeof(IServerConsoleFacade)).First(), GetUri(STR_ServerConsoleFacade));
     47      serverConsoleHost.Open();
     48
     49      ServiceHost executionEngineHost = new ServiceHost(ApplicationManager.Manager.GetTypes(typeof(IExecutionEngineFacade)).First(), GetUri(STR_ExecutionEngineFacade));
     50      executionEngineHost.Open();
    16451
    16552      ILifecycleManager lifecycleManager = ServiceLocator.GetLifecycleManager();
    166 
    16753      lifecycleManager.Init();
    16854
     
    17056      Application.Run();
    17157
     58      slaveHost.Close();
     59      serverConsoleHost.Close();
     60      executionEngineHost.Close();
     61
    17262      lifecycleManager.Shutdown();
    173      
    174       StopService(Services.All);
    17563    }
     64
     65    private Uri GetUri(string serviceName) {
     66      string ipAddress = WcfSettings.GetActiveIP().ToString();
     67      string port = WcfSettings.DEFAULTPORT.ToString();
     68      Uri uriHttp = new Uri("http://" + ipAddress + ":" + port + "/" + serviceName + "/");
     69      baseAddrDict.Add(serviceName, uriHttp);
     70      return uriHttp;
     71    }
     72
    17673  }
    17774}
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Slave.ExecutionEngine/3.3/Executor.cs

    r4253 r4285  
    7777    public void Abort() {
    7878      CurrentMessage = MessageContainer.MessageType.AbortJob;
    79       Job.Stop();
     79      if (Job.ExecutionState != Core.ExecutionState.Stopped) {
     80        Job.Stop();
     81      }
    8082    }
    8183
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive/3.3/Files.txt

    r4253 r4285  
    1414HeuristicLab.Hive.Slave.ExecutionEngine\3.3:HeuristicLab.Hive.Slave.ExecutionEngine-3.3.dll
    1515
    16 HeuristicLab.Hive.Engine\3.3:HeuristicLab.Hive.Engine-3.3.dll
    1716HeuristicLab.Hive.Experiment\3.3:HeuristicLab.Hive.Experiment-3.3.dll
    1817HeuristicLab.Hive.Experiment.Views\3.3:HeuristicLab.Hive.Experiment.Views-3.3.dll
     
    3837;HeuristicLab.Security.Server\3.3:HeuristicLab.Security.Server-3.3.dll
    3938
    40 ;External Libraries
    41 ;HeuristicLab.ExtLibs\HeuristicLab.SpringNET\1.3.0:HeuristicLab.SpringNET-1.3.0.dll
    42 ;HeuristicLab.ExtLibs\HeuristicLab.SpringNET\1.3.0:Common.Logging.dll
    43 ;HeuristicLab.ExtLibs\HeuristicLab.SpringNET\1.3.0:Spring.Aop.dll
    44 ;HeuristicLab.ExtLibs\HeuristicLab.SpringNET\1.3.0:Spring.Core.dll
    45 ;HeuristicLab.ExtLibs\HeuristicLab.SpringNET\1.3.0:Spring.Services.dll
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive/3.3/HeuristicLab 3.3.exe.config

    r4136 r4285  
    1010  <connectionStrings>
    1111  </connectionStrings>
     12 
     13  <!-- [chn] TODO: system.web should be located in HeuristicLab.Hive.Server.Core/app.config, but the ConfigMerger does not merge system.web (yet) -->
     14  <system.web>
     15    <membership>
     16      <providers>
     17        <clear/>
     18        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="HeuristicLab.Authentication"
     19             enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
     20             maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
     21             applicationName="HeuristicLab.Authentication" />
     22      </providers>
     23    </membership>
     24
     25    <roleManager enabled="true">
     26      <providers>
     27        <clear/>
     28        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="HeuristicLab.Authentication" applicationName="HeuristicLab.Authentication" />
     29      </providers>
     30    </roleManager>
     31  </system.web>
     32 
    1233  <system.serviceModel>
    1334    <behaviors>
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive/3.3/MergeConfigs.cmd

    r4253 r4285  
     1
     2
     3ConfigMerger "%SolutionDir%HeuristicLab.Hive.Experiment\3.3\app.config" "HeuristicLab.Hive-3.3.dll.config"
     4ConfigMerger "%SolutionDir%HeuristicLab.Hive.Server.Core\3.3\app.config" "HeuristicLab.Hive-3.3.dll.config"
    15ConfigMerger "%SolutionDir%HeuristicLab.Hive.Server.LINQDataAccess\3.3\app.config" "HeuristicLab.Hive-3.3.dll.config"
    26ConfigMerger "%SolutionDir%HeuristicLab.Hive.Slave.Core\3.3\app.config" "HeuristicLab.Hive-3.3.dll.config"
    3 ConfigMerger "%SolutionDir%HeuristicLab.Hive.Experiment\3.3\app.config" "HeuristicLab.Hive-3.3.dll.config"
    47ConfigMerger "%SolutionDir%HeuristicLab.Hive.Tracing\3.3\app.config" "HeuristicLab.Hive-3.3.dll.config"
    58
Note: See TracChangeset for help on using the changeset viewer.