Ejemplo n.º 1
0
 protected override void OnServerStopping()
 {
     // cleanup
     DisposeHelper.SafeDispose(ref _hostConfigRuleSubs);
     // stop all services
     _logger.LogInfo("Stopping all servers...");
     foreach (ServerFarmNode node in _serverFarmDict.GetValues())
     {
         try
         {
             if (node.Server != null)
             {
                 _logger.LogInfo("Server: '{0}' stopping...", node.Key);
                 node.Server.Stop();
                 DisposeHelper.SafeDispose(ref node.Server);
                 DisposeHelper.SafeDispose(ref node.Logger);
                 _logger.LogInfo("Server: '{0}' stopped.", node.Key);
             }
             // publish result
             PublishHostConfigResult(node, null);
         }
         catch (Exception e)
         {
             _logger.Log(e);
             // publish result
             PublishHostConfigResult(node, "Exception: " + e);
         }
     }
     _logger.LogInfo("All servers stopped.");
 }
Ejemplo n.º 2
0
        private void HousekeepConnections(object notUsed)
        {
            // calls are accumulative, not discrete
            if (Interlocked.Decrement(ref _housekeepCallsPart1) > 0)
            {
                return;
            }

            try
            {
                DateTimeOffset dtCommenced  = DateTimeOffset.Now;
                int            activeCount  = 0;
                var            expiredConns = new List <IConnection>();
                foreach (IConnection connection in _connectionIndex.GetValues())
                {
                    bool removeConnection = false;
                    if (connection.HasFaulted)
                    {
                        removeConnection = true;
                        Logger.LogDebug("Connection: '{0}' faulted ({1})", connection.ClientId, connection.ReplyAddress);
                    }
                    if (connection.HasExpired)
                    {
                        removeConnection = true;
                        Logger.LogDebug("Connection: '{0}' expired ({1})", connection.ClientId, connection.ReplyAddress);
                    }
                    if (removeConnection)
                    {
                        // client not found or expired
                        expiredConns.Add(connection);
                    }
                    else
                    {
                        activeCount++;
                    }
                }
                foreach (IConnection connection in expiredConns)
                {
                    _connectionIndex.Remove(connection.ClientId);
                    _cacheEngine.DeleteConnectionState(connection.ClientId);
                }
                DateTimeOffset dtCompleted = DateTimeOffset.Now;
                TimeSpan       duration    = dtCompleted - dtCommenced;
                Logger.LogDebug("---------- Housekeep Connections ----------");
                Logger.LogDebug("Connections");
                Logger.LogDebug("  Active    : {0}", activeCount);
                Logger.LogDebug("  Expired   : {0}", expiredConns.Count);
                Logger.LogDebug("Duration    : {0}s", duration.TotalSeconds);
                Logger.LogDebug("---------- Housekeep Connections ----------");
            }
            catch (Exception e)
            {
                Logger.LogError("HousekeepConnections failed: {0}", e);
            }

            // ---------------------------------------- next part ----------------------------------------
            //Interlocked.Increment(ref _HousekeepCallsPart2);
            //_MainCommsDispatcher.Dispatch<object>(null, HousekeeperPart2);
        }
Ejemplo n.º 3
0
        private void EnsureSubscribed(Type dataType, IExpression whereExpr)
        {
            // check for existing equivalent or global subscription
            // if not found, add it and start a new subscription
            string globalSubscription = Expr.ALL.ToString();

            foreach (CacheSubscription cacheSubs in _Subscriptions.GetValues())
            {
                if (cacheSubs.CacheParams.DataType == dataType)
                {
                    if (cacheSubs.Subscription.WhereExpr.ToString() == globalSubscription)
                    {
                        return;
                    }
                    if (cacheSubs.Subscription.WhereExpr.GetHashCode() == whereExpr.GetHashCode())
                    {
                        return;
                    }
                }
            }
            // not found
            SubscribePrivate(dataType, whereExpr, false, true, false, null, null);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Gets the counters
 /// </summary>
 /// <param name="reset"></param>
 /// <returns></returns>
 public List <StatsCounter> GetCounters(bool reset)
 {
     return(_counters.GetValues(reset));
 }