Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ServerClient"/> class.
 /// </summary>
 /// <param name="url">The URL.</param>
 /// <param name="convention">The convention.</param>
 /// <param name="credentials">The credentials.</param>
 /// <param name="replicationInformer">The replication informer.</param>
 public ServerClient(string url, DocumentConvention convention, ICredentials credentials, ReplicationInformer replicationInformer, HttpJsonRequestFactory jsonRequestFactory)
 {
     this.credentials         = credentials;
     this.jsonRequestFactory  = jsonRequestFactory;
     this.replicationInformer = replicationInformer;
     this.url          = url;
     this.convention   = convention;
     OperationsHeaders = new NameValueCollection();
     replicationInformer.UpdateReplicationInformationIfNeeded(this);
 }
Пример #2
0
        public HttpJsonRequest AddReplicationStatusHeaders(string thePrimaryUrl, string currentUrl, ReplicationInformer replicationInformer, FailoverBehavior failoverBehavior, Action <NameValueCollection, string, string> handleReplicationStatusChanges)
        {
            if (thePrimaryUrl.Equals(currentUrl, StringComparison.InvariantCultureIgnoreCase))
            {
                return(this);
            }
            if (replicationInformer.GetFailureCount(thePrimaryUrl) <= 0)
            {
                return(this);                // not because of failover, no need to do this.
            }
            var lastPrimaryCheck = replicationInformer.GetFailureLastCheck(thePrimaryUrl);

            webRequest.Headers.Add(Constants.RavenClientPrimaryServerUrl, ToRemoteUrl(thePrimaryUrl));
            webRequest.Headers.Add(Constants.RavenClientPrimaryServerLastCheck, lastPrimaryCheck.ToString("s"));

            primaryUrl   = thePrimaryUrl;
            operationUrl = currentUrl;

            HandleReplicationStatusChanges = handleReplicationStatusChanges;

            return(this);
        }