public ProxiedMessageCenter(ClientConfiguration config, IPAddress localAddress, int gen, GrainId clientId, IGatewayListProvider gatewayListProvider)
 {
     lockable  = new object();
     MyAddress = SiloAddress.New(new IPEndPoint(localAddress, 0), gen);
     ClientId  = clientId;
     Running   = false;
     MessagingConfiguration     = config;
     GatewayManager             = new GatewayManager(config, gatewayListProvider);
     PendingInboundMessages     = new RuntimeQueue <Message>();
     registrarGetSystemTarget   = GrainClient.GetStaticMethodThroughReflection("Orleans", "Orleans.Runtime.ClientObserverRegistrarFactory", "GetSystemTarget", null);
     typeManagerGetSystemTarget = GrainClient.GetStaticMethodThroughReflection("Orleans", "Orleans.Runtime.TypeManagerFactory", "GetSystemTarget", null);
     gatewayConnections         = new Dictionary <Uri, GatewayConnection>();
     numMessages            = 0;
     registeredLocalObjects = new HashSet <GrainId>();
     grainBuckets           = new WeakReference[config.ClientSenderBuckets];
     logger = TraceLogger.GetLogger("Messaging.ProxiedMessageCenter", TraceLogger.LoggerType.Runtime);
     if (logger.IsVerbose)
     {
         logger.Verbose("Proxy grain client constructed");
     }
     IntValueStatistic.FindOrCreate(StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () =>
     {
         lock (gatewayConnections)
         {
             return(gatewayConnections.Values.Count(conn => conn.IsLive));
         }
     });
     if (StatisticsCollector.CollectQueueStats)
     {
         queueTracking = new QueueTrackingStatistic("ClientReceiver");
     }
 }
 public ProxiedMessageCenter(ClientConfiguration config, IPAddress localAddress, int gen, GrainId clientId, IGatewayListProvider gatewayListProvider)
 {
     lockable  = new object();
     MyAddress = SiloAddress.New(new IPEndPoint(localAddress, 0), gen);
     ClientId  = clientId;
     Running   = false;
     MessagingConfiguration = config;
     GatewayManager         = new GatewayManager(config, gatewayListProvider);
     PendingInboundMessages = new BlockingCollection <Message>();
     gatewayConnections     = new Dictionary <Uri, GatewayConnection>();
     numMessages            = 0;
     grainBuckets           = new WeakReference[config.ClientSenderBuckets];
     logger = LogManager.GetLogger("Messaging.ProxiedMessageCenter", LoggerType.Runtime);
     if (logger.IsVerbose)
     {
         logger.Verbose("Proxy grain client constructed");
     }
     IntValueStatistic.FindOrCreate(StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT, () =>
     {
         lock (gatewayConnections)
         {
             return(gatewayConnections.Values.Count(conn => conn.IsLive));
         }
     });
     if (StatisticsCollector.CollectQueueStats)
     {
         queueTracking = new QueueTrackingStatistic("ClientReceiver");
     }
 }
Exemple #3
0
        public ThreadPoolTrackingStatistic(string name, ILoggerFactory loggerFactory)
        {
            if (StatisticsCollector.CollectQueueStats)
            {
                queueTracking = new QueueTrackingStatistic(name);
            }

            if (ExecutorOptions.CollectDetailedThreadStatistics)
            {
                threadTracking = new ThreadTrackingStatistic(name, loggerFactory);
            }
        }
 public ClientMessageCenter(
     IOptions <GatewayOptions> gatewayOptions,
     IOptions <ClientMessagingOptions> clientMessagingOptions,
     IPAddress localAddress,
     int gen,
     GrainId clientId,
     IGatewayListProvider gatewayListProvider,
     SerializationManager serializationManager,
     IRuntimeClient runtimeClient,
     MessageFactory messageFactory,
     IClusterConnectionStatusListener connectionStatusListener,
     ExecutorService executorService,
     ILoggerFactory loggerFactory,
     IOptions <NetworkingOptions> networkingOptions,
     IOptions <StatisticsOptions> statisticsOptions)
 {
     this.loggerFactory         = loggerFactory;
     this.openConnectionTimeout = networkingOptions.Value.OpenConnectionTimeout;
     this.SerializationManager  = serializationManager;
     this.executorService       = executorService;
     lockable                      = new object();
     MyAddress                     = SiloAddress.New(new IPEndPoint(localAddress, 0), gen);
     ClientId                      = clientId;
     this.RuntimeClient            = runtimeClient;
     this.messageFactory           = messageFactory;
     this.connectionStatusListener = connectionStatusListener;
     Running                = false;
     GatewayManager         = new GatewayManager(gatewayOptions.Value, gatewayListProvider, loggerFactory);
     PendingInboundMessages = new BlockingCollection <Message>();
     gatewayConnections     = new Dictionary <Uri, GatewayConnection>();
     numMessages            = 0;
     grainBuckets           = new WeakReference[clientMessagingOptions.Value.ClientSenderBuckets];
     logger = loggerFactory.CreateLogger <ClientMessageCenter>();
     if (logger.IsEnabled(LogLevel.Debug))
     {
         logger.Debug("Proxy grain client constructed");
     }
     IntValueStatistic.FindOrCreate(
         StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT,
         () =>
     {
         lock (gatewayConnections)
         {
             return(gatewayConnections.Values.Count(conn => conn.IsLive));
         }
     });
     statisticsLevel = statisticsOptions.Value.CollectionLevel;
     if (statisticsLevel.CollectQueueStats())
     {
         queueTracking = new QueueTrackingStatistic("ClientReceiver", statisticsOptions);
     }
 }
