Beispiel #1
0
        internal bool ReturnClientIntoThePool(string serverName, ServerLocatorServiceClient client)
        {
            bool result = false;

            lock (this.lockObject)
            {
                WcfProxyObjectsPerServerStack wcfProxyObjectsPerServerStack;
                if (this.m_dictionary.TryGetValue(serverName, out wcfProxyObjectsPerServerStack))
                {
                    if (wcfProxyObjectsPerServerStack.Count < WcfProxyObjectsPool.s_maximumSizeOfThePool)
                    {
                        wcfProxyObjectsPerServerStack.Push(client);
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
                else
                {
                    wcfProxyObjectsPerServerStack = new WcfProxyObjectsPerServerStack();
                    wcfProxyObjectsPerServerStack.Push(client);
                    this.m_dictionary[serverName] = wcfProxyObjectsPerServerStack;
                    result = true;
                }
            }
            return(result);
        }
Beispiel #2
0
 public ActiveCopiesCacheProvider()
 {
     this.activeCopiesList           = new List <DatabaseServerInformation>();
     this.serverLocator              = ServerLocatorServiceClient.Create("localhost");
     this.backgroundRefresh          = new Timer((double)ActiveCopiesCacheProvider.DataRefreshIntervalInMilliseconds.Value);
     this.backgroundRefresh.Elapsed += this.OnBackgroundRefresh;
     this.backgroundRefresh.Enabled  = true;
     this.Synchronize();
 }
        protected override void InternalRun()
        {
            if (!ReplicationCheckGlobals.ServerLocatorServiceCheckHasRun)
            {
                ReplicationCheckGlobals.ServerLocatorServiceCheckHasRun = true;
            }
            else
            {
                ExTraceGlobals.HealthChecksTracer.TraceDebug((long)this.GetHashCode(), "ServerLocatorServiceCheck skipping because it has already been run once.");
                base.Skip();
            }
            if (!IgnoreTransientErrors.HasPassed(base.GetDefaultErrorKey(typeof(ReplayServiceCheck))))
            {
                ExTraceGlobals.HealthChecksTracer.TraceDebug <string>((long)this.GetHashCode(), "ReplayServiceCheck didn't pass! Skipping {0}.", base.Title);
                base.Skip();
            }
            if ((ReplicationCheckGlobals.ServerConfiguration & ServerConfig.Stopped) == ServerConfig.Stopped)
            {
                ExTraceGlobals.HealthChecksTracer.TraceDebug <string>((long)this.GetHashCode(), "Stopped server! Skipping {0}.", base.Title);
                base.Skip();
            }
            string text = null;
            bool   flag = false;
            ServerLocatorServiceClient serverLocatorServiceClient = null;
            TimeSpan timeSpan = TimeSpan.FromSeconds(5.0);

            try
            {
                serverLocatorServiceClient = ServerLocatorServiceClient.Create(base.ServerName, timeSpan, timeSpan, timeSpan, timeSpan);
                serverLocatorServiceClient.GetVersion();
                flag = true;
            }
            catch (ServerLocatorClientException ex)
            {
                text = ex.Message;
            }
            catch (ServerLocatorClientTransientException ex2)
            {
                text = ex2.Message;
            }
            finally
            {
                if (serverLocatorServiceClient != null)
                {
                    serverLocatorServiceClient.Dispose();
                    serverLocatorServiceClient = null;
                }
            }
            ExTraceGlobals.HealthChecksTracer.TraceDebug <string, bool, string>((long)this.GetHashCode(), "ServerLocatorServiceCheck: TestHealth() for server '{0}' returned: healthy={1}, errMsg='{2}'", base.ServerName, flag, text);
            if (!flag)
            {
                base.Fail(Strings.ServerLocatorServiceRequestFailed(base.ServerName, text));
            }
        }
 // Token: 0x06000813 RID: 2067 RVA: 0x00020BEC File Offset: 0x0001EDEC
 private void ServerLocatorBeginGetServerList(bool batchRequest)
 {
     this.Tracer.TraceDebug <string>((long)this.GetHashCode(), "[MailboxServerLocator.ServerLocatorBeginGetServerList] Calling ServerLocatorService for on host {0}.", this.masterServer.Fqdn);
     if (this.serverLocator != null)
     {
         this.serverLocator.Dispose();
         this.serverLocator = null;
     }
     this.serverLocator      = ServerLocatorServiceClient.Create(this.masterServer.Fqdn, MailboxServerLocator.ServerLocatorCloseTimeout.Value, MailboxServerLocator.ServerLocatorOpenTimeout.Value, MailboxServerLocator.ServerLocatorReceiveTimeout.Value, MailboxServerLocator.ServerLocatorSendTimeout.Value);
     this.IsSourceCachedData = batchRequest;
     if (batchRequest)
     {
         this.serverLocator.BeginGetActiveCopiesForDatabaseAvailabilityGroup(new AsyncCallback(this.ServerLocatorAsyncCallback), batchRequest);
         return;
     }
     this.serverLocator.BeginGetServerForDatabase(this.DatabaseGuid, new AsyncCallback(this.ServerLocatorAsyncCallback), batchRequest);
 }
Beispiel #5
0
 internal void Clear()
 {
     while (Interlocked.CompareExchange(ref WcfProxyObjectsPool.s_backgroundThreadSyncPoint, -1, 0) != 0)
     {
         Thread.Yield();
     }
     lock (this.lockObject)
     {
         foreach (WcfProxyObjectsPerServerStack wcfProxyObjectsPerServerStack in this.m_dictionary.Values)
         {
             while (wcfProxyObjectsPerServerStack.Count > 0)
             {
                 ServerLocatorServiceClient serverLocatorServiceClient = wcfProxyObjectsPerServerStack.Pop();
                 serverLocatorServiceClient.Dispose(true);
             }
         }
         this.m_dictionary.Clear();
     }
     WcfProxyObjectsPool.s_backgroundThreadSyncPoint = 0;
 }
Beispiel #6
0
 public void Synchronize()
 {
     ExWatson.SendReportOnUnhandledException(delegate()
     {
         lock (ActiveCopiesCacheProvider.synchronizeLock)
         {
             try
             {
                 if (!this.serverLocator.IsUsable)
                 {
                     this.serverLocator.Dispose();
                     this.serverLocator = ServerLocatorServiceClient.Create("localhost");
                 }
                 GetActiveCopiesForDatabaseAvailabilityGroupParameters getActiveCopiesForDatabaseAvailabilityGroupParameters = new GetActiveCopiesForDatabaseAvailabilityGroupParameters();
                 getActiveCopiesForDatabaseAvailabilityGroupParameters.CachedData = false;
                 this.activeCopiesList = new List <DatabaseServerInformation>(this.serverLocator.GetActiveCopiesForDatabaseAvailabilityGroupExtended(getActiveCopiesForDatabaseAvailabilityGroupParameters));
             }
             catch (ServerLocatorClientTransientException)
             {
             }
         }
     });
 }
Beispiel #7
0
 internal void Push(ServerLocatorServiceClient client)
 {
     Interlocked.Exchange(ref this.m_lastAccessTicksUtc, DateTime.UtcNow.Ticks);
     this.m_stack.Push(client);
 }