public override InternalIndexState GetInitialState(StoreIndexDescriptor descriptor) { TemporalIndexFiles temporalIndexFiles = new TemporalIndexFiles(DirectoryStructure(), descriptor, _fs); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final Iterable<TemporalIndexFiles.FileLayout> existing = temporalIndexFiles.existing(); IEnumerable <TemporalIndexFiles.FileLayout> existing = temporalIndexFiles.Existing(); InternalIndexState state = InternalIndexState.ONLINE; foreach (TemporalIndexFiles.FileLayout subIndex in existing) { try { switch (NativeIndexes.ReadState(_pageCache, subIndex.indexFile)) { case FAILED: return(InternalIndexState.FAILED); case POPULATING: state = InternalIndexState.POPULATING; goto default; default: // continue break; } } catch (Exception e) when(e is MetadataMismatchException || e is IOException) { _monitor.failedToOpenIndex(descriptor, "Requesting re-population.", e); return(InternalIndexState.POPULATING); } } return(state); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: public org.neo4j.graphdb.schema.Schema_IndexState getIndexState(final org.neo4j.graphdb.schema.IndexDefinition index) public override Org.Neo4j.Graphdb.schema.Schema_IndexState GetIndexState(IndexDefinition index) { KernelTransaction transaction = SafeAcquireTransaction(_transactionSupplier); try { using (Statement ignore = transaction.AcquireStatement()) { SchemaRead schemaRead = transaction.SchemaRead(); IndexReference reference = GetIndexReference(schemaRead, transaction.TokenRead(), (IndexDefinitionImpl)index); InternalIndexState indexState = schemaRead.IndexGetState(reference); switch (indexState) { case InternalIndexState.POPULATING: return(POPULATING); case InternalIndexState.ONLINE: return(ONLINE); case InternalIndexState.FAILED: return(FAILED); default: throw new System.ArgumentException(string.Format("Illegal index state {0}", indexState)); } } } catch (Exception e) when(e is SchemaRuleNotFoundException || e is IndexNotFoundKernelException) { throw NewIndexNotFoundException(index, e); } }
internal virtual void LogCompletionMessage() { InternalIndexState postPopulationState = Flipper.State; string messageTemplate = IsIndexPopulationOngoing(postPopulationState) ? "Index created. Starting data checks. Index [%s] is %s." : "Index creation finished. Index [%s] is %s."; outerInstance.Log.info(messageTemplate, IndexUserDescription, postPopulationState.name()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportInitialStateAsPopulatingIfPopulationStartedButIncomplete() public virtual void ShouldReportInitialStateAsPopulatingIfPopulationStartedButIncomplete() { // given _provider = NewProvider(); IndexPopulator populator = _provider.getPopulator(Descriptor(), SamplingConfig(), heapBufferFactory(1024)); populator.Create(); // when InternalIndexState state = _provider.getInitialState(Descriptor()); // then assertEquals(InternalIndexState.POPULATING, state); populator.Close(true); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportInitialStateAsOnlineIfPopulationCompletedSuccessfully() public virtual void ShouldReportInitialStateAsOnlineIfPopulationCompletedSuccessfully() { // given _provider = NewProvider(); IndexPopulator populator = _provider.getPopulator(Descriptor(), SamplingConfig(), heapBufferFactory(1024)); populator.Create(); populator.Close(true); // when InternalIndexState state = _provider.getInitialState(Descriptor()); // then assertEquals(InternalIndexState.ONLINE, state); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportInitialStateAsFailedIfMarkedAsFailed() public virtual void ShouldReportInitialStateAsFailedIfMarkedAsFailed() { // given _provider = NewProvider(); IndexPopulator populator = _provider.getPopulator(Descriptor(), SamplingConfig(), heapBufferFactory(1024)); populator.Create(); populator.MarkAsFailed("Just some failure"); populator.Close(false); // when InternalIndexState state = _provider.getInitialState(Descriptor()); // then assertEquals(InternalIndexState.FAILED, state); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldRequestIndexPopulationIfTheIndexIsCorrupt() internal virtual void ShouldRequestIndexPopulationIfTheIndexIsCorrupt() { // Given long faultyIndexId = 1; CorruptIndexException error = new CorruptIndexException("It's broken.", ""); LuceneIndexProvider provider = NewFaultyIndexProvider(faultyIndexId, error); // When StoreIndexDescriptor descriptor = forSchema(forLabel(1, 1), provider.ProviderDescriptor).withId(faultyIndexId); InternalIndexState initialState = provider.GetInitialState(descriptor); // Then assertThat(initialState, equalTo(InternalIndexState.POPULATING)); _logProvider.assertAtLeastOnce(LoggedException(error)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test void shouldRequestIndexPopulationWhenFailingWithEOFException() internal virtual void ShouldRequestIndexPopulationWhenFailingWithEOFException() { // Given long faultyIndexId = 1; EOFException error = new EOFException("/some/path/somewhere"); LuceneIndexProvider provider = NewFaultyIndexProvider(faultyIndexId, error); // When StoreIndexDescriptor descriptor = forSchema(forLabel(1, 1), provider.ProviderDescriptor).withId(faultyIndexId); InternalIndexState initialState = provider.GetInitialState(descriptor); // Then assertThat(initialState, equalTo(InternalIndexState.POPULATING)); _logProvider.assertAtLeastOnce(LoggedException(error)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportPopulatingIfAnyIsPopulating() public virtual void ShouldReportPopulatingIfAnyIsPopulating() { // given foreach (InternalIndexState state in array(InternalIndexState.ONLINE, InternalIndexState.POPULATING)) { foreach (IndexProvider populatingProvider in _aliveProviders) { // when foreach (IndexProvider aliveProvider in _aliveProviders) { SetInitialState(aliveProvider, populatingProvider == aliveProvider ? InternalIndexState.POPULATING : state); } InternalIndexState initialState = _fusionIndexProvider.getInitialState(AnIndex); // then assertEquals(InternalIndexState.POPULATING, initialState); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private boolean isOnline(IndexSpecifier specifier, org.neo4j.internal.kernel.api.IndexReference index) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException private bool IsOnline(IndexSpecifier specifier, IndexReference index) { InternalIndexState state = GetState(specifier, index); switch (state) { case InternalIndexState.POPULATING: return(false); case InternalIndexState.ONLINE: return(true); case InternalIndexState.FAILED: string cause = GetFailure(specifier, index); throw new ProcedureException(Org.Neo4j.Kernel.Api.Exceptions.Status_Schema.IndexCreationFailed, IndexPopulationFailure.appendCauseOfFailure("Index %s is in failed state.", cause), specifier); default: throw new System.InvalidOperationException("Unknown index state " + state); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportFailedIfAnyIsFailed() public virtual void ShouldReportFailedIfAnyIsFailed() { // given IndexProvider provider = _fusionIndexProvider; foreach (InternalIndexState state in Enum.GetValues(typeof(InternalIndexState))) { foreach (IndexProvider failedProvider in _aliveProviders) { // when foreach (IndexProvider aliveProvider in _aliveProviders) { SetInitialState(aliveProvider, failedProvider == aliveProvider ? InternalIndexState.FAILED : state); } InternalIndexState initialState = provider.GetInitialState(AnIndex); // then assertEquals(InternalIndexState.FAILED, initialState); } } }
/* getInitialState */ // pattern: open populator, markAsFailed, close populator, getInitialState, getPopulationFailure //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReportCorrectInitialStateIfIndexDoesntExist() public virtual void ShouldReportCorrectInitialStateIfIndexDoesntExist() { // given _provider = NewProvider(); // when InternalIndexState state = _provider.getInitialState(Descriptor()); // then InternalIndexState expected = ExpectedStateOnNonExistingSubIndex(); assertEquals(expected, state); if (InternalIndexState.POPULATING == expected) { _logging.rawMessageMatcher().assertContains("Failed to open index"); } else { _logging.rawMessageMatcher().assertNotContains("Failed to open index"); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void assertHeader(org.neo4j.internal.kernel.api.InternalIndexState expectedState, String failureMessage, boolean messageTruncated) throws java.io.IOException private void AssertHeader(InternalIndexState expectedState, string failureMessage, bool messageTruncated) { NativeIndexHeaderReader headerReader = new NativeIndexHeaderReader(NO_HEADER_READER); using (GBPTree <KEY, VALUE> ignored = (new GBPTreeBuilder <KEY, VALUE>(pageCache, IndexFile, layout)).with(headerReader).build()) { switch (expectedState) { case InternalIndexState.ONLINE: assertEquals("Index was not marked as online when expected not to be.", BYTE_ONLINE, headerReader.State); assertNull("Expected failure message to be null when marked as online.", headerReader.FailureMessage); break; case InternalIndexState.FAILED: assertEquals("Index was marked as online when expected not to be.", BYTE_FAILED, headerReader.State); if (messageTruncated) { assertTrue(headerReader.FailureMessage.Length < failureMessage.Length); assertTrue(failureMessage.StartsWith(headerReader.FailureMessage, StringComparison.Ordinal)); } else { assertEquals(failureMessage, headerReader.FailureMessage); } break; case InternalIndexState.POPULATING: assertEquals("Index was not left as populating when expected to be.", BYTE_POPULATING, headerReader.State); assertNull("Expected failure message to be null when marked as populating.", headerReader.FailureMessage); break; default: throw new System.NotSupportedException("Unexpected index state " + expectedState); } } }
private void SetInitialState(IndexProvider mockedProvider, InternalIndexState state) { when(mockedProvider.GetInitialState(any(typeof(StoreIndexDescriptor)))).thenReturn(state); }
public override void InitialState(StoreIndexDescriptor descriptor, InternalIndexState state) { InitialStateMap[descriptor] = state; }
internal virtual bool IsIndexPopulationOngoing(InternalIndexState postPopulationState) { return(InternalIndexState.POPULATING == postPopulationState); }