Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected final <Value> Value lookup(Key key, Reader<Value> reader) throws java.io.IOException
        protected internal Value Lookup <Value>(Key key, Reader <Value> reader)
        {
            ValueLookup <Value> lookup = new ValueLookup <Value>(reader);
            long retriesLeft           = MaxLookupRetryCount;

            while (retriesLeft > 0)
            {
                ProgressiveState <Key> originalState = this.State;
                try
                {
                    return(lookup.Value(!originalState.lookup(key, lookup)));
                }
                catch (FileIsNotMappedException e)
                {
                    // if the state has changed we think the exception is caused by a rotation event. In this
                    // case we simply retry the lookup on the rotated state. Otherwise we rethrow.
                    if (originalState == this.State)
                    {
                        throw e;
                    }
                }
                retriesLeft--;
            }
            throw new IOException(string.Format("Failed to lookup `{0}` in key value store, after {1:D} retries", key, MaxLookupRetryCount));
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private ProgressiveState<String> stateWithLookup(org.neo4j.function.ThrowingSupplier<bool, java.io.IOException> valueSupplier) throws java.io.IOException
        private ProgressiveState <string> StateWithLookup(ThrowingSupplier <bool, IOException> valueSupplier)
        {
            ProgressiveState <string> state = mock(typeof(ProgressiveState));

            when(state.lookup(any(), any())).thenAnswer(invocation =>
            {
                bool wasFound = valueSupplier.Get();
                invocation.getArgument <ValueLookup <string> >(1).value(null);
                return(wasFound);
            });
            return(state);
        }
Пример #3
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 accessClosedStateShouldThrow() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AccessClosedStateShouldThrow()
        {
            Store store = _resourceManager.managed(new Store(this));

            store.Put("test", "value");
            store.PrepareRotation(0).rotate();
            ProgressiveState <string> lookupState = store.State;

            store.PrepareRotation(0).rotate();

            _expectedException.expect(typeof(FileIsNotMappedException));
            _expectedException.expectMessage("File has been unmapped");

            lookupState.lookup("test", new ValueSinkAnonymousInnerClass(this));
        }