Example #1
0
 public MessageCenter(SiloInitializationParameters silo, NodeConfiguration nodeConfig, IMessagingConfiguration config, ISiloPerformanceMetrics metrics = null)
 {
     this.Initialize(silo.SiloAddress.Endpoint, nodeConfig.Generation, config, metrics);
     if (nodeConfig.IsGatewayNode)
     {
         this.InstallGateway(nodeConfig.ProxyGatewayEndpoint);
     }
 }
Example #2
0
 public SiloControl(
     Silo silo,
     DeploymentLoadPublisher deploymentLoadPublisher,
     Catalog catalog,
     GrainTypeManager grainTypeManager,
     ISiloPerformanceMetrics siloMetrics)
     : base(Constants.SiloControlId, silo.SiloAddress)
 {
     this.silo = silo;
     this.deploymentLoadPublisher = deploymentLoadPublisher;
     this.catalog = catalog;
     this.grainTypeManager = grainTypeManager;
     this.siloMetrics = siloMetrics;
 }
Example #3
0
        private void Initialize(IPEndPoint here, int generation, IMessagingConfiguration config, ISiloPerformanceMetrics metrics = null)
        {
            if(log.IsVerbose3) log.Verbose3("Starting initialization.");

            SocketManager = new SocketManager(config);
            ima = new IncomingMessageAcceptor(this, here, SocketDirection.SiloToSilo);
            MyAddress = SiloAddress.New((IPEndPoint)ima.AcceptingSocket.LocalEndPoint, generation);
            MessagingConfiguration = config;
            InboundQueue = new InboundMessageQueue();
            OutboundQueue = new OutboundMessageQueue(this, config);
            Gateway = null;
            Metrics = metrics;
            
            sendQueueLengthCounter = IntValueStatistic.FindOrCreate(StatisticNames.MESSAGE_CENTER_SEND_QUEUE_LENGTH, () => SendQueueLength);
            receiveQueueLengthCounter = IntValueStatistic.FindOrCreate(StatisticNames.MESSAGE_CENTER_RECEIVE_QUEUE_LENGTH, () => ReceiveQueueLength);

            if (log.IsVerbose3) log.Verbose3("Completed initialization.");
        }
Example #4
0
 public ActivationCountBasedPlacementTestGrain(ISiloPerformanceMetrics siloPerformanceMetrics) : base(siloPerformanceMetrics)
 {
 }
Example #5
0
 public RandomPlacementTestGrain(ISiloPerformanceMetrics siloPerformanceMetrics) : base(siloPerformanceMetrics)
 {
 }
Example #6
0
 public LocalPlacementTestGrain(ISiloPerformanceMetrics siloPerformanceMetrics) : base(siloPerformanceMetrics)
 {
 }
        private SiloMetricsData PopulateSiloMetricsDataTableEntry(ISiloPerformanceMetrics metricsData)
        {
            // NOTE: Repeatedly re-uses a single SiloMetricsData object, updated with the latest current data

            // Add data row header info
            metricsDataObject.PartitionKey = deploymentId;
            metricsDataObject.RowKey = siloName;
            metricsDataObject.Timestamp = DateTime.UtcNow;

            metricsDataObject.DeploymentId = deploymentId;
            metricsDataObject.SiloName = siloName;
            metricsDataObject.Address = siloAddress.ToString();
            if (gateway != null)
            {
                metricsDataObject.GatewayAddress = gateway.ToString();
            }
            metricsDataObject.HostName = myHostName;

            // Add metrics data
            metricsDataObject.CPU = metricsData.CpuUsage;
            metricsDataObject.MemoryUsage = metricsData.MemoryUsage;
            metricsDataObject.Activations = metricsData.ActivationCount;
            metricsDataObject.RecentlyUsedActivations = metricsData.RecentlyUsedActivationCount;
            metricsDataObject.SendQueue = metricsData.SendQueueLength;
            metricsDataObject.ReceiveQueue = metricsData.ReceiveQueueLength;
            metricsDataObject.RequestQueue = metricsData.RequestQueueLength;
            metricsDataObject.SentMessages = metricsData.SentMessages;
            metricsDataObject.ReceivedMessages = metricsData.ReceivedMessages;
            metricsDataObject.LoadShedding = metricsData.IsOverloaded;
            metricsDataObject.ClientCount = metricsData.ClientCount;
            return metricsDataObject;
        }