Exemple #5
0
        public ThreadPoolTrackingStatistic(string name, ILoggerFactory loggerFactory, IOptions <StatisticsOptions> statisticsOptions, StageAnalysisStatisticsGroup schedulerStageStatistics)
        {
            this.statisticsLevel = statisticsOptions.Value.CollectionLevel;
            if (statisticsLevel.CollectQueueStats())
            {
                queueTracking = new QueueTrackingStatistic(name, statisticsOptions);
            }

            if (this.statisticsLevel.CollectDetailedThreadStatistics())
            {
                threadTracking = new ThreadTrackingStatistic(name, loggerFactory, statisticsOptions, schedulerStageStatistics);
            }
        }
Exemple #6
0
 public ClientMessageCenter(
     IOptions <ClientMessagingOptions> clientMessagingOptions,
     IPAddress localAddress,
     int gen,
     GrainId clientId,
     SerializationManager serializationManager,
     IRuntimeClient runtimeClient,
     MessageFactory messageFactory,
     IClusterConnectionStatusListener connectionStatusListener,
     ILoggerFactory loggerFactory,
     IOptions <StatisticsOptions> statisticsOptions,
     ConnectionManager connectionManager,
     GatewayManager gatewayManager)
 {
     this.messageHandlers      = new Action <Message> [Enum.GetValues(typeof(Message.Categories)).Length];
     this.connectionManager    = connectionManager;
     this.SerializationManager = serializationManager;
     MyAddress                     = SiloAddress.New(new IPEndPoint(localAddress, 0), gen);
     ClientId                      = clientId;
     this.RuntimeClient            = runtimeClient;
     this.messageFactory           = messageFactory;
     this.connectionStatusListener = connectionStatusListener;
     Running                = false;
     this.gatewayManager    = gatewayManager;
     PendingInboundMessages = Channel.CreateUnbounded <Message>(new UnboundedChannelOptions
     {
         SingleReader = true,
         SingleWriter = false,
         AllowSynchronousContinuations = false
     });
     numMessages       = 0;
     this.grainBuckets = new WeakReference <Connection> [clientMessagingOptions.Value.ClientSenderBuckets];
     logger            = loggerFactory.CreateLogger <ClientMessageCenter>();
     if (logger.IsEnabled(LogLevel.Debug))
     {
         logger.Debug("Proxy grain client constructed");
     }
     IntValueStatistic.FindOrCreate(
         StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT,
         () =>
     {
         return(connectionManager.ConnectionCount);
     });
     statisticsLevel = statisticsOptions.Value.CollectionLevel;
     if (statisticsLevel.CollectQueueStats())
     {
         queueTracking = new QueueTrackingStatistic("ClientReceiver", statisticsOptions);
     }
 }
