/// <summary> Write state data function for this storage provider. </summary> /// <see cref="IStorageProvider.WriteStateAsync"/> public virtual async Task WriteStateAsync(string grainType, GrainReference grainReference, IGrainState grainState) { var keys = MakeKeys(grainType, grainReference); string key = HierarchicalKeyStore.MakeStoreKey(keys); if (Log.IsVerbose2) { Log.Verbose2("Write {0} ", StorageProviderUtils.PrintOneWrite(keys, grainState.State, grainState.ETag)); } IMemoryStorageGrain storageGrain = GetStorageGrain(key); grainState.ETag = await storageGrain.WriteStateAsync(STATE_STORE_NAME, key, grainState); }
/// <summary> Write state data function for this storage provider. </summary> /// <see cref="IStorageProvider#WriteStateAsync"/> public virtual async Task WriteStateAsync(string grainType, GrainReference grainReference, GrainState grainState) { var keys = MakeKeys(grainType, grainReference); var data = grainState.AsDictionary(); string prevEtag = grainState.Etag; if (Log.IsVerbose2) { Log.Verbose2("Write {0} ", StorageProviderUtils.PrintOneWrite(keys, data, prevEtag)); } string key = HierarchicalKeyStore.MakeStoreKey(keys); IMemoryStorageGrain storageGrain = GetStorageGrain(key); string newEtag = await storageGrain.WriteStateAsync(STATE_STORE_NAME, key, data, prevEtag); grainState.Etag = newEtag; }
/// <summary> Write state data function for this storage provider. </summary> /// <see cref="IGrainStorage.WriteStateAsync"/> public virtual async Task WriteStateAsync(string grainType, GrainReference grainReference, IGrainState grainState) { var keys = MakeKeys(grainType, grainReference); string key = HierarchicalKeyStore.MakeStoreKey(keys); if (logger.IsEnabled(LogLevel.Trace)) { logger.LogTrace("Write {Write} ", StorageProviderUtils.PrintOneWrite(keys, grainState.State, grainState.ETag)); } IMemoryStorageGrain storageGrain = GetStorageGrain(key); try { grainState.ETag = await storageGrain.WriteStateAsync(STATE_STORE_NAME, key, grainState); } catch (MemoryStorageEtagMismatchException e) { throw e.AsInconsistentStateException(); } }
/// <summary> Write state data function for this storage provider. </summary> /// <see cref="IStorageProvider.WriteStateAsync"/> public virtual async Task WriteStateAsync(string grainType, GrainReference grainReference, IGrainState grainState) { IList <Tuple <string, string> > keys = MakeKeys(grainType, grainReference).ToList(); string key = HierarchicalKeyStore.MakeStoreKey(keys); if (Log.IsVerbose2) { Log.Verbose2("Write {0} ", StorageProviderUtils.PrintOneWrite(keys, grainState.State, grainState.ETag)); } IMemoryStorageGrain storageGrain = GetStorageGrain(key); try { grainState.ETag = await storageGrain.WriteStateAsync(STATE_STORE_NAME, key, grainState); } catch (MemoryStorageEtagMismatchException e) { throw e.AsInconsistentStateException(); } }
/// <summary> Write state data function for this storage provider. </summary> /// <see cref="IStorageProvider#WriteStateAsync"/> public virtual async Task WriteStateAsync(string grainType, GrainReference grainReference, GrainState grainState) { var keys = MakeKeys(grainType, grainReference); var data = grainState.AsDictionary(); string receivedEtag = grainState.Etag; if (Log.IsVerbose2) { Log.Verbose2("Write {0} ", StorageProviderUtils.PrintOneWrite(keys, data, receivedEtag)); } if (receivedEtag != null && receivedEtag != etag) { throw new InconsistentStateException(string.Format("Etag mismatch durign Write: Expected = {0} Received = {1}", etag, receivedEtag)); } string key = HierarchicalKeyStore.MakeStoreKey(keys); IMemoryStorageGrain storageGrain = GetStorageGrain(key); await storageGrain.WriteStateAsync(STATE_STORE_NAME, key, data); etag = NewEtag(); }