Exemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void put(String key, final String value) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
            public virtual void Put(string key, string value)
            {
                using (EntryUpdater <string> updater = updater())
                {
                    updater.Apply(key, value(value));
                }
            }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void updateStore(final Store store, long transaction) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        private void UpdateStore(Store store, long transaction)
        {
            ThrowingConsumer <long, IOException> update = u =>
            {
                using (EntryUpdater <string> updater = store.Updater(u).get())
                {
                    updater.Apply("key " + u, Value("value " + u));
                }
            };

            update.Accept(transaction);
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void markDirtyVersionLookupOnKeyUpdate() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MarkDirtyVersionLookupOnKeyUpdate()
        {
            long updaterVersionTxId = 25;
            long lastClosedTxId     = 20;
            TransactionVersionContextSupplier versionContextSupplier = new TransactionVersionContextSupplier();

            versionContextSupplier.Init(() => lastClosedTxId);
            ConcurrentMapState <string> mapState = CreateMapState(versionContextSupplier);
            VersionContext versionContext        = versionContextSupplier.VersionContext;

            using (EntryUpdater <string> updater = mapState.Updater(updaterVersionTxId, @lock))
            {
                updater.Apply("a", new SimpleValueUpdate(1));
                updater.Apply("b", new SimpleValueUpdate(2));
            }

            assertEquals(updaterVersionTxId, mapState.Version());
            versionContext.InitRead();
            mapState.Lookup("a", new EmptyValueSink());
            assertTrue(versionContext.Dirty);
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @Resources.Life(STARTED) public void shouldLeaveStoreInGoodStateAfterRotationFailure() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldLeaveStoreInGoodStateAfterRotationFailure()
        {
            // GIVEN
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Store store = resourceManager.managed(createTestStore(0));
            Store store          = _resourceManager.managed(CreateTestStore(0));
            long  initialVersion = store.Version(store.Headers());
            // a key/value which is rotated into a persistent version
            string permanentKey   = "permakey";
            string permanentValue = "here";

            using (EntryUpdater <string> updater = store.Updater(initialVersion + 1).get())
            {
                updater.Apply(permanentKey, Value(permanentValue));
            }
            store.PrepareRotation(initialVersion + 1).rotate();

            // another key/value which is applied to the new version
            string key   = "mykey";
            string value = "first";

            using (EntryUpdater <string> updater = store.Updater(initialVersion + 2).get())
            {
                updater.Apply(key, value("first"));
            }

            // WHEN rotating a version which doesn't exist
            try
            {
                store.PrepareRotation(initialVersion + 3).rotate();
                fail("Should've failed rotation, since that version doesn't exist yet");
            }
            catch (RotationTimeoutException)
            {
                // THEN afterwards it should still be possible to read from the counts store
                assertEquals(permanentValue, store.Get(permanentKey));
                assertEquals(value, store.Get(key));

                // and also continue to make updates
                using (EntryUpdater <string> updater = store.Updater(initialVersion + 2).get())
                {
                    updater.Apply(key, value("second"));
                }

                // and eventually rotation again successfully
                store.PrepareRotation(initialVersion + 3).rotate();
            }
        }