Exemple #7
0
        internal WorkQueue()
        {
            mainQueue = new BlockingCollection<IWorkItem>(new ConcurrentBag<IWorkItem>());
            systemQueue = new BlockingCollection<IWorkItem>(new ConcurrentBag<IWorkItem>());
            queueArray = new BlockingCollection<IWorkItem>[] { systemQueue, mainQueue };

            if (!StatisticsCollector.CollectShedulerQueuesStats) return;

            mainQueueTracking = new QueueTrackingStatistic("Scheduler.LevelOne.MainQueue");
            systemQueueTracking = new QueueTrackingStatistic("Scheduler.LevelOne.SystemQueue");
            tasksQueueTracking = new QueueTrackingStatistic("Scheduler.LevelOne.TasksQueue");
            mainQueueTracking.OnStartExecution();
            systemQueueTracking.OnStartExecution();
            tasksQueueTracking.OnStartExecution();
        }
 public ProxiedMessageCenter(
     ClientConfiguration config,
     IPAddress localAddress,
     int gen,
     GrainId clientId,
     IGatewayListProvider gatewayListProvider,
     SerializationManager serializationManager,
     IRuntimeClient runtimeClient,
     MessageFactory messageFactory,
     IClusterConnectionStatusListener connectionStatusListener,
     ILoggerFactory loggerFactory,
     IOptions <ClientMessagingOptions> messagingOptions)
 {
     this.loggerFactory         = loggerFactory;
     this.openConnectionTimeout = messagingOptions.Value.OpenConnectionTimeout;
     this.SerializationManager  = serializationManager;
     lockable                      = new object();
     MyAddress                     = SiloAddress.New(new IPEndPoint(localAddress, 0), gen);
     ClientId                      = clientId;
     this.RuntimeClient            = runtimeClient;
     this.messageFactory           = messageFactory;
     this.connectionStatusListener = connectionStatusListener;
     Running                = false;
     GatewayManager         = new GatewayManager(config, gatewayListProvider, loggerFactory);
     PendingInboundMessages = new BlockingCollection <Message>();
     gatewayConnections     = new Dictionary <Uri, GatewayConnection>();
     numMessages            = 0;
     grainBuckets           = new WeakReference[config.ClientSenderBuckets];
     logger = new LoggerWrapper <ProxiedMessageCenter>(loggerFactory);
     if (logger.IsVerbose)
     {
         logger.Verbose("Proxy grain client constructed");
     }
     IntValueStatistic.FindOrCreate(
         StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT,
         () =>
     {
         lock (gatewayConnections)
         {
             return(gatewayConnections.Values.Count(conn => conn.IsLive));
         }
     });
     if (StatisticsCollector.CollectQueueStats)
     {
         queueTracking = new QueueTrackingStatistic("ClientReceiver");
     }
 }
Exemple #9
0
        internal WorkQueue()
        {
            mainQueue   = new BlockingCollection <IWorkItem>(new ConcurrentBag <IWorkItem>());
            systemQueue = new BlockingCollection <IWorkItem>(new ConcurrentBag <IWorkItem>());
            queueArray  = new BlockingCollection <IWorkItem>[] { systemQueue, mainQueue };

            if (!StatisticsCollector.CollectShedulerQueuesStats)
            {
                return;
            }

            mainQueueTracking   = new QueueTrackingStatistic("Scheduler.LevelOne.MainQueue");
            systemQueueTracking = new QueueTrackingStatistic("Scheduler.LevelOne.SystemQueue");
            tasksQueueTracking  = new QueueTrackingStatistic("Scheduler.LevelOne.TasksQueue");
            mainQueueTracking.OnStartExecution();
            systemQueueTracking.OnStartExecution();
            tasksQueueTracking.OnStartExecution();
        }
 internal InboundMessageQueue()
 {
     int n = Enum.GetValues(typeof(Message.Categories)).Length;
     messageQueues = new RuntimeQueue<Message>[n];
     queueTracking = new QueueTrackingStatistic[n];
     int i = 0;
     foreach (var category in Enum.GetValues(typeof(Message.Categories)))
     {
         messageQueues[i] = new RuntimeQueue<Message>();
         if (StatisticsCollector.CollectQueueStats)
         {
             var queueName = "IncomingMessageAgent." + category;
             queueTracking[i] = new QueueTrackingStatistic(queueName);
             queueTracking[i].OnStartExecution();
         }
         i++;
     }
     log = TraceLogger.GetLogger("Orleans.Messaging.InboundMessageQueue");
 }
