Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/28/13 12:05:53 (11 years ago)
Author:
ascheibe
Message:

#2030 merged hive performance branch back into trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/HiveServiceLocator.cs

    r9456 r9665  
    3535    }
    3636
     37    private HiveServiceLocator() {
     38    }
     39
    3740    private string username;
    3841    public string Username {
     
    4750    }
    4851
     52    public int EndpointRetries { get; private set; }
     53
     54    public string WorkingEndpoint { get; private set; }
     55
    4956    private HiveServiceClient NewServiceClient() {
    50       HiveServiceClient cl;
     57      if (EndpointRetries >= Settings.Default.MaxEndpointRetries) {
     58        return CreateClient(WorkingEndpoint);
     59      }
     60
     61      var configurations = Settings.Default.EndpointConfigurationPriorities;
     62
     63      Exception exception = null;
     64      foreach (var endpointConfigurationName in configurations) {
     65        try {
     66          var cl = CreateClient(endpointConfigurationName);
     67          cl.Open();
     68          WorkingEndpoint = endpointConfigurationName;
     69          return cl;
     70        }
     71        catch (Exception exc) {
     72          exception = exc;
     73          EndpointRetries++;
     74        }
     75      }
     76
     77      throw exception ?? new Exception("No endpoint for Hive service found.");
     78    }
     79
     80    private HiveServiceClient CreateClient(string endpointConfigurationName) {
     81      HiveServiceClient cl = null;
     82
    5183      if (string.IsNullOrEmpty(username) && string.IsNullOrEmpty(password))
    52         cl = ClientFactory.CreateClient<HiveServiceClient, IHiveService>();
     84        cl = ClientFactory.CreateClient<HiveServiceClient, IHiveService>(endpointConfigurationName);
    5385      else
    54         cl = ClientFactory.CreateClient<HiveServiceClient, IHiveService>(null, null, username, password);
     86        cl = ClientFactory.CreateClient<HiveServiceClient, IHiveService>(endpointConfigurationName, null, username, password);
    5587
    5688      return cl;
Note: See TracChangeset for help on using the changeset viewer.