Changeset 14732


Ignore:
Timestamp:
03/08/17 11:21:07 (8 weeks ago)
Author:
jkarder
Message:

#2743: added support for multiple OKB query service endpoints

Location:
trunk/sources/HeuristicLab.Clients.OKB/3.3
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.OKB/3.3/HeuristicLab.Clients.OKB-3.3.csproj

    r13691 r14732  
    114114    <Compile Include="Administration\ServiceClient\ProblemClass.cs" />
    115115    <Compile Include="OKBRoles.cs" />
     116    <Compile Include="Properties\Settings.Designer.cs">
     117      <AutoGen>True</AutoGen>
     118      <DesignTimeSharedInput>True</DesignTimeSharedInput>
     119      <DependentUpon>Settings.settings</DependentUpon>
     120    </Compile>
    116121    <Compile Include="RunCreation\OKBSolution.cs" />
    117122    <Compile Include="Plugin.cs" />
     
    177182    <None Include="Properties\AssemblyInfo.cs.frame" />
    178183    <None Include="Administration\ServiceClient\GenerateServiceClient.cmd" />
     184    <None Include="Properties\Settings.settings">
     185      <Generator>SettingsSingleFileGenerator</Generator>
     186      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
     187    </None>
    179188    <None Include="Query\ServiceClient\GenerateServiceClient.cmd" />
    180189    <None Include="RunCreation\ServiceClient\GenerateServiceClient.cmd" />
  • trunk/sources/HeuristicLab.Clients.OKB/3.3/Query/QueryClient.cs

    r14185 r14732  
    2424using System.IO;
    2525using System.Linq;
     26using System.ServiceModel;
    2627using HeuristicLab.Clients.Common;
    2728using HeuristicLab.Common;
     
    3940      }
    4041    }
     42
     43    private int endpointRetries;
     44    private string workingEndpoint;
    4145
    4246    #region Properties
     
    6872    }
    6973    public void RefreshAsync(Action<Exception> exceptionCallback) {
    70       var call = new Func<Exception>(delegate() {
     74      var call = new Func<Exception>(delegate () {
    7175        try {
    7276          Refresh();
     
    7680        return null;
    7781      });
    78       call.BeginInvoke(delegate(IAsyncResult result) {
     82      call.BeginInvoke(delegate (IAsyncResult result) {
    7983        Exception ex = call.EndInvoke(result);
    8084        if (ex != null) exceptionCallback(ex);
     
    156160
    157161    #region Helpers
     162    private QueryServiceClient NewServiceClient() {
     163      if (endpointRetries >= Properties.Settings.Default.MaxEndpointRetries)
     164        return CreateClient(workingEndpoint);
     165
     166      var configurations = Properties.Settings.Default.EndpointConfigurationPriorities;
     167      Exception exception = null;
     168
     169      foreach (var endpointConfigurationName in configurations) {
     170        try {
     171          var cl = CreateClient(endpointConfigurationName);
     172          cl.Open();
     173          workingEndpoint = endpointConfigurationName;
     174          return cl;
     175        } catch (EndpointNotFoundException e) {
     176          exception = e;
     177          ++endpointRetries;
     178        }
     179      }
     180
     181      throw exception ?? new EndpointNotFoundException("No endpoint for Query service found.");
     182    }
     183
     184    private QueryServiceClient CreateClient(string endpointConfigurationName) {
     185      var cl = ClientFactory.CreateClient<QueryServiceClient, IQueryService>(endpointConfigurationName);
     186      return cl;
     187    }
     188
    158189    private T CallQueryService<T>(Func<IQueryService, T> call) {
    159       QueryServiceClient client = ClientFactory.CreateClient<QueryServiceClient, IQueryService>();
     190      QueryServiceClient client = NewServiceClient();
     191
    160192      try {
    161193        return call(client);
  • trunk/sources/HeuristicLab.Clients.OKB/3.3/app.config

    r11623 r14732  
    11<?xml version="1.0" encoding="utf-8"?>
    22<configuration>
     3  <configSections>
     4    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
     5      <section name="HeuristicLab.Clients.OKB.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
     6    </sectionGroup>
     7  </configSections>
    38  <system.serviceModel>
    49    <behaviors>
     
    6368    </client>
    6469  </system.serviceModel>
    65 <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
     70<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup><applicationSettings>
     71    <HeuristicLab.Clients.OKB.Properties.Settings>
     72      <setting name="EndpointConfigurationPriorities" serializeAs="Xml">
     73        <value>
     74          <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     75            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
     76            <string>WSHttpBinding_IQueryService</string>
     77          </ArrayOfString>
     78        </value>
     79      </setting>
     80      <setting name="MaxEndpointRetries" serializeAs="String">
     81        <value>3</value>
     82      </setting>
     83    </HeuristicLab.Clients.OKB.Properties.Settings>
     84  </applicationSettings>
     85</configuration>
Note: See TracChangeset for help on using the changeset viewer.