/// <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 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(); } }
/// <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 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; } }