Example #8
0
 public Task ReportMetrics(ISiloPerformanceMetrics metricsData)
 {
     Trace.TraceInformation("{0} ReportMetrics called", GetType().Name);
     Interlocked.Increment(ref NumMetricsCalls);
     return(TaskDone.Done);
 }
Example #9
0
 public async Task ReportMetrics(ISiloPerformanceMetrics metricsData)
 {
     latestRequestQueueLength = metricsData.RequestQueueLength;
 }
        /// <summary>
        /// Either inserts or updates a silo metrics row.
        /// </summary>
        /// <param name="storage">The storage to use.</param>
        /// <param name="query">The query to use.</param>
        /// <param name="deploymentId">The deployment ID.</param>
        /// <param name="siloId">The silo ID.</param>
        /// <param name="gateway">The gateway information.</param>
        /// <param name="siloAddress">The silo address information.</param>
        /// <param name="hostName">The hostname.</param>
        /// <param name="siloMetrics">The silo metrics to be either updated or inserted.</param>
        /// <returns></returns>
        public static async Task UpsertSiloMetricsAsync(this IRelationalStorage storage, string query, string deploymentId, string siloId, IPEndPoint gateway, SiloAddress siloAddress, string hostName, ISiloPerformanceMetrics siloMetrics)
        {            
            await storage.ExecuteAsync(query, command =>
            {               
                var direction = ParameterDirection.Input;
                var deploymentIdParameter = CreateDeploymentIdParameter(command, deploymentId, direction);
                command.Parameters.Add(deploymentIdParameter);

                var clientIdParameter = CreateSiloIdParameter(command, siloId, direction);
                command.Parameters.Add(clientIdParameter);

                var addressParameter = CreateAddressParameter(command, siloAddress.Endpoint.Address, direction);
                command.Parameters.Add(addressParameter);

                var portParameter = CreatePortParameter(command, siloAddress.Endpoint.Port, direction);
                command.Parameters.Add(portParameter);

                var generationParameter = CreateGenerationParameter(command, siloAddress.Generation, direction);
                command.Parameters.Add(generationParameter);

                var hostNameParameter = CreateHostNameParameter(command, hostName, direction);
                command.Parameters.Add(hostNameParameter);
                
                var gatewayAddressParameter = CreateGatewayAddressParameter(command, gateway != null ? gateway.Address : null, direction);
                command.Parameters.Add(gatewayAddressParameter);

                var gatewayPortParameter = CreateGatewayPortParameter(command, gateway != null ? gateway.Port : 0, direction);
                command.Parameters.Add(gatewayPortParameter);
                
                var cpuUsageParameter = CreateCpuUsageParameter(command, siloMetrics.CpuUsage, direction);
                command.Parameters.Add(cpuUsageParameter);

                var memoryUsageParameter = CreateMemoryUsageParameter(command, siloMetrics.MemoryUsage, direction);
                command.Parameters.Add(memoryUsageParameter);

                var activationsCountParameter = CreateActivationsCountParameter(command, siloMetrics.ActivationCount, direction);
                command.Parameters.Add(activationsCountParameter);

                var recentlyUsedActivationsCountParameter = CreateRecentlyUsedActivationsCountParameter(command, siloMetrics.RecentlyUsedActivationCount, direction);
                command.Parameters.Add(recentlyUsedActivationsCountParameter);

                var sendQueueLengthParameter = CreateSendQueueUsageParameter(command, siloMetrics.SendQueueLength, direction);
                command.Parameters.Add(sendQueueLengthParameter);

                var receiveQueueParameter = CreateReceiveQueueLengthParameter(command, siloMetrics.ReceiveQueueLength, direction);
                command.Parameters.Add(receiveQueueParameter);

                var sentMessagesCountParameter = CreateSentMessagesCountParameter(command, siloMetrics.SentMessages, direction);
                command.Parameters.Add(sentMessagesCountParameter);

                var receivedMessagesCountParameter = CreateReceivedMessagesCountParameter(command, siloMetrics.ReceivedMessages, direction);
                command.Parameters.Add(receivedMessagesCountParameter);

                var requestQueueLengthParameter = CreateRequestQueueLengthParameter(command, siloMetrics.RequestQueueLength, direction);
                command.Parameters.Add(requestQueueLengthParameter);
                
                var isOverloadedParameter = CreateIsOverloadedParameter(command, siloMetrics.IsOverloaded, direction);
                command.Parameters.Add(isOverloadedParameter);

                var clientCountParameter = CreateClientCountParameter(command, siloMetrics.ClientCount, direction);
                command.Parameters.Add(clientCountParameter);
            }).ConfigureAwait(continueOnCapturedContext: false);
        }
        public async Task ReportMetrics(ISiloPerformanceMetrics metricsData)
        {
            using (var conn = new SqlConnection(connectionString))
            {
                conn.Open();
                using (var tx = conn.BeginTransaction())
                {
                    var command1 = new SqlCommand(METRICS_READ_SINGLE_ROW);
                    command1.Parameters.Add(new SqlParameter { ParameterName = "@id", DbType = DbType.String, Value = deploymentId });
                    command1.Parameters.Add(new SqlParameter { ParameterName = "@siloid", DbType = DbType.String, Value = siloName });
                    command1.Connection = conn;
                    command1.Transaction = tx;

                    var result = (Int32)await command1.ExecuteScalarAsync();

                    var command2 = new SqlCommand((result > 0) ? METRICS_UPDATE_ROW : METRICS_INSERT_ROW);
                    ConvertToMetricsRow(metricsData, command2);
                    command2.Connection = conn;
                    command2.Transaction = tx;

                    await command2.ExecuteNonQueryAsync();
                    tx.Commit();
                }
            }
        }
 /// <summary>
 /// Writes silo performance metrics to the database
 /// </summary>
 /// <param name="metricsData">Metrics data</param>
 /// <returns>Task for database operation</returns>
 public Task ReportMetrics(ISiloPerformanceMetrics metricsData)
 {
     if (logger != null && logger.IsVerbose3) logger.Verbose3("SqlStatisticsPublisher.ReportMetrics (silo) called with data: {0}.", metricsData);
     try
     {
         return orleansQueries.UpsertSiloMetricsAsync(deploymentId, siloName, gateway, siloAddress, hostName, metricsData);
     }
     catch(Exception ex)
     {
         if (logger != null && logger.IsVerbose) logger.Verbose("SqlStatisticsPublisher.ReportMetrics (silo) failed: {0}", ex);
         throw;
     }
 }
 public Task ReportMetrics(ISiloPerformanceMetrics metricsData)
 {
     if (!Initialized) return Task.CompletedTask;
     var pageView = new PageViewTelemetry(SiloName);
     pageView.Properties.Add("deploymentId", DeploymentId);
     Telemetry.TrackMetric("ActivationCount", metricsData.ActivationCount);
     Telemetry.TrackMetric("CpuUsage", metricsData.CpuUsage);
     Telemetry.TrackMetric("AvailablePhysicalMemory", metricsData.AvailablePhysicalMemory);
     Telemetry.TrackMetric("ClientCount", metricsData.ClientCount);
     Telemetry.TrackMetric("MemoryUsage", metricsData.MemoryUsage);
     Telemetry.TrackMetric("ReceivedMessages", metricsData.ReceivedMessages);
     Telemetry.TrackMetric("ReceiveQueueLength", metricsData.ReceiveQueueLength);
     Telemetry.TrackMetric("RecentlyUsedActivationCount", metricsData.RecentlyUsedActivationCount);
     Telemetry.TrackMetric("RequestQueueLength", metricsData.RequestQueueLength);
     Telemetry.TrackMetric("SendQueueLength", metricsData.SendQueueLength);
     Telemetry.TrackMetric("SentMessages", metricsData.SentMessages);
     Telemetry.TrackMetric("TotalPhysicalMemory", metricsData.TotalPhysicalMemory);
     var props = new Dictionary<string, string>();
     props.Add("DeploymentId", DeploymentId);
     props.Add("HostName", HostName);
     Telemetry.TrackEvent("ReportMetrics",props);
     Telemetry.Flush();
     return Task.CompletedTask;
 }
