Beispiel #1
0
 private async Task PublishStatistics(object _)
 {
     try
     {
         if (logger.IsVerbose)
         {
             logger.Verbose("PublishStatistics.");
         }
         List <SiloAddress> members = this.siloStatusOracle.GetApproximateSiloStatuses(true).Keys.ToList();
         var tasks   = new List <Task>();
         var myStats = new SiloRuntimeStatistics(silo.Metrics, DateTime.UtcNow);
         foreach (var siloAddress in members)
         {
             try
             {
                 tasks.Add(this.grainFactory.GetSystemTarget <IDeploymentLoadPublisher>(
                               Constants.DeploymentLoadPublisherSystemTargetId, siloAddress)
                           .UpdateRuntimeStatistics(silo.SiloAddress, myStats));
             }
             catch (Exception)
             {
                 logger.Warn(ErrorCode.Placement_RuntimeStatisticsUpdateFailure_1,
                             String.Format("An unexpected exception was thrown by PublishStatistics.UpdateRuntimeStatistics(). Ignored."));
             }
         }
         await Task.WhenAll(tasks);
     }
     catch (Exception exc)
     {
         logger.Warn(ErrorCode.Placement_RuntimeStatisticsUpdateFailure_2,
                     String.Format("An exception was thrown by PublishStatistics.UpdateRuntimeStatistics(). Ignoring."), exc);
     }
 }
 private async Task PublishStatistics(object _)
 {
     try
     {
         if(logger.IsVerbose) logger.Verbose("PublishStatistics.");
         List<SiloAddress> members = silo.LocalSiloStatusOracle.GetApproximateSiloStatuses(true).Keys.ToList();
         var tasks = new List<Task>();
         var myStats = new SiloRuntimeStatistics(silo.Metrics, DateTime.UtcNow);
         foreach (var siloAddress in members)
         {
             try
             {
                 tasks.Add(InsideRuntimeClient.Current.InternalGrainFactory.GetSystemTarget<IDeploymentLoadPublisher>(
                     Constants.DeploymentLoadPublisherSystemTargetId, siloAddress)
                     .UpdateRuntimeStatistics(silo.SiloAddress, myStats));
             }
             catch (Exception)
             {
                 logger.Warn(ErrorCode.Placement_RuntimeStatisticsUpdateFailure_1,
                     String.Format("An unexpected exception was thrown by PublishStatistics.UpdateRuntimeStatistics(). Ignored."));
             }
         }
         await Task.WhenAll(tasks);
     }
     catch (Exception exc)
     {
         logger.Warn(ErrorCode.Placement_RuntimeStatisticsUpdateFailure_2,
             String.Format("An exception was thrown by PublishStatistics.UpdateRuntimeStatistics(). Ignoring."), exc);
     }
 }
        public Task UpdateRuntimeStatistics(SiloAddress siloAddress, SiloRuntimeStatistics siloStats)
        {
            if (logger.IsVerbose) logger.Verbose("UpdateRuntimeStatistics from {0}", siloAddress);
            if (silo.LocalSiloStatusOracle.GetApproximateSiloStatus(siloAddress) != SiloStatus.Active)
                return TaskDone.Done;

            SiloRuntimeStatistics old;
            // Take only if newer.
            if (periodicStats.TryGetValue(siloAddress, out old) && old.DateTime > siloStats.DateTime)
                return TaskDone.Done;

            periodicStats[siloAddress] = siloStats;
            NotifyAllStatisticsChangeEventsSubscribers(siloAddress, siloStats);
            return TaskDone.Done;
        }
Beispiel #4
0
 private void NotifyAllStatisticsChangeEventsSubscribers(SiloAddress silo, SiloRuntimeStatistics stats)
 {
     lock (siloStatisticsChangeListeners)
     {
         foreach (var subscriber in siloStatisticsChangeListeners)
         {
             if (stats == null)
             {
                 subscriber.RemoveSilo(silo);
             }
             else
             {
                 subscriber.SiloStatisticsChangeNotification(silo, stats);
             }
         }
     }
 }
Beispiel #5
0
        public Task <SiloRuntimeStatistics> GetRuntimeStatistics()
        {
            if (logger.IsEnabled(LogLevel.Debug))
            {
                logger.LogDebug("GetRuntimeStatistics");
            }
            var activationCount = this.activationDirectory.Count;
            var stats           = new SiloRuntimeStatistics(
                activationCount,
                activationWorkingSet.Count,
                this.appEnvironmentStatistics,
                this.hostEnvironmentStatistics,
                this.loadSheddingOptions,
                DateTime.UtcNow);

            return(Task.FromResult(stats));
        }
 private async Task PublishStatistics(object _)
 {
     try
     {
         if (logger.IsEnabled(LogLevel.Trace))
         {
             logger.LogTrace("PublishStatistics");
         }
         var members                     = this.siloStatusOracle.GetApproximateSiloStatuses(true).Keys;
         var tasks                       = new List <Task>();
         var activationCount             = this.activationDirectory.Count;
         var recentlyUsedActivationCount = this.activationWorkingSet.Count;
         var myStats                     = new SiloRuntimeStatistics(
             activationCount,
             recentlyUsedActivationCount,
             this.appEnvironmentStatistics,
             this.hostEnvironmentStatistics,
             this.loadSheddingOptions,
             DateTime.UtcNow);
         foreach (var siloAddress in members)
         {
             try
             {
                 tasks.Add(this.grainFactory.GetSystemTarget <IDeploymentLoadPublisher>(
                               Constants.DeploymentLoadPublisherSystemTargetType, siloAddress)
                           .UpdateRuntimeStatistics(this.siloDetails.SiloAddress, myStats));
             }
             catch (Exception exception)
             {
                 logger.LogWarning(
                     (int)ErrorCode.Placement_RuntimeStatisticsUpdateFailure_1,
                     exception,
                     "An unexpected exception was thrown by PublishStatistics.UpdateRuntimeStatistics(). Ignored");
             }
         }
         await Task.WhenAll(tasks);
     }
     catch (Exception exc)
     {
         logger.LogWarning(
             (int)ErrorCode.Placement_RuntimeStatisticsUpdateFailure_2,
             exc,
             "An exception was thrown by PublishStatistics.UpdateRuntimeStatistics(). Ignoring");
     }
 }
