public void Store_Delete() { string name = Guid.NewGuid().ToString();//TestContext.TestName; ILocalDataStore store = new HierarchicalKeyStore(2); GrainReference reference = this.fixture.InternalGrainFactory.GetGrain(LegacyGrainId.NewId()); var data = TestStoreGrainState.NewRandomState(); output.WriteLine("Using store = {0}", store.GetType().FullName); Stopwatch sw = new Stopwatch(); var keys = GetKeys(name, reference); sw.Restart(); string eTag = store.WriteRow(keys, AsDictionary(data.State), null); output.WriteLine("Write returned Etag={0} after {1} {2}", eTag, sw.Elapsed, StorageProviderUtils.PrintOneWrite(keys, data, eTag)); sw.Restart(); var storedData = store.ReadRow(keys); output.WriteLine("Read returned {0} after {1}", StorageProviderUtils.PrintOneWrite(keys, storedData, eTag), sw.Elapsed); Assert.NotNull(data); // Should get some data from Read sw.Restart(); bool ok = store.DeleteRow(keys, eTag); Assert.True(ok, $"Row deleted OK after {sw.Elapsed}. Etag={eTag} Keys={StorageProviderUtils.PrintKeys(keys)}"); sw.Restart(); storedData = store.ReadRow(keys); // Try to re-read after delete output.WriteLine("Re-Read took {0} and returned {1}", sw.Elapsed, StorageProviderUtils.PrintData(storedData)); Assert.NotNull(data); // Should not get null data from Re-Read Assert.True(storedData.Count == 0, $"Should get no data from Re-Read but got: {StorageProviderUtils.PrintData(storedData)}"); sw.Restart(); const string oldEtag = null; eTag = store.WriteRow(keys, storedData, oldEtag); output.WriteLine("Write for Keys={0} Etag={1} Data={2} returned New Etag={3} after {4}", StorageProviderUtils.PrintKeys(keys), oldEtag, StorageProviderUtils.PrintData(storedData), eTag, sw.Elapsed); sw.Restart(); ok = store.DeleteRow(keys, eTag); Assert.True(ok, $"Row deleted OK after {sw.Elapsed}. Etag={eTag} Keys={StorageProviderUtils.PrintKeys(keys)}"); }
public void Store_Delete() { string name = TestContext.TestName; ILocalDataStore store = new HierarchicalKeyStore(2); GrainReference reference = GrainReference.FromGrainId(GrainId.NewId()); IDictionary <string, object> data = TestStoreGrainState.NewRandomState().AsDictionary(); Console.WriteLine("Using store = {0}", store.GetType().FullName); Stopwatch sw = new Stopwatch(); var keys = GetKeys(name, reference); sw.Restart(); string eTag = store.WriteRow(keys, data, null); Console.WriteLine("Write returned Etag={0} after {1} {2}", eTag, sw.Elapsed, StorageProviderUtils.PrintOneWrite(keys, data, eTag)); sw.Restart(); data = store.ReadRow(keys); Console.WriteLine("Read returned {0} after {1}", StorageProviderUtils.PrintOneWrite(keys, data, eTag), sw.Elapsed); Assert.IsNotNull(data, "Should get some data from Read"); sw.Restart(); bool ok = store.DeleteRow(keys, eTag); Assert.IsTrue(ok, "Row deleted OK after {0}. Etag={1} Keys={2}", sw.Elapsed, eTag, StorageProviderUtils.PrintKeys(keys)); sw.Restart(); data = store.ReadRow(keys); // Try to re-read after delete Console.WriteLine("Re-Read took {0} and returned {1}", sw.Elapsed, StorageProviderUtils.PrintData(data)); Assert.IsNotNull(data, "Should not get null data from Re-Read"); Assert.IsTrue(data.Count == 0, "Should get no data from Re-Read but got: {0}", StorageProviderUtils.PrintData(data)); sw.Restart(); const string oldEtag = null; eTag = store.WriteRow(keys, data, oldEtag); Console.WriteLine("Write for Keys={0} Etag={1} Data={2} returned New Etag={3} after {4}", StorageProviderUtils.PrintKeys(keys), oldEtag, StorageProviderUtils.PrintData(data), eTag, sw.Elapsed); sw.Restart(); ok = store.DeleteRow(keys, eTag); Assert.IsTrue(ok, "Row deleted OK after {0}. Etag={1} Keys={2}", sw.Elapsed, eTag, StorageProviderUtils.PrintKeys(keys)); }
public IList <IDictionary <string, object> > ReadMultiRow(IList <Tuple <string, string> > keys) { if (keys.Count > numKeyLayers) { throw new ArgumentOutOfRangeException("keys", keys.Count, string.Format("Too many key supplied -- Expected count = {0} Received = {1}", numKeyLayers, keys.Count)); } lock (lockable) { IList <IDictionary <string, object> > results = FindDataStores(keys); #if DEBUG Trace.TraceInformation("ReadMultiRow: Keys={0} returning Results={1}", StorageProviderUtils.PrintKeys(keys), StorageProviderUtils.PrintResults(results)); #endif return(results); } }
public IDictionary <string, object> ReadRow(IList <Tuple <string, string> > keys) { if (keys.Count > numKeyLayers) { var error = string.Format("Not enough keys supplied -- Expected count = {0} Received = {1}", numKeyLayers, keys.Count); Trace.TraceError(error); throw new ArgumentOutOfRangeException("keys", keys.Count, error); } lock (lockable) { IDictionary <string, object> data = GetDataStore(keys); #if DEBUG Trace.TraceInformation("ReadMultiRow: Keys={0} returning Data={1}", StorageProviderUtils.PrintKeys(keys), StorageProviderUtils.PrintData(data)); #endif return(data); } }