/// <summary> /// Async method to cause refresh of the current grain state data from backing store. /// Any previous contents of the grain state data will be overwritten. /// </summary> public async Task ReadStateAsync() { const string what = "ReadState"; Stopwatch sw = Stopwatch.StartNew(); GrainReference grainRef = baseGrain.GrainReference; try { await store.ReadStateAsync(grainTypeName, grainRef, grain.GrainState); StorageStatisticsGroup.OnStorageRead(store, grainTypeName, grainRef, sw.Elapsed); } catch (Exception exc) { StorageStatisticsGroup.OnStorageReadError(store, grainTypeName, grainRef); string errMsg = MakeErrorMsg(what, exc); store.Log.Error((int)ErrorCode.StorageProvider_ReadFailed, errMsg, exc); throw new OrleansException(errMsg, exc); } finally { sw.Stop(); } }
/// <summary> /// Async method to cause write of the current grain state data into backing store. /// </summary> public async Task WriteStateAsync() { const string what = "WriteState"; try { Stopwatch sw = Stopwatch.StartNew(); await store.WriteStateAsync(name, grainRef, grainState); sw.Stop(); StorageStatisticsGroup.OnStorageWrite(store, name, grainRef, sw.Elapsed); } catch (Exception exc) { StorageStatisticsGroup.OnStorageWriteError(store, name, grainRef); string errMsgToLog = MakeErrorMsg(what, exc); store.Log.Error((int)ErrorCode.StorageProvider_WriteFailed, errMsgToLog, exc); // If error is not specialization of OrleansException, wrap it if (!(exc is OrleansException)) { throw new OrleansException(errMsgToLog, exc); } throw; } }
/// <summary> /// Async method to cause write of the current grain state data into backing store. /// </summary> public async Task ClearStateAsync() { const string what = "ClearState"; Stopwatch sw = Stopwatch.StartNew(); GrainReference grainRef = baseGrain.GrainReference; try { // Clear (most likely Delete) state from external storage await store.ClearStateAsync(grainTypeName, grainRef, grain.GrainState); // Reset the in-memory copy of the state grain.GrainState.State = Activator.CreateInstance(grain.GrainState.State.GetType()); // Update counters StorageStatisticsGroup.OnStorageDelete(store, grainTypeName, grainRef, sw.Elapsed); } catch (Exception exc) { StorageStatisticsGroup.OnStorageDeleteError(store, grainTypeName, grainRef); string errMsg = MakeErrorMsg(what, exc); store.Log.Error((int)ErrorCode.StorageProvider_DeleteFailed, errMsg, exc); throw new OrleansException(errMsg, exc); } finally { sw.Stop(); } }
/// <summary> /// Async method to cause refresh of the current grain state data from backin store. /// Any previous contents of the grain state data will be overwritten. /// </summary> public async Task ReadStateAsync() { const string what = "ReadState"; Stopwatch sw = Stopwatch.StartNew(); // The below is the worng way to create GrainReference. // IAddressable.AsReference is also a wrong way to get GrainReference. // Both are weakly types and lose the actual strongly typed Grain Reference. GrainReference grainRef = RuntimeClient.Current.CurrentActivationData.GrainReference; IStorageProvider storage = GetCheckStorageProvider(what); try { await storage.ReadStateAsync(grainTypeName, grainRef, this); StorageStatisticsGroup.OnStorageRead(storage, grainTypeName, grainRef, sw.Elapsed); } catch (Exception exc) { StorageStatisticsGroup.OnStorageReadError(storage, grainTypeName, grainRef); string errMsg = MakeErrorMsg(what, grainRef, exc); storage.Log.Error((int)ErrorCode.StorageProvider_ReadFailed, errMsg, exc); throw new OrleansException(errMsg, exc); } finally { sw.Stop(); } }
/// <summary> /// Async method to cause write of the current grain state data into backing store. /// </summary> public async Task ClearStateAsync() { const string what = "ClearState"; try { Stopwatch sw = Stopwatch.StartNew(); // Clear (most likely Delete) state from external storage await store.ClearStateAsync(name, grainRef, grainState); sw.Stop(); // Reset the in-memory copy of the state grainState.State = new TState(); // Update counters StorageStatisticsGroup.OnStorageDelete(store, name, grainRef, sw.Elapsed); } catch (Exception exc) { StorageStatisticsGroup.OnStorageDeleteError(store, name, grainRef); string errMsg = MakeErrorMsg(what, exc); store.Log.Error((int)ErrorCode.StorageProvider_DeleteFailed, errMsg, exc); if (!(exc is OrleansException)) { throw new OrleansException(errMsg, exc); } throw; } }
/// <summary> /// Async method to cause refresh of the current grain state data from backing store. /// Any previous contents of the grain state data will be overwritten. /// </summary> public async Task ReadStateAsync() { const string what = "ReadState"; Stopwatch sw = Stopwatch.StartNew(); try { CheckRuntimeContext(); await store.ReadStateAsync(name, grainRef, grainState); StorageStatisticsGroup.OnStorageRead(name, grainRef, sw.Elapsed); } catch (Exception exc) { StorageStatisticsGroup.OnStorageReadError(name, grainRef); string errMsg = MakeErrorMsg(what, exc); this.logger.Error((int)ErrorCode.StorageProvider_ReadFailed, errMsg, exc); if (!(exc is OrleansException)) { throw new OrleansException(errMsg, exc); } throw; } finally { sw.Stop(); } }
/// <summary> /// Async method to cause write of the current grain state data into backin store. /// </summary> public async Task ClearStateAsync() { const string what = "ClearState"; Stopwatch sw = Stopwatch.StartNew(); GrainReference grainRef = RuntimeClient.Current.CurrentActivationData.GrainReference; IStorageProvider storage = GetCheckStorageProvider(what); try { // Clear (most likely Delete) state from external storage await storage.ClearStateAsync(grainTypeName, grainRef, this); // Null out the in-memory copy of the state SetAll(null); // Update counters StorageStatisticsGroup.OnStorageDelete(storage, grainTypeName, grainRef, sw.Elapsed); } catch (Exception exc) { StorageStatisticsGroup.OnStorageDeleteError(storage, grainTypeName, grainRef); string errMsg = MakeErrorMsg(what, grainRef, exc); storage.Log.Error((int)ErrorCode.StorageProvider_DeleteFailed, errMsg, exc); throw new OrleansException(errMsg, exc); } finally { sw.Stop(); } }
public SiloStatisticsManager( IOptions <SiloStatisticsOptions> statisticsOptions, IOptions <LoadSheddingOptions> loadSheddingOptions, IOptions <StorageOptions> azureStorageOptions, ILocalSiloDetails siloDetails, SerializationManager serializationManager, ITelemetryProducer telemetryProducer, IHostEnvironmentStatistics hostEnvironmentStatistics, IAppEnvironmentStatistics appEnvironmentStatistics, ILoggerFactory loggerFactory, IOptions <SiloMessagingOptions> messagingOptions) { this.siloDetails = siloDetails; this.storageOptions = azureStorageOptions.Value; MessagingStatisticsGroup.Init(true); MessagingProcessingStatisticsGroup.Init(); NetworkingStatisticsGroup.Init(true); ApplicationRequestsStatisticsGroup.Init(messagingOptions.Value.ResponseTimeout); SchedulerStatisticsGroup.Init(loggerFactory); StorageStatisticsGroup.Init(); TransactionsStatisticsGroup.Init(); this.logger = loggerFactory.CreateLogger <SiloStatisticsManager>(); this.hostEnvironmentStatistics = hostEnvironmentStatistics; this.logStatistics = new LogStatistics(statisticsOptions.Value.LogWriteInterval, true, serializationManager, loggerFactory); this.MetricsTable = new SiloPerformanceMetrics(this.hostEnvironmentStatistics, appEnvironmentStatistics, loggerFactory, loadSheddingOptions); this.countersPublisher = new CountersStatistics(statisticsOptions.Value.PerfCountersWriteInterval, telemetryProducer, loggerFactory); }
/// <summary> /// Async method to cause write of the current grain state data into backing store. /// </summary> public async Task ClearStateAsync() { const string what = "ClearState"; try { GrainRuntime.CheckRuntimeContext(RuntimeContext.Current); Stopwatch sw = Stopwatch.StartNew(); // Clear (most likely Delete) state from external storage await store.ClearStateAsync(name, grainRef, grainState); sw.Stop(); // Reset the in-memory copy of the state grainState.State = Activator.CreateInstance <TState>(); // Update counters StorageStatisticsGroup.OnStorageDelete(name, grainRef, sw.Elapsed); } catch (Exception exc) { StorageStatisticsGroup.OnStorageDeleteError(name, grainRef); string errMsg = MakeErrorMsg(what, exc); this.logger.Error((int)ErrorCode.StorageProvider_DeleteFailed, errMsg, exc); if (!(exc is OrleansException)) { throw new OrleansException(errMsg, exc); } throw; } }
/// <summary> /// Async method to cause write of the current grain state data into backing store. /// </summary> public async Task WriteStateAsync() { const string what = "WriteState"; Stopwatch sw = Stopwatch.StartNew(); GrainReference grainRef = baseGrain.GrainReference; Exception errorOccurred; try { await store.WriteStateAsync(grainTypeName, grainRef, statefulGrain.GrainState); StorageStatisticsGroup.OnStorageWrite(store, grainTypeName, grainRef, sw.Elapsed); errorOccurred = null; } catch (Exception exc) { errorOccurred = exc; } // Note, we can't do this inside catch block above, because await is not permitted there. if (errorOccurred != null) { StorageStatisticsGroup.OnStorageWriteError(store, grainTypeName, grainRef); string errMsgToLog = MakeErrorMsg(what, errorOccurred); store.Log.Error((int)ErrorCode.StorageProvider_WriteFailed, errMsgToLog, errorOccurred); // If error is not specialization of OrleansException, wrap it if (!(errorOccurred is OrleansException)) { errorOccurred = new OrleansException(errMsgToLog, errorOccurred); } #if REREAD_STATE_AFTER_WRITE_FAILED // Force rollback to previously stored state try { sw.Restart(); store.Log.Warn(ErrorCode.StorageProvider_ForceReRead, "Forcing re-read of last good state for grain Type={0}", grainTypeName); await store.ReadStateAsync(grainTypeName, grainRef, grain.GrainState); StorageStatisticsGroup.OnStorageRead(store, grainTypeName, grainRef, sw.Elapsed); } catch (Exception exc) { StorageStatisticsGroup.OnStorageReadError(store, grainTypeName, grainRef); // Should we ignore this secondary error, and just return the original one? errMsgToLog = MakeErrorMsg("re-read state from store after write error", exc); errorOccurred = new OrleansException(errMsgToLog, exc); } #endif } sw.Stop(); if (errorOccurred != null) { throw errorOccurred; } }
public SiloStatisticsManager( IOptions <StatisticsOptions> statisticsOptions, ITelemetryProducer telemetryProducer, ILoggerFactory loggerFactory) { MessagingStatisticsGroup.Init(); MessagingProcessingStatisticsGroup.Init(); NetworkingStatisticsGroup.Init(); StorageStatisticsGroup.Init(); this.logStatistics = new LogStatistics(statisticsOptions.Value.LogWriteInterval, true, loggerFactory); this.countersPublisher = new CountersStatistics(statisticsOptions.Value.PerfCountersWriteInterval, telemetryProducer, loggerFactory); }
internal SiloStatisticsManager(GlobalConfiguration globalConfig, NodeConfiguration nodeConfig) { MessagingStatisticsGroup.Init(true); MessagingProcessingStatisticsGroup.Init(); NetworkingStatisticsGroup.Init(true); ApplicationRequestsStatisticsGroup.Init(globalConfig.ResponseTimeout); SchedulerStatisticsGroup.Init(); StorageStatisticsGroup.Init(); runtimeStats = new RuntimeStatisticsGroup(); logStatistics = new LogStatistics(nodeConfig.StatisticsLogWriteInterval, true); MetricsTable = new SiloPerformanceMetrics(runtimeStats, nodeConfig); perfCountersPublisher = new PerfCountersStatistics(nodeConfig.StatisticsPerfCountersWriteInterval); }
public SiloStatisticsManager( IOptions <SiloStatisticsOptions> statisticsOptions, SerializationManager serializationManager, ITelemetryProducer telemetryProducer, ILoggerFactory loggerFactory) { MessagingStatisticsGroup.Init(true); MessagingProcessingStatisticsGroup.Init(); NetworkingStatisticsGroup.Init(true); ApplicationRequestsStatisticsGroup.Init(); SchedulerStatisticsGroup.Init(loggerFactory); StorageStatisticsGroup.Init(); TransactionsStatisticsGroup.Init(); this.logStatistics = new LogStatistics(statisticsOptions.Value.LogWriteInterval, true, serializationManager, loggerFactory); this.countersPublisher = new CountersStatistics(statisticsOptions.Value.PerfCountersWriteInterval, telemetryProducer, loggerFactory); }
public SiloStatisticsManager(NodeConfiguration nodeConfiguration, ILocalSiloDetails siloDetails, SerializationManager serializationManager, ITelemetryProducer telemetryProducer, ILoggerFactory loggerFactory, IOptions <MessagingOptions> messagingOptions) { this.siloDetails = siloDetails; MessagingStatisticsGroup.Init(true); MessagingProcessingStatisticsGroup.Init(); NetworkingStatisticsGroup.Init(true); ApplicationRequestsStatisticsGroup.Init(messagingOptions.Value.ResponseTimeout); SchedulerStatisticsGroup.Init(loggerFactory); StorageStatisticsGroup.Init(); TransactionsStatisticsGroup.Init(); this.logger = loggerFactory.CreateLogger <SiloStatisticsManager>(); runtimeStats = new RuntimeStatisticsGroup(loggerFactory); this.logStatistics = new LogStatistics(nodeConfiguration.StatisticsLogWriteInterval, true, serializationManager, loggerFactory); this.MetricsTable = new SiloPerformanceMetrics(this.runtimeStats, loggerFactory, nodeConfiguration); this.countersPublisher = new CountersStatistics(nodeConfiguration.StatisticsPerfCountersWriteInterval, telemetryProducer, loggerFactory); }
public SiloStatisticsManager(SiloInitializationParameters initializationParams) { MessagingStatisticsGroup.Init(true); MessagingProcessingStatisticsGroup.Init(); NetworkingStatisticsGroup.Init(true); ApplicationRequestsStatisticsGroup.Init(initializationParams.GlobalConfig.ResponseTimeout); SchedulerStatisticsGroup.Init(); StorageStatisticsGroup.Init(); runtimeStats = new RuntimeStatisticsGroup(); this.logStatistics = new LogStatistics(initializationParams.NodeConfig.StatisticsLogWriteInterval, true); this.MetricsTable = new SiloPerformanceMetrics(this.runtimeStats, initializationParams.NodeConfig); this.countersPublisher = new CountersStatistics(initializationParams.NodeConfig.StatisticsPerfCountersWriteInterval); initializationParams.ClusterConfig.OnConfigChange( "Defaults/LoadShedding", () => this.MetricsTable.NodeConfig = initializationParams.NodeConfig, false); }
public SiloStatisticsManager(SiloInitializationParameters initializationParams, SerializationManager serializationManager, ITelemetryProducer telemetryProducer, ILoggerFactory loggerFactory) { MessagingStatisticsGroup.Init(true); MessagingProcessingStatisticsGroup.Init(); NetworkingStatisticsGroup.Init(true); ApplicationRequestsStatisticsGroup.Init(initializationParams.ClusterConfig.Globals.ResponseTimeout); SchedulerStatisticsGroup.Init(loggerFactory); StorageStatisticsGroup.Init(); TransactionsStatisticsGroup.Init(); this.logger = new LoggerWrapper <SiloStatisticsManager>(loggerFactory); runtimeStats = new RuntimeStatisticsGroup(loggerFactory); this.logStatistics = new LogStatistics(initializationParams.NodeConfig.StatisticsLogWriteInterval, true, serializationManager, loggerFactory); this.MetricsTable = new SiloPerformanceMetrics(this.runtimeStats, loggerFactory, initializationParams.NodeConfig); this.countersPublisher = new CountersStatistics(initializationParams.NodeConfig.StatisticsPerfCountersWriteInterval, telemetryProducer, loggerFactory); initializationParams.ClusterConfig.OnConfigChange( "Defaults/LoadShedding", () => this.MetricsTable.NodeConfig = initializationParams.NodeConfig, false); }