public OceanikServiceApplicationProxy(string name, OceanikServiceProxy proxy, Uri serviceAddress) : base(name, proxy, serviceAddress) { // create instance of a new load balancer _loadBalancer = new SPRoundRobinServiceLoadBalancer(serviceAddress); }
/// <summary> /// Initializes a new instance of the <see cref="ConfigServiceApplicationProxy"/> class. Use this constructor to create a new Service Application Proxy (e.g. from code on the Create page). /// </summary> /// <param name="name">The name of the Service Application Proxy to create. This name will not be localized.</param> /// <param name="serviceProxy">A reference to the Service Proxy class.</param> /// <param name="serviceEndpointUri">The endpoint uri to the service.</param> internal ConfigServiceApplicationProxy(string name, ConfigServiceProxy serviceProxy, Uri serviceEndpointUri) : base(name, serviceProxy, serviceEndpointUri) { this.loadBalancer = new SPRoundRobinServiceLoadBalancer(serviceEndpointUri); }
public ServiceApplicationProxy(string name, IdentityServiceProxy serviceProxy, Uri serviceApplicationAddress) : base(name, serviceProxy, serviceApplicationAddress) { m_LoadBalancer = new SPRoundRobinServiceLoadBalancer(serviceApplicationAddress); }
public ParagoServiceApplicationProxy(string name, ParagoServiceProxy serviceProxy, Uri serviceApplicationAddress) : base(name, serviceProxy, serviceApplicationAddress) { _loadBalancer = new SPRoundRobinServiceLoadBalancer(serviceApplicationAddress); }
public NodeServiceApplicationProxy(string name, NodeServiceProxy nodeServiceProxy, Uri serviceApplicationUri) : base(name, nodeServiceProxy, serviceApplicationUri) { _loadBalancer = new SPRoundRobinServiceLoadBalancer(serviceApplicationUri); }
public CvrServiceApplicationProxy(string name, CvrServiceProxy serviceProxy, Uri serviceEndpointUri) : base(name, serviceProxy, serviceEndpointUri) { _loadBalancer = new SPRoundRobinServiceLoadBalancer(serviceEndpointUri); }
/// <summary> /// This is the method that will execute the WCF service operation across the WCF channel. /// </summary> /// <param name="codeToExecute">A delegate, pointing to the method on the Service Contract interface that you want to run.</param> /// <param name="asProcess">Whether to run as the passed-through identity of the user (supported in claims mode), or the app pool account.</param> /// <typeparam name="TChannel">The type of channel.</typeparam> /// <remarks> /// This is a good place to use an SPMonitoredScope so that you can /// monitor execution times of your service calls. /// This method sets up the load balancer, and calls into the service application. /// If an exception occurs during the load balancer operation, make sure to report it as a failure if it is due to a /// communication issue. Otherwise, if it is an exception in your application logic or execution, do not report the failure /// to ensure that the server is not taken out of the load balancer. /// </remarks> protected void ExecuteOnChannel <TChannel>(CodeToExecuteOnChannel <TChannel> codeToExecute, bool asProcess) { if (codeToExecute == null) { throw new ArgumentNullException("codeToExecute"); } if (this.Proxy == null) { throw new EndpointNotFoundException("Could not find an endpoint because the proxy was not found."); } using (new SPMonitoredScope(string.Format(CultureInfo.InvariantCulture, "{0} - {1}", this.EndPoint, codeToExecute.Method.Name))) { SPDiagnosticsService diagSvc = SPDiagnosticsService.Local; SPServiceLoadBalancer loadBalancer = this.Proxy.LoadBalancer; if (loadBalancer == null) { diagSvc.WriteTrace(0, new SPDiagnosticsCategory("ClubCloud Service", TraceSeverity.Monitorable, EventSeverity.Error), TraceSeverity.Monitorable, "SPServiceLoadBalancerStatus.Failed: {0}", new object[] { "No Load Balancer was available." }); throw new InvalidOperationException("No Load Balancer was available."); } SPServiceLoadBalancerContext loadBalancerContext = loadBalancer.BeginOperation(); try { using (new SPServiceContextScope(this.currentServiceContext)) { ICommunicationObject channel = (ICommunicationObject)this.GetChannel <TChannel>(loadBalancerContext, asProcess); try { codeToExecute((TChannel)channel); channel.Close(); } finally { if (channel.State != CommunicationState.Closed) { channel.Abort(); } } } } catch (TimeoutException ex) { loadBalancerContext.Status = SPServiceLoadBalancerStatus.Failed; diagSvc.WriteTrace(0, new SPDiagnosticsCategory("ClubCloud Service", TraceSeverity.Monitorable, EventSeverity.Error), TraceSeverity.Monitorable, "SPServiceLoadBalancerStatus.Failed: {0}", new object[] { ex.Message }); throw; } catch (EndpointNotFoundException enfex) { loadBalancerContext.Status = SPServiceLoadBalancerStatus.Failed; diagSvc.WriteTrace(0, new SPDiagnosticsCategory("ClubCloud Service", TraceSeverity.Monitorable, EventSeverity.Error), TraceSeverity.Monitorable, "SPServiceLoadBalancerStatus.Failed: {0}", new object[] { enfex.Message }); throw; } catch (ServerTooBusyException stbex) { loadBalancerContext.Status = SPServiceLoadBalancerStatus.Failed; diagSvc.WriteTrace(0, new SPDiagnosticsCategory("ClubCloud Service", TraceSeverity.Monitorable, EventSeverity.Error), TraceSeverity.Monitorable, "SPServiceLoadBalancerStatus.Failed: {0}", new object[] { stbex.Message }); throw; } catch (CommunicationException exception) { if (!(exception is FaultException)) { loadBalancerContext.Status = SPServiceLoadBalancerStatus.Failed; } diagSvc.WriteTrace(0, new SPDiagnosticsCategory("ClubCloud Service", TraceSeverity.Monitorable, EventSeverity.Error), TraceSeverity.Monitorable, "SPServiceLoadBalancerStatus.Failed: {0}", new object[] { exception.Message }); throw; } finally { loadBalancerContext.EndOperation(); } } }
/// <summary> /// Initializes a new instance of the <see cref="ClubCloudServiceApplicationProxy"/> class. Use this constructor to create a new Service Application Proxy (e.g. from code on the Create page). /// </summary> /// <param name="name">The name of the Service Application Proxy to create. This name will not be localized.</param> /// <param name="serviceProxy">A reference to the Service Proxy class.</param> /// <param name="serviceEndpointUri">The endpoint uri to the service.</param> internal ClubCloudServiceApplicationProxy(string name, ClubCloudServiceProxy serviceProxy, Uri serviceEndpointUri) : base(name, serviceProxy, serviceEndpointUri) { this.loadBalancer = new SPRoundRobinServiceLoadBalancer(serviceEndpointUri); }