Esempio n. 1
0
        public override bool OnStart()
        {
            try
            {
                // Set the maximum number of concurrent connections
                ServicePointManager.DefaultConnectionLimit = int.MaxValue;

                // Pull the configuration object from service and app configuration
                _configuration = Configuration.GetCurrentConfiguration();

                // Create the instrumentation (performance counter publisher)
                var instrumentationPublisher =
                    new ColdStorageInstrumentationManager(
                        instrumentationEnabled: true,
                        installInstrumentation: false)
                        .CreatePublisher("WaWorkerHost");

                // Activate the cold storage processor
                _coordinator = ColdStorageCoordinator.CreateAsync(
                    RoleEnvironment.CurrentRoleInstance.Id,
                    _configuration.EventHubName,
                    _configuration.ConsumerGroupName,
                    _configuration.EventHubConnectionString,
                    _configuration.CheckpointStorageAccount,
                    _configuration.MaxBatchSize,
                    _configuration.PreFetchCount,
                    _configuration.ReceiveTimeout,
                    new[] { _configuration.BlobWriterStorageAccount },
                    _configuration.ContainerName,
                    _configuration.RollSizeForBlobWriterMb,
                    _configuration.BlobPrefix,
                    _configuration.CircuitBreakerWarningLevel,
                    _configuration.CircuitBreakerTripLevel,
                    _configuration.CircuitBreakerStallInterval,
                    _configuration.CircuitBreakerLogCooldownInterval,
                    instrumentationPublisher
                    ).Result;

                bool result = base.OnStart();

                Trace.TraceInformation("Processor has been started");

                return result;
            }
            catch (Exception ex)
            {
                LogHelpers.HandleRoleException(Logger, "Run()", ex);
                throw;
            }
        }
        internal ColdStorageInstrumentationPublisher(
            string instanceName,
            ColdStorageInstrumentationManager instrumentationManager)
        {
            _currentCacheSizeInBlocksCounter =
                instrumentationManager.CurrentCacheSizeInBlocksCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalWritesFailedCounter =
                instrumentationManager.TotalWritesFailedCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalWritesSucceededCounter =
                instrumentationManager.TotalWritesSucceededDefinition.CreatePerformanceCounter(instanceName);
            _totalBlocksWrittenCounter =
                instrumentationManager.TotalBlocksWrittenCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalConcurrentWritesFailedCounter =
                instrumentationManager.TotalConcurrentWritesFailedCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalWriteAttemptsCounter =
                instrumentationManager.TotalWriteAttemptsCounterDefinition.CreatePerformanceCounter(instanceName);
            _averageWriteTimeCounter =
                instrumentationManager.AverageWriteTimeCounterDefinition.CreatePerformanceCounter(instanceName);
            _averageWriteTimeBaseCounter =
                instrumentationManager.AverageWriteTimeBaseCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalLeasesLostCounter =
                instrumentationManager.TotalLeasesLostCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalLeasesObtainedCounter =
                instrumentationManager.TotalLeasesObtainedCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalEventsProcessedCounter =
                instrumentationManager.TotalEventsProcessedCounterDefinition.CreatePerformanceCounter(instanceName);

            _totalWritesFailedCounter.RawValue           = 0L;
            _totalWritesSucceededCounter.RawValue        = 0L;
            _totalConcurrentWritesFailedCounter.RawValue = 0L;
            _totalWriteAttemptsCounter.RawValue          = 0L;
            _averageWriteTimeCounter.RawValue            = 0L;
            _averageWriteTimeBaseCounter.RawValue        = 0L;
            _currentCacheSizeInBlocksCounter.RawValue    = 0L;
            _totalLeasesLostCounter.RawValue             = 0L;
            _totalLeasesObtainedCounter.RawValue         = 0L;
            _totalEventsProcessedCounter.RawValue        = 0L;
        }
        internal ColdStorageInstrumentationPublisher(
            string instanceName,
            ColdStorageInstrumentationManager instrumentationManager)
        {
            _currentCacheSizeInBlocksCounter =
                instrumentationManager.CurrentCacheSizeInBlocksCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalWritesFailedCounter =
                instrumentationManager.TotalWritesFailedCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalWritesSucceededCounter =
                instrumentationManager.TotalWritesSucceededDefinition.CreatePerformanceCounter(instanceName);
            _totalBlocksWrittenCounter =
                instrumentationManager.TotalBlocksWrittenCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalConcurrentWritesFailedCounter =
                instrumentationManager.TotalConcurrentWritesFailedCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalWriteAttemptsCounter =
                instrumentationManager.TotalWriteAttemptsCounterDefinition.CreatePerformanceCounter(instanceName);
            _averageWriteTimeCounter =
                instrumentationManager.AverageWriteTimeCounterDefinition.CreatePerformanceCounter(instanceName);
            _averageWriteTimeBaseCounter =
                instrumentationManager.AverageWriteTimeBaseCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalLeasesLostCounter =
                instrumentationManager.TotalLeasesLostCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalLeasesObtainedCounter =
                instrumentationManager.TotalLeasesObtainedCounterDefinition.CreatePerformanceCounter(instanceName);
            _totalEventsProcessedCounter =
                instrumentationManager.TotalEventsProcessedCounterDefinition.CreatePerformanceCounter(instanceName);

            _totalWritesFailedCounter.RawValue = 0L;
            _totalWritesSucceededCounter.RawValue = 0L;
            _totalConcurrentWritesFailedCounter.RawValue = 0L;
            _totalWriteAttemptsCounter.RawValue = 0L;
            _averageWriteTimeCounter.RawValue = 0L;
            _averageWriteTimeBaseCounter.RawValue = 0L;
            _currentCacheSizeInBlocksCounter.RawValue = 0L;
            _totalLeasesLostCounter.RawValue = 0L;
            _totalLeasesObtainedCounter.RawValue = 0L;
            _totalEventsProcessedCounter.RawValue = 0L;
        }
Esempio n. 4
0
        private static async Task RunAsync(CancellationToken token)
        {
            var configuration = Configuration.GetCurrentConfiguration();
            ColdStorageCoordinator processor = null;
            var instrumentationPublisher =
                new ColdStorageInstrumentationManager(true, true).CreatePublisher("Console");

            processor =
                await ColdStorageCoordinator.CreateAsync(
                    "Console",
                    configuration.EventHubName,
                    configuration.ConsumerGroupName,
                    configuration.EventHubConnectionString,
                    configuration.CheckpointStorageAccount,
                    configuration.MaxBatchSize,
                    configuration.PreFetchCount,
                    configuration.ReceiveTimeout,
                    new[] { configuration.BlobWriterStorageAccount },
                    configuration.ContainerName,
                    configuration.RollSizeForBlobWriterMb,
                    configuration.BlobPrefix,
                    configuration.CircuitBreakerWarningLevel,
                    configuration.CircuitBreakerTripLevel,
                    configuration.CircuitBreakerStallInterval,
                    configuration.CircuitBreakerLogCooldownInterval,
                    instrumentationPublisher);

            Console.WriteLine("Running processor");

            try
            {
                await Task.Delay(Timeout.InfiniteTimeSpan, token);
            }
            catch (TaskCanceledException) { /* expected cancellation */ }

            processor.Dispose();
        }