//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void persistentCallToSecondary(org.neo4j.causalclustering.messaging.CatchUpRequest request, org.neo4j.causalclustering.catchup.CatchUpResponseAdaptor<StoreCopyFinishedResponse> copyHandler, org.neo4j.causalclustering.catchup.CatchupAddressProvider addressProvider, TerminationCondition terminationCondition) throws StoreCopyFailedException private void PersistentCallToSecondary(CatchUpRequest request, CatchUpResponseAdaptor <StoreCopyFinishedResponse> copyHandler, CatchupAddressProvider addressProvider, TerminationCondition terminationCondition) { Org.Neo4j.causalclustering.helper.TimeoutStrategy_Timeout timeout = _backOffStrategy.newTimeout(); while (true) { try { AdvertisedSocketAddress address = addressProvider.Secondary(); _log.info(format("Sending request '%s' to '%s'", request, address)); StoreCopyFinishedResponse response = _catchUpClient.makeBlockingRequest(address, request, copyHandler); if (SuccessfulRequest(response, request)) { break; } } catch (CatchUpClientException e) { Exception cause = e.InnerException; if (cause is ConnectException) { _log.warn(cause.Message); } else { _log.warn(format("Request failed exceptionally '%s'.", request), e); } } catch (CatchupAddressResolutionException e) { _log.warn("Unable to resolve address for '%s'. %s", request, e.Message); } terminationCondition(); AwaitAndIncrementTimeout(timeout); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGiveProperErrorOnTxBehind() public virtual void ShouldGiveProperErrorOnTxBehind() { _embeddedChannel.writeInbound(new GetStoreFileRequest(_storeIdMatching, new File("some-file"), 2)); assertEquals(ResponseMessageType.STORE_COPY_FINISHED, _embeddedChannel.readOutbound()); StoreCopyFinishedResponse expectedResponse = new StoreCopyFinishedResponse(StoreCopyFinishedResponse.Status.ETooFarBehind); assertEquals(expectedResponse, _embeddedChannel.readOutbound()); assertTrue(_catchupServerProtocol.isExpecting(CatchupServerProtocol.State.MESSAGE_TYPE)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void individualFileCopyFailsIfStoreIdMismatch() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void IndividualFileCopyFailsIfStoreIdMismatch() { // given a file exists on the server AddData(_graphDb); File expectedExistingFile = _graphDb.databaseLayout().file(EXISTING_FILE_NAME); // and SimpleCatchupClient simpleCatchupClient = new SimpleCatchupClient(_graphDb, _fsa, _catchupClient, _catchupServer, _temporaryDirectory, _logProvider); // when we copy that file using a different storeId StoreCopyFinishedResponse storeCopyFinishedResponse = simpleCatchupClient.RequestIndividualFile(expectedExistingFile, _wrongStoreId); simpleCatchupClient.Close(); // then the response from the server should be an error message that describes a store ID mismatch assertEquals(StoreCopyFinishedResponse.Status.EStoreIdMismatch, storeCopyFinishedResponse.Status()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private boolean successfulRequest(StoreCopyFinishedResponse response, org.neo4j.causalclustering.messaging.CatchUpRequest request) throws StoreCopyFailedException private bool SuccessfulRequest(StoreCopyFinishedResponse response, CatchUpRequest request) { StoreCopyFinishedResponse.Status responseStatus = response.Status(); if (responseStatus == StoreCopyFinishedResponse.Status.Success) { _log.info(format("Request was successful '%s'", request)); return(true); } else if (StoreCopyFinishedResponse.Status.ETooFarBehind == responseStatus || StoreCopyFinishedResponse.Status.EUnknown == responseStatus || StoreCopyFinishedResponse.Status.EStoreIdMismatch == responseStatus) { _log.warn(format("Request failed '%s'. With response: %s", request, response.Status())); return(false); } else { throw new StoreCopyFailedException(format("Request responded with an unknown response type: %s. '%s'", responseStatus, request)); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldEncodeAndDecodePullRequestMessage() public virtual void ShouldEncodeAndDecodePullRequestMessage() { // given EmbeddedChannel channel = new EmbeddedChannel(new StoreCopyFinishedResponseEncoder(), new StoreCopyFinishedResponseDecoder()); StoreCopyFinishedResponse sent = new StoreCopyFinishedResponse(Status.E_STORE_ID_MISMATCH); // when channel.writeOutbound(sent); object message = channel.readOutbound(); channel.writeInbound(message); // then StoreCopyFinishedResponse received = channel.readInbound(); assertNotSame(sent, received); assertEquals(sent, received); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldResetProtocolAndGiveErrorOnUncheckedException() public virtual void ShouldResetProtocolAndGiveErrorOnUncheckedException() { when(_neoStoreDataSource.StoreId).thenThrow(new System.InvalidOperationException()); try { _embeddedChannel.writeInbound(new GetStoreFileRequest(_storeIdMatching, new File("some-file"), 1)); fail(); } catch (System.InvalidOperationException) { } assertEquals(ResponseMessageType.STORE_COPY_FINISHED, _embeddedChannel.readOutbound()); StoreCopyFinishedResponse expectedResponse = new StoreCopyFinishedResponse(StoreCopyFinishedResponse.Status.EUnknown); assertEquals(expectedResponse, _embeddedChannel.readOutbound()); assertTrue(_catchupServerProtocol.isExpecting(CatchupServerProtocol.State.MESSAGE_TYPE)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shoulResetProtocolAndGiveErrorIfFilesThrowException() public virtual void ShoulResetProtocolAndGiveErrorIfFilesThrowException() { EmbeddedChannel alternativeChannel = new EmbeddedChannel(new EvilStoreCopyRequestHandler(this, _catchupServerProtocol, () => _neoStoreDataSource, new StoreFileStreamingProtocol(), _fileSystemAbstraction, NullLogProvider.Instance)); try { alternativeChannel.writeInbound(new GetStoreFileRequest(_storeIdMatching, new File("some-file"), 1)); fail(); } catch (System.InvalidOperationException) { // do nothing } assertEquals(ResponseMessageType.STORE_COPY_FINISHED, alternativeChannel.readOutbound()); StoreCopyFinishedResponse expectedResponse = new StoreCopyFinishedResponse(StoreCopyFinishedResponse.Status.EUnknown); assertEquals(expectedResponse, alternativeChannel.readOutbound()); assertTrue(_catchupServerProtocol.isExpecting(CatchupServerProtocol.State.MESSAGE_TYPE)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void individualFileCopyWorks() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void IndividualFileCopyWorks() { // given a file exists on the server AddData(_graphDb); File existingFile = new File(_temporaryDirectory, EXISTING_FILE_NAME); // and SimpleCatchupClient simpleCatchupClient = new SimpleCatchupClient(_graphDb, _fsa, _catchupClient, _catchupServer, _temporaryDirectory, _logProvider); // when we copy that file _pageCache.flushAndForce(); StoreCopyFinishedResponse storeCopyFinishedResponse = simpleCatchupClient.RequestIndividualFile(existingFile); simpleCatchupClient.Close(); // then the response is successful assertEquals(StoreCopyFinishedResponse.Status.Success, storeCopyFinishedResponse.Status()); // then the contents matches FileContentEquals(ClientFileToDatabaseFile(existingFile), existingFile); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void individualIndexSnapshotCopyWorks() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void IndividualIndexSnapshotCopyWorks() { // given NeoStoreDataSource neoStoreDataSource = GetNeoStoreDataSource(_graphDb); //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: IList <File> expectingFiles = neoStoreDataSource.NeoStoreFileListing.builder().excludeAll().includeSchemaIndexStoreFiles().build().Select(StoreFileMetadata::file).ToList(); SimpleCatchupClient simpleCatchupClient = new SimpleCatchupClient(_graphDb, _fsa, _catchupClient, _catchupServer, _temporaryDirectory, _logProvider); // and LongIterator indexIds = GetExpectedIndexIds(neoStoreDataSource).longIterator(); // when while (indexIds.hasNext()) { long indexId = indexIds.next(); StoreCopyFinishedResponse response = simpleCatchupClient.RequestIndexSnapshot(indexId); simpleCatchupClient.Close(); assertEquals(StoreCopyFinishedResponse.Status.Success, response.Status()); } // then FileContentEquals(expectingFiles); }