protected virtual ILoadBalanceService CreateLoadBalancerClient(DirectoryServer server, IDirectoryProvider directory) { ILoadBalanceService result; using (DisposeGuard disposeGuard = default(DisposeGuard)) { LoadBalancerClient loadBalancerClient = LoadBalancerClient.Create(server.Fqdn, directory, this.logger); disposeGuard.Add <LoadBalancerClient>(loadBalancerClient); bool flag = true; ILoadBalanceService loadBalanceService = loadBalancerClient; if (!loadBalancerClient.ServerVersion[1]) { flag = false; loadBalanceService = this.CreateCompatibilityLoadBalanceClient(server); } else if (!loadBalancerClient.ServerVersion[2]) { loadBalanceService = new SoftDeletedRemovalCapabilityDecorator(loadBalanceService, server); } if (!loadBalancerClient.ServerVersion[3]) { loadBalanceService = new ConsumerMetricsLoadBalanceCapabilityDecorator(loadBalanceService, server); } if (!loadBalancerClient.ServerVersion[5]) { loadBalanceService = new CapacitySummaryCapabilityDecorator(loadBalanceService, server, this.serviceContext); } if (flag) { disposeGuard.Success(); } result = loadBalanceService; } return(result); }
protected void ExecuteLoadBalancerCreateMethod(object[] invokeMethodInputParameters) { string serviceName = (string)ParseParameter(invokeMethodInputParameters[0]); string deploymentName = (string)ParseParameter(invokeMethodInputParameters[1]); LoadBalancerCreateParameters parameters = (LoadBalancerCreateParameters)ParseParameter(invokeMethodInputParameters[2]); var result = LoadBalancerClient.Create(serviceName, deploymentName, parameters); WriteObject(result); }
public void CorrectRequestForCreate() { var factory = Substitute.For <IConnection>(); var client = new LoadBalancerClient(factory); var body = new LoadBalancer(); client.Create(body); factory.Received().ExecuteRequest <Models.Responses.LoadBalancer>("load_balancers", null, body, "load_balancers", Method.POST); }
protected T CallClientFunction <T>(Func <ILoadBalanceService, T> func) { Server server = LocalServer.GetServer(); T result; using (LoadBalancerClient loadBalancerClient = LoadBalancerClient.Create(server.Name, NullDirectory.Instance, this.logger)) { this.logger.Log(MigrationEventType.Verbose, "Making WCF call to load balancer", new object[0]); result = func(loadBalancerClient); } return(result); }