示例#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));
                }
            }
示例#2
0
 public override EntryUpdater <Key> Updater(long version, Lock @lock)
 {
     if (version <= _previousVersion)
     {
         return(EntryUpdater.NoUpdates());
     }
     Update(_highestAppliedVersion, version);
     _hasTrackedChanges.set(true);
     return(new Updater <Key>(@lock, Store, _changes, _appliedChanges, version));
 }
示例#3
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);
        }
示例#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();
            }
        }
示例#5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.helpers.collection.Pair<java.io.File, KeyValueStoreFile> initialState(DataInitializer<EntryUpdater<Key>> initializer) throws java.io.IOException
            internal virtual Pair <File, KeyValueStoreFile> InitialState(DataInitializer <EntryUpdater <Key> > initializer)
            {
                long version = initializer.InitialVersion();

                using (ActiveState <Key> creation = StateFactory.open(ReadableState.Empty(KeyFormat(), version), null, VersionContextSupplier))
                {
                    try (EntryUpdater <Key> updater = creation.resetter(new ReentrantLock(), () =>
                        {
                        }
                                                                        ))
                        {
                            initializer.Initialize(updater);
                        }
                    return(Rotation.create(KeyFormat().filter(creation.dataProvider()), initializer.InitialVersion()));
                }
            }
示例#6
0
            protected internal override Optional <EntryUpdater <Key> > OptionalUpdater(long version, Lock @lock)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final EntryUpdater<Key> post = postState.updater(version, lock);
                EntryUpdater <Key> post = PostState.updater(version, @lock);

                if (version <= Threshold)
                {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final EntryUpdater<Key> pre = preState.updater(version, lock);
                    EntryUpdater <Key> pre = PreState.updater(version, @lock);
                    return(new EntryUpdaterAnonymousInnerClass(this, @lock, post, pre));
                }
                else
                {
                    return(post);
                }
            }
示例#7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldUseEmptyUpdaterOnVersionLowerOrEqualToTheInitialVersion()
        public virtual void ShouldUseEmptyUpdaterOnVersionLowerOrEqualToTheInitialVersion()
        {
            // given
            long initialVersion = 42;

            when(_store.version()).thenReturn(initialVersion);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: ConcurrentMapState<?> state = createMapState();
            ConcurrentMapState <object> state = CreateMapState();

            // when
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: EntryUpdater<?> updater = state.updater(initialVersion, lock);
            EntryUpdater <object> updater = state.Updater(initialVersion, @lock);

            // expected
            assertEquals("Empty updater should be used for version less or equal to initial", EntryUpdater.NoUpdates(), updater);
        }
示例#8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void doNotMarkVersionAsDirtyOnAnotherKeyUpdate() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DoNotMarkVersionAsDirtyOnAnotherKeyUpdate()
        {
            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("b", new SimpleValueUpdate(2));
            }

            assertEquals(updaterVersionTxId, mapState.Version());
            versionContext.InitRead();
            mapState.Lookup("a", new EmptyValueSink());
            assertFalse(versionContext.Dirty);
        }
示例#9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCreateAnUpdaterForTheNextUnseenVersionUpdate()
        public virtual void ShouldCreateAnUpdaterForTheNextUnseenVersionUpdate()
        {
            // given
            long initialVersion = 42;

            when(_store.version()).thenReturn(initialVersion);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: ConcurrentMapState<?> state = createMapState();
            ConcurrentMapState <object> state = CreateMapState();

            // when
            long updateVersion = 43;
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: EntryUpdater<?> updater = state.updater(updateVersion, lock);
            EntryUpdater <object> updater = state.Updater(updateVersion, @lock);

            // then
            // it does not blow up
            assertNotNull(updater);
            assertEquals(updateVersion, state.Version());
        }
示例#10
0
 public void initialize(EntryUpdater <string> stringEntryUpdater)
 {
 }