Beispiel #7
0
        public Task <SiloRuntimeStatistics> GetRuntimeStatistics()
        {
            if (logger.IsEnabled(LogLevel.Debug))
            {
                logger.Debug("GetRuntimeStatistics");
            }
            var activationCount             = this.activationDirectory.Count;
            var recentlyUsedActivationCount = this.activationCollector.GetNumRecentlyUsed(TimeSpan.FromMinutes(10));
            var stats = new SiloRuntimeStatistics(
                activationCount,
                recentlyUsedActivationCount,
                this.appEnvironmentStatistics,
                this.hostEnvironmentStatistics,
                this.loadSheddingOptions,
                DateTime.UtcNow);

            return(Task.FromResult(stats));
        }
Beispiel #8
0
 private async Task PublishStatistics(object _)
 {
     try
     {
         if (logger.IsEnabled(LogLevel.Debug))
         {
             logger.Debug("PublishStatistics.");
         }
         List <SiloAddress> members = this.siloStatusOracle.GetApproximateSiloStatuses(true).Keys.ToList();
         var tasks                       = new List <Task>();
         var activationCount             = this.activationDirectory.Count;
         var recentlyUsedActivationCount = this.activationCollector.GetNumRecentlyUsed(TimeSpan.FromMinutes(10));
         var myStats                     = new SiloRuntimeStatistics(
             this.messageCenter,
             activationCount,
             recentlyUsedActivationCount,
             this.appEnvironmentStatistics,
             this.hostEnvironmentStatistics,
             this.loadSheddingOptions,
             DateTime.UtcNow);
         foreach (var siloAddress in members)
         {
             try
             {
                 tasks.Add(this.grainFactory.GetSystemTarget <IDeploymentLoadPublisher>(
                               Constants.DeploymentLoadPublisherSystemTargetId, siloAddress)
                           .UpdateRuntimeStatistics(this.siloDetails.SiloAddress, myStats));
             }
             catch (Exception)
             {
                 logger.Warn(ErrorCode.Placement_RuntimeStatisticsUpdateFailure_1,
                             String.Format("An unexpected exception was thrown by PublishStatistics.UpdateRuntimeStatistics(). Ignored."));
             }
         }
         await Task.WhenAll(tasks);
     }
     catch (Exception exc)
     {
         logger.Warn(ErrorCode.Placement_RuntimeStatisticsUpdateFailure_2,
                     String.Format("An exception was thrown by PublishStatistics.UpdateRuntimeStatistics(). Ignoring."), exc);
     }
 }
Beispiel #9
0
        public Task UpdateRuntimeStatistics(SiloAddress siloAddress, SiloRuntimeStatistics siloStats)
        {
            if (logger.IsVerbose)
            {
                logger.Verbose("UpdateRuntimeStatistics from {0}", siloAddress);
            }
            if (this.siloStatusOracle.GetApproximateSiloStatus(siloAddress) != SiloStatus.Active)
            {
                return(TaskDone.Done);
            }

            SiloRuntimeStatistics old;

            // Take only if newer.
            if (periodicStats.TryGetValue(siloAddress, out old) && old.DateTime > siloStats.DateTime)
            {
                return(TaskDone.Done);
            }

            periodicStats[siloAddress] = siloStats;
            NotifyAllStatisticsChangeEventsSubscribers(siloAddress, siloStats);
            return(TaskDone.Done);
        }
        public Task UpdateRuntimeStatistics(SiloAddress siloAddress, SiloRuntimeStatistics siloStats)
        {
            if (logger.IsEnabled(LogLevel.Trace))
            {
                logger.LogTrace("UpdateRuntimeStatistics from {Server}", siloAddress);
            }
            if (this.siloStatusOracle.GetApproximateSiloStatus(siloAddress) != SiloStatus.Active)
            {
                return(Task.CompletedTask);
            }

            SiloRuntimeStatistics old;

            // Take only if newer.
            if (periodicStats.TryGetValue(siloAddress, out old) && old.DateTime > siloStats.DateTime)
            {
                return(Task.CompletedTask);
            }

            periodicStats[siloAddress] = siloStats;
            NotifyAllStatisticsChangeEventsSubscribers(siloAddress, siloStats);
            return(Task.CompletedTask);
        }
 private void NotifyAllStatisticsChangeEventsSubscribers(SiloAddress silo, SiloRuntimeStatistics stats)
 {
     lock (siloStatisticsChangeListeners) 
     {
         foreach (var subscriber in siloStatisticsChangeListeners)
         {
             if (stats==null)
             {
                 subscriber.RemoveSilo(silo);
             }
             else
             {
                 subscriber.SiloStatisticsChangeNotification(silo, stats);
             }
         }
     }
 }