Exemple #1
0
        public void Store_WriteRead()
        {
            string name = TestContext.TestName;

            ILocalDataStore store = new HierarchicalKeyStore(2);

            GrainReference      reference = GrainReference.FromGrainId(GrainId.NewId());
            TestStoreGrainState state     = TestStoreGrainState.NewRandomState();
            Stopwatch           sw        = new Stopwatch();

            sw.Start();
            var keys = GetKeys(name, reference);

            store.WriteRow(keys, state.AsDictionary(), state.Etag);
            TimeSpan writeTime = sw.Elapsed;

            sw.Restart();
            TestStoreGrainState storedState = new TestStoreGrainState();
            var data = store.ReadRow(keys);

            storedState.SetAll(data);
            TimeSpan readTime = sw.Elapsed;

            Console.WriteLine("{0} - Write time = {1} Read time = {2}", store.GetType().FullName, writeTime, readTime);
            Assert.AreEqual(state.A, storedState.A, "A");
            Assert.AreEqual(state.B, storedState.B, "B");
            Assert.AreEqual(state.C, storedState.C, "C");
        }
Exemple #2
0
        public void Store_ReadMulti()
        {
            string name = TestContext.TestName;

            ILocalDataStore store = new HierarchicalKeyStore(2);

            // Write #1
            IList <Tuple <string, string> > keys = new[]
            {
                Tuple.Create("GrainType", name),
                Tuple.Create("GrainId", "1")
            }.ToList();
            TestStoreGrainState state = TestStoreGrainState.NewRandomState();

            state.A = name;
            store.WriteRow(keys, state.AsDictionary(), state.Etag);

            // Write #2
            keys = new[]
            {
                Tuple.Create("GrainType", name),
                Tuple.Create("GrainId", "2")
            }.ToList();
            state   = TestStoreGrainState.NewRandomState();
            state.A = name;
            store.WriteRow(keys, state.AsDictionary(), state.Etag);

            // Multi Read
            keys = new[]
            {
                Tuple.Create("GrainType", name)
            }.ToList();

            var results = store.ReadMultiRow(keys);

            Assert.AreEqual(2, results.Count, "Count");
        }