Example #14
0
        private void Initialize(IPEndPoint here, int generation, IOptions <SiloMessagingOptions> messagingOptions, IOptions <NetworkingOptions> networkingOptions, ISiloPerformanceMetrics metrics = null)
        {
            if (log.IsEnabled(LogLevel.Trace))
            {
                log.Trace("Starting initialization.");
            }

            SocketManager = new SocketManager(networkingOptions, this.loggerFactory);
            ima           = new IncomingMessageAcceptor(this, here, SocketDirection.SiloToSilo, this.messageFactory, this.serializationManager, this.executorService, this.loggerFactory);
            MyAddress     = SiloAddress.New((IPEndPoint)ima.AcceptingSocket.LocalEndPoint, generation);
            InboundQueue  = new InboundMessageQueue(this.loggerFactory);
            OutboundQueue = new OutboundMessageQueue(this, messagingOptions, this.serializationManager, this.executorService, this.loggerFactory);
            Metrics       = metrics;

            sendQueueLengthCounter    = IntValueStatistic.FindOrCreate(StatisticNames.MESSAGE_CENTER_SEND_QUEUE_LENGTH, () => SendQueueLength);
            receiveQueueLengthCounter = IntValueStatistic.FindOrCreate(StatisticNames.MESSAGE_CENTER_RECEIVE_QUEUE_LENGTH, () => ReceiveQueueLength);

            if (log.IsEnabled(LogLevel.Trace))
            {
                log.Trace("Completed initialization.");
            }
        }
 public Task ReportMetrics(ISiloPerformanceMetrics metricsData)
 {
     return(TaskDone.Done);
 }