Exemple #11
0
 public ClientMessageCenter(
     IOptions <ClientMessagingOptions> clientMessagingOptions,
     IPAddress localAddress,
     int gen,
     ClientGrainId clientId,
     SerializationManager serializationManager,
     IRuntimeClient runtimeClient,
     MessageFactory messageFactory,
     IClusterConnectionStatusListener connectionStatusListener,
     ILoggerFactory loggerFactory,
     IOptions <StatisticsOptions> statisticsOptions,
     ConnectionManager connectionManager,
     GatewayManager gatewayManager)
 {
     this.connectionManager    = connectionManager;
     this.SerializationManager = serializationManager;
     MyAddress                     = SiloAddress.New(new IPEndPoint(localAddress, 0), gen);
     ClientId                      = clientId;
     this.RuntimeClient            = runtimeClient;
     this.messageFactory           = messageFactory;
     this.connectionStatusListener = connectionStatusListener;
     Running             = false;
     this.gatewayManager = gatewayManager;
     numMessages         = 0;
     this.grainBuckets   = new WeakReference <Connection> [clientMessagingOptions.Value.ClientSenderBuckets];
     logger = loggerFactory.CreateLogger <ClientMessageCenter>();
     if (logger.IsEnabled(LogLevel.Debug))
     {
         logger.Debug("Proxy grain client constructed");
     }
     IntValueStatistic.FindOrCreate(
         StatisticNames.CLIENT_CONNECTED_GATEWAY_COUNT,
         () =>
     {
         return(connectionManager.ConnectionCount);
     });
     statisticsLevel = statisticsOptions.Value.CollectionLevel;
     if (statisticsLevel.CollectQueueStats())
     {
         queueTracking = new QueueTrackingStatistic("ClientReceiver", statisticsOptions);
     }
 }
Exemple #12
0
        internal InboundMessageQueue()
        {
            int n = Enum.GetValues(typeof(Message.Categories)).Length;

            messageQueues = new RuntimeQueue <Message> [n];
            queueTracking = new QueueTrackingStatistic[n];
            int i = 0;

            foreach (var category in Enum.GetValues(typeof(Message.Categories)))
            {
                messageQueues[i] = new RuntimeQueue <Message>();
                if (StatisticsCollector.CollectQueueStats)
                {
                    var queueName = "IncomingMessageAgent." + category;
                    queueTracking[i] = new QueueTrackingStatistic(queueName);
                    queueTracking[i].OnStartExecution();
                }
                i++;
            }
            log = TraceLogger.GetLogger("Orleans.Messaging.InboundMessageQueue");
        }
        internal InboundMessageQueue(ILoggerFactory loggerFactory)
        {
            int n = Enum.GetValues(typeof(Message.Categories)).Length;

            messageQueues = new BlockingCollection <Message> [n];
            queueTracking = new QueueTrackingStatistic[n];
            int i = 0;

            foreach (var category in Enum.GetValues(typeof(Message.Categories)))
            {
                messageQueues[i] = new BlockingCollection <Message>();
                if (StatisticsCollector.CollectQueueStats)
                {
                    var queueName = "IncomingMessageAgent." + category;
                    queueTracking[i] = new QueueTrackingStatistic(queueName);
                    queueTracking[i].OnStartExecution();
                }
                i++;
            }
            log = loggerFactory.CreateLogger <InboundMessageQueue>();
        }
Exemple #14
0
        internal WorkItemGroup(OrleansTaskScheduler sched, ISchedulingContext schedulingContext)
        {
            masterScheduler      = sched;
            SchedulingContext    = schedulingContext;
            state                = WorkGroupStatus.Waiting;
            workItems            = new Queue <Task>();
            lockable             = new Object();
            totalItemsEnQueued   = 0;
            totalItemsProcessed  = 0;
            totalQueuingDelay    = TimeSpan.Zero;
            quantumExpirations   = 0;
            TaskRunner           = new ActivationTaskScheduler(this);
            MaxPendingItemsLimit = LimitManager.GetLimit(LimitNames.LIMIT_MAX_PENDING_ITEMS);
            log = IsSystem ? TraceLogger.GetLogger("Scheduler." + Name + ".WorkItemGroup", TraceLogger.LoggerType.Runtime) : appLogger;

            if (StatisticsCollector.CollectShedulerQueuesStats)
            {
                queueTracking = new QueueTrackingStatistic("Scheduler." + SchedulingContext.Name);
                queueTracking.OnStartExecution();
            }

            if (StatisticsCollector.CollectPerWorkItemStats)
            {
                workItemGroupStatisticsNumber = SchedulerStatisticsGroup.RegisterWorkItemGroup(SchedulingContext.Name, SchedulingContext,
                                                                                               () =>
                {
                    var sb = new StringBuilder();
                    lock (lockable)
                    {
                        sb.Append("QueueLength = " + WorkItemCount);
                        sb.Append(String.Format(", State = {0}", state));
                        if (state == WorkGroupStatus.Runnable)
                        {
                            sb.Append(String.Format("; oldest item is {0} old", workItems.Count >= 0 ? workItems.Peek().ToString() : "null"));
                        }
                    }
                    return(sb.ToString());
                });
            }
        }
Exemple #15
0
        // This is the maximum number of waiting threads (blocked in WaitForResponse) allowed
        // per ActivationWorker. An attempt to wait when there are already too many threads waiting
        // will result in a TooManyWaitersException being thrown.
        //private static readonly int MaxWaitingThreads = 500;


        internal WorkItemGroup(OrleansTaskScheduler sched, ISchedulingContext schedulingContext, ILoggerFactory loggerFactory)
        {
            masterScheduler     = sched;
            SchedulingContext   = schedulingContext;
            state               = WorkGroupStatus.Waiting;
            workItems           = new Queue <Task>();
            lockable            = new Object();
            totalItemsEnQueued  = 0;
            totalItemsProcessed = 0;
            totalQueuingDelay   = TimeSpan.Zero;
            quantumExpirations  = 0;
            TaskRunner          = new ActivationTaskScheduler(this, loggerFactory);
            log = IsSystemPriority ? loggerFactory.CreateLogger($"{this.GetType().Namespace} {Name}.{this.GetType().Name}") : loggerFactory.CreateLogger <WorkItemGroup>();

            if (StatisticsCollector.CollectShedulerQueuesStats)
            {
                queueTracking = new QueueTrackingStatistic("Scheduler." + SchedulingContext.Name);
                queueTracking.OnStartExecution();
            }

            if (StatisticsCollector.CollectPerWorkItemStats)
            {
                workItemGroupStatisticsNumber = SchedulerStatisticsGroup.RegisterWorkItemGroup(SchedulingContext.Name, SchedulingContext,
                                                                                               () =>
                {
                    var sb = new StringBuilder();
                    lock (lockable)
                    {
                        sb.Append("QueueLength = " + WorkItemCount);
                        sb.Append(String.Format(", State = {0}", state));
                        if (state == WorkGroupStatus.Runnable)
                        {
                            sb.Append(String.Format("; oldest item is {0} old", workItems.Count >= 0 ? workItems.Peek().ToString() : "null"));
                        }
                    }
                    return(sb.ToString());
                });
            }
        }
Exemple #16
0
        // This is the maximum number of waiting threads (blocked in WaitForResponse) allowed
        // per ActivationWorker. An attempt to wait when there are already too many threads waiting
        // will result in a TooManyWaitersException being thrown.
        //private static readonly int MaxWaitingThreads = 500;


        internal WorkItemGroup(OrleansTaskScheduler sched, ISchedulingContext schedulingContext)
        {
            masterScheduler = sched;
            SchedulingContext = schedulingContext;
            state = WorkGroupStatus.Waiting;
            workItems = new Queue<ActivationTask>();
            lockable = new Object();
            totalItemsEnQueued = 0;
            totalItemsProcessed = 0;
            totalQueuingDelay = TimeSpan.Zero;
            quantumExpirations = 0;
            TaskRunner = new ActivationTaskScheduler(this);
            
            log = IsSystemPriority ? LogManager.GetLogger("Scheduler." + Name + ".WorkItemGroup", LoggerType.Runtime) : appLogger;
      
            if (StatisticsCollector.CollectShedulerQueuesStats)
            {
                queueTracking = new QueueTrackingStatistic("Scheduler." + SchedulingContext.Name);
                queueTracking.OnStartExecution();
            }

            if (StatisticsCollector.CollectPerWorkItemStats)
            {
                workItemGroupStatisticsNumber = SchedulerStatisticsGroup.RegisterWorkItemGroup(SchedulingContext.Name, SchedulingContext,
                    () =>
                    {
                        var sb = new StringBuilder();
                        lock (lockable)
                        {
                                    
                            sb.Append("QueueLength = " + WorkItemCount);
                            sb.Append(String.Format(", State = {0}", state));
                            if (state == WorkGroupStatus.Runnable)
                                sb.Append(String.Format("; oldest item is {0} old", workItems.Count >= 0 ? workItems.Peek().ToString() : "null"));
                        }
                        return sb.ToString();
                    });
            }
        }