Example #16
0
        /// <summary>
        /// Upsert silo metrics.
        /// </summary>
        /// <param name="siloMetricsTable">
        /// The silo metrics table.
        /// </param>
        /// <param name="siloPerformanceMetrics">
        /// The silo performance metrics.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task UpsertSiloMetricsAsync(OrleansSiloMetricsTable siloMetricsTable, ISiloPerformanceMetrics siloPerformanceMetrics)
        {
            siloMetricsTable.ActivationCount             = siloPerformanceMetrics.ActivationCount;
            siloMetricsTable.ClientCount                 = siloPerformanceMetrics.ClientCount;
            siloMetricsTable.IsOverloaded                = siloPerformanceMetrics.IsOverloaded;
            siloMetricsTable.RecentlyUsedActivationCount = siloPerformanceMetrics.RecentlyUsedActivationCount;
            siloMetricsTable.RequestQueueLength          = siloPerformanceMetrics.RequestQueueLength;
            siloMetricsTable.MemoryUsage                 = siloPerformanceMetrics.MemoryUsage;
            siloMetricsTable.AvailablePhysicalMemory     = siloPerformanceMetrics.AvailablePhysicalMemory;
            siloMetricsTable.CpuUsage            = siloPerformanceMetrics.CpuUsage;
            siloMetricsTable.ReceiveQueueLength  = siloPerformanceMetrics.ReceiveQueueLength;
            siloMetricsTable.ReceivedMessages    = siloPerformanceMetrics.ReceivedMessages;
            siloMetricsTable.SendQueueLength     = siloPerformanceMetrics.SendQueueLength;
            siloMetricsTable.SentMessages        = siloPerformanceMetrics.SentMessages;
            siloMetricsTable.TotalPhysicalMemory = siloPerformanceMetrics.TotalPhysicalMemory;
            //siloMetricsTable.Generation = siloPerformanceMetrics.

            var collection = this.ReturnOrCreateCollection(OrleansSiloMetricsTableName);

            FilterDefinition <BsonDocument> filter = null;
            BsonDocument document = siloMetricsTable.ToBsonDocument();

            filter = Builders <BsonDocument> .Filter.Eq(DeploymentIdName, siloMetricsTable.DeploymentId) & Builders <BsonDocument> .Filter.Eq(SiloIdName, siloMetricsTable.SiloId);

            await collection.ReplaceOneAsync(
                filter,
                document,
                new UpdateOptions { BypassDocumentValidation = true, IsUpsert = true });
        }
Example #17
0
 public PlacementTestGrainBase(ISiloPerformanceMetrics siloPerformanceMetrics)
 {
     this.siloPerformanceMetrics = siloPerformanceMetrics;
 }
Example #18
0
 public MessageCenter(IPEndPoint here, int generation, IMessagingConfiguration config, ISiloPerformanceMetrics metrics = null)
 {
     Initialize(here, generation, config, metrics);
 }
Example #19
0
 public Task ReportMetrics(ISiloPerformanceMetrics metricsData)
 {
     Trace.TraceInformation("{0} ReportMetrics called", GetType().Name);
     Interlocked.Increment(ref NumMetricsCalls);
     return TaskDone.Done;
 }
Example #20
0
 public Task ReportMetrics(ISiloPerformanceMetrics metricsData)
 {
     logger.Info("{0} ReportMetrics called", GetType().Name);
     taskScheduler.QueueTask(() => grain.ReportMetricsCalled(), schedulingContext).Ignore();
     return(Task.CompletedTask);
 }
        /// <summary>
        /// Either inserts or updates a silo metrics row.
        /// </summary>
        /// <param name="deploymentId">The deployment ID.</param>
        /// <param name="siloId">The silo ID.</param>
        /// <param name="gateway">The gateway information.</param>
        /// <param name="siloAddress">The silo address information.</param>
        /// <param name="hostName">The host name.</param>
        /// <param name="siloMetrics">The silo metrics to be either updated or inserted.</param>
        /// <returns></returns>
        internal Task UpsertSiloMetricsAsync(string deploymentId, string siloId, IPEndPoint gateway,
                                             SiloAddress siloAddress, string hostName, ISiloPerformanceMetrics siloMetrics)
        {
            return(ExecuteAsync(dbStoredQueries.UpsertSiloMetricsKey, command =>
            {
                var columns = new DbStoredQueries.Columns(command);

                columns.DeploymentId = deploymentId;
                columns.HostName = hostName;
                columns.SiloMetrics = siloMetrics;
                columns.SiloAddress = siloAddress;
                columns.GatewayAddress = gateway.Address;
                columns.GatewayPort = gateway.Port;
                columns.SiloId = siloId;
                return columns;
            }));
        }
 private void ConvertToMetricsRow(ISiloPerformanceMetrics metricsData, SqlCommand command)
 {
     command.Parameters.Add(new SqlParameter { ParameterName = "@id", DbType = DbType.String, Value = deploymentId });
     command.Parameters.Add(new SqlParameter { ParameterName = "@siloid", DbType = DbType.String, Value = siloName });
     command.Parameters.Add(new SqlParameter { ParameterName = "@timestamp", DbType = DbType.DateTime, Value = DateTime.UtcNow });
     command.Parameters.Add(new SqlParameter { ParameterName = "@address", DbType = DbType.String, Value = siloAddress.Endpoint.Address.ToString() });
     command.Parameters.Add(new SqlParameter { ParameterName = "@port", DbType = DbType.Int32, Value = siloAddress.Endpoint.Port });
     command.Parameters.Add(new SqlParameter { ParameterName = "@generation", DbType = DbType.Int32, Value = siloAddress.Generation });
     command.Parameters.Add(new SqlParameter { ParameterName = "@hostname", DbType = DbType.String, Value = myHostName });
     if (gateway != null)
     {
         command.Parameters.Add(new SqlParameter { ParameterName = "@gatewayaddress", DbType = DbType.String, Value = gateway.Address.ToString() });
         command.Parameters.Add(new SqlParameter { ParameterName = "@gatewayport", DbType = DbType.Int32, Value = gateway.Port });
     }
     else
     {
         command.Parameters.Add(new SqlParameter { ParameterName = "@gatewayaddress", DbType = DbType.String, Value = null });
         command.Parameters.Add(new SqlParameter { ParameterName = "@gatewayport", DbType = DbType.Int32, Value = 0 });
     }
     command.Parameters.Add(new SqlParameter { ParameterName = "@cpu", DbType = DbType.Double, Value = (double)metricsData.CpuUsage });
     command.Parameters.Add(new SqlParameter { ParameterName = "@memory", DbType = DbType.Int64, Value = metricsData.MemoryUsage });
     command.Parameters.Add(new SqlParameter { ParameterName = "@activations", DbType = DbType.Int32, Value = metricsData.ActivationCount });
     command.Parameters.Add(new SqlParameter { ParameterName = "@recentlyusedactivations", DbType = DbType.Int32, Value = metricsData.RecentlyUsedActivationCount });
     command.Parameters.Add(new SqlParameter { ParameterName = "@sendqueue", DbType = DbType.Int32, Value = metricsData.SendQueueLength });
     command.Parameters.Add(new SqlParameter { ParameterName = "@receivequeue", DbType = DbType.Int32, Value = metricsData.ReceiveQueueLength });
     command.Parameters.Add(new SqlParameter { ParameterName = "@requestqueue", DbType = DbType.Int64, Value = metricsData.RequestQueueLength });
     command.Parameters.Add(new SqlParameter { ParameterName = "@sentmessages", DbType = DbType.Int64, Value = metricsData.SentMessages });
     command.Parameters.Add(new SqlParameter { ParameterName = "@receivedmessages", DbType = DbType.Int64, Value = metricsData.ReceivedMessages });
     command.Parameters.Add(new SqlParameter { ParameterName = "@loadshedding", DbType = DbType.Boolean, Value = metricsData.IsOverloaded });
     command.Parameters.Add(new SqlParameter { ParameterName = "@clientcount", DbType = DbType.Int64, Value = metricsData.ClientCount });
 }
Example #23
0
 public MessageCenter(SiloInitializationParameters silo, NodeConfiguration nodeConfig, IMessagingConfiguration config, ISiloPerformanceMetrics metrics = null)
 {
     this.Initialize(silo.SiloAddress.Endpoint, nodeConfig.Generation, config, metrics);
     if (nodeConfig.IsGatewayNode)
     {
         this.InstallGateway(nodeConfig.ProxyGatewayEndpoint);
     }
 }
Example #24
0
 public Task ReportMetrics(ISiloPerformanceMetrics metricsData)
 {
     logger.Info("{0} ReportMetrics called", GetType().Name);
     taskScheduler.QueueTask(() => grain.ReportMetricsCalled(), schedulingContext).Ignore();
     return TaskDone.Done;
 }
Example #25
0
 public MessageCenter(IPEndPoint here, int generation, IMessagingConfiguration config, ISiloPerformanceMetrics metrics = null)
 {
     Initialize(here, generation, config, metrics);
 }
 public Task ReportMetrics(ISiloPerformanceMetrics metricsData)
 {
     if (logger != null && logger.IsVerbose3) logger.Verbose3("SqlStatisticsPublisher.ReportMetrics (silo) called with data: {0}.", metricsData);
     try
     {
         var query = queryConstants.GetConstant(database.InvariantName, QueryKeys.UpsertSiloMetricsKey);
         return database.UpsertSiloMetricsAsync(query, deploymentId, siloName, gateway, siloAddress, hostName, metricsData);
     }
     catch(Exception ex)
     {
         if (logger != null && logger.IsVerbose) logger.Verbose("SqlStatisticsPublisher.ReportMetrics (silo) failed: {0}", ex);
         throw;
     }
 }
Example #27
0
        private void Initialize(IPEndPoint here, int generation, IMessagingConfiguration config, ISiloPerformanceMetrics metrics = null)
        {
            if (log.IsVerbose3)
            {
                log.Verbose3("Starting initialization.");
            }

            SocketManager          = new SocketManager(config);
            ima                    = new IncomingMessageAcceptor(this, here, SocketDirection.SiloToSilo);
            MyAddress              = SiloAddress.New((IPEndPoint)ima.AcceptingSocket.LocalEndPoint, generation);
            MessagingConfiguration = config;
            InboundQueue           = new InboundMessageQueue();
            OutboundQueue          = new OutboundMessageQueue(this, config);
            Gateway                = null;
            Metrics                = metrics;

            sendQueueLengthCounter    = IntValueStatistic.FindOrCreate(StatisticNames.MESSAGE_CENTER_SEND_QUEUE_LENGTH, () => SendQueueLength);
            receiveQueueLengthCounter = IntValueStatistic.FindOrCreate(StatisticNames.MESSAGE_CENTER_RECEIVE_QUEUE_LENGTH, () => ReceiveQueueLength);

            if (log.IsVerbose3)
            {
                log.Verbose3("Completed initialization.");
            }
        }
 internal SiloRuntimeStatistics(ISiloPerformanceMetrics metrics, DateTime dateTime)
 {
     ActivationCount = metrics.ActivationCount;
     RecentlyUsedActivationCount = metrics.RecentlyUsedActivationCount;
     RequestQueueLength = metrics.RequestQueueLength;
     SendQueueLength = metrics.SendQueueLength;
     ReceiveQueueLength = metrics.ReceiveQueueLength;
     CpuUsage = metrics.CpuUsage;
     AvailableMemory = metrics.AvailablePhysicalMemory;
     MemoryUsage = metrics.MemoryUsage;
     IsOverloaded = metrics.IsOverloaded;
     ClientCount = metrics.ClientCount;
     TotalPhysicalMemory = metrics.TotalPhysicalMemory;
     ReceivedMessages = metrics.ReceivedMessages;
     SentMessages = metrics.SentMessages;
     DateTime = dateTime;
 }
Example #29
0
 private void ConvertToMetricsRow(ISiloPerformanceMetrics metricsData, SqlCommand command)
 {
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@id", DbType = DbType.String, Value = deploymentId
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@siloid", DbType = DbType.String, Value = siloName
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@timestamp", DbType = DbType.DateTime, Value = DateTime.UtcNow
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@address", DbType = DbType.String, Value = siloAddress.Endpoint.Address.ToString()
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@port", DbType = DbType.Int32, Value = siloAddress.Endpoint.Port
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@generation", DbType = DbType.Int32, Value = siloAddress.Generation
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@hostname", DbType = DbType.String, Value = myHostName
     });
     if (gateway != null)
     {
         command.Parameters.Add(new SqlParameter {
             ParameterName = "@gatewayaddress", DbType = DbType.String, Value = gateway.Address.ToString()
         });
         command.Parameters.Add(new SqlParameter {
             ParameterName = "@gatewayport", DbType = DbType.Int32, Value = gateway.Port
         });
     }
     else
     {
         command.Parameters.Add(new SqlParameter {
             ParameterName = "@gatewayaddress", DbType = DbType.String, Value = null
         });
         command.Parameters.Add(new SqlParameter {
             ParameterName = "@gatewayport", DbType = DbType.Int32, Value = 0
         });
     }
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@cpu", DbType = DbType.Double, Value = (double)metricsData.CpuUsage
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@memory", DbType = DbType.Int64, Value = metricsData.MemoryUsage
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@activations", DbType = DbType.Int32, Value = metricsData.ActivationCount
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@recentlyusedactivations", DbType = DbType.Int32, Value = metricsData.RecentlyUsedActivationCount
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@sendqueue", DbType = DbType.Int32, Value = metricsData.SendQueueLength
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@receivequeue", DbType = DbType.Int32, Value = metricsData.ReceiveQueueLength
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@requestqueue", DbType = DbType.Int64, Value = metricsData.RequestQueueLength
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@sentmessages", DbType = DbType.Int64, Value = metricsData.SentMessages
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@receivedmessages", DbType = DbType.Int64, Value = metricsData.ReceivedMessages
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@loadshedding", DbType = DbType.Boolean, Value = metricsData.IsOverloaded
     });
     command.Parameters.Add(new SqlParameter {
         ParameterName = "@clientcount", DbType = DbType.Int64, Value = metricsData.ClientCount
     });
 }
 public Task ReportMetrics(ISiloPerformanceMetrics metricsData)
 {
     var siloMetricsTableEntry = PopulateSiloMetricsDataTableEntry(metricsData);
     if (logger.IsVerbose) logger.Verbose("Updating silo metrics table entry: {0}", siloMetricsTableEntry);
     return storage.UpsertTableEntryAsync(siloMetricsTableEntry);
 }
Example #31
0
 /// <summary>
 /// Either inserts or updates a silo metrics row.
 /// </summary>
 /// <param name="deploymentId">The deployment ID.</param>
 /// <param name="siloId">The silo ID.</param>
 /// <param name="gateway">The gateway information.</param>
 /// <param name="siloAddress">The silo address information.</param>
 /// <param name="hostName">The host name.</param>
 /// <param name="siloMetrics">The silo metrics to be either updated or inserted.</param>
 /// <returns></returns>
 internal Task UpsertSiloMetricsAsync(string deploymentId, string siloId, IPEndPoint gateway,
                                      SiloAddress siloAddress, string hostName, ISiloPerformanceMetrics siloMetrics)
 {
     return(ExecuteAsync(dbStoredQueries.UpsertSiloMetricsKey, command =>
                         new DbStoredQueries.Columns(command)
     {
         DeploymentId = deploymentId,
         HostName = hostName,
         SiloMetrics = siloMetrics,
         SiloAddress = siloAddress,
         GatewayAddress = gateway.Address,
         GatewayPort = gateway.Port,
         SiloId = siloId
     }));
 }