//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldListExpectedFilesCorrectly() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldListExpectedFilesCorrectly() { // given (setup) required runtime subject dependencies NeoStoreDataSource neoStoreDataSource = GetNeoStoreDataSource(_graphDb); SimpleCatchupClient simpleCatchupClient = new SimpleCatchupClient(_graphDb, _fsa, _catchupClient, _catchupServer, _temporaryDirectory, _logProvider); // when PrepareStoreCopyResponse prepareStoreCopyResponse = simpleCatchupClient.RequestListOfFilesFromServer(); simpleCatchupClient.Close(); // then ListOfDownloadedFilesMatchesServer(neoStoreDataSource, prepareStoreCopyResponse.Files); // and downloaded files are identical to source IList <File> expectedCountStoreFiles = ListServerExpectedNonReplayableFiles(neoStoreDataSource); foreach (File storeFileSnapshot in expectedCountStoreFiles) { FileContentEquals(DatabaseFileToClientFile(storeFileSnapshot), storeFileSnapshot); } // and AssertTransactionIdMatches(prepareStoreCopyResponse.LastTransactionId()); //and assertTrue("Expected an empty set of ids. Found size " + prepareStoreCopyResponse.IndexIds.size(), prepareStoreCopyResponse.IndexIds.Empty); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: protected void channelRead0(io.netty.channel.ChannelHandlerContext channelHandlerContext, PrepareStoreCopyRequest prepareStoreCopyRequest) throws java.io.IOException protected internal override void ChannelRead0(ChannelHandlerContext channelHandlerContext, PrepareStoreCopyRequest prepareStoreCopyRequest) { CloseablesListener closeablesListener = new CloseablesListener(); PrepareStoreCopyResponse response = PrepareStoreCopyResponse.Error(PrepareStoreCopyResponse.Status.EListingStore); try { NeoStoreDataSource neoStoreDataSource = _dataSourceSupplier.get(); if (!hasSameStoreId(prepareStoreCopyRequest.StoreId, neoStoreDataSource)) { channelHandlerContext.write(ResponseMessageType.PREPARE_STORE_COPY_RESPONSE); response = PrepareStoreCopyResponse.Error(PrepareStoreCopyResponse.Status.EStoreIdMismatch); } else { CheckPointer checkPointer = neoStoreDataSource.DependencyResolver.resolveDependency(typeof(CheckPointer)); closeablesListener.Add(TryCheckpointAndAcquireMutex(checkPointer)); PrepareStoreCopyFiles prepareStoreCopyFiles = closeablesListener.Add(_prepareStoreCopyFilesProvider.prepareStoreCopyFiles(neoStoreDataSource)); StoreResource[] nonReplayable = prepareStoreCopyFiles.AtomicFilesSnapshot; foreach (StoreResource storeResource in nonReplayable) { _streamingProtocol.stream(channelHandlerContext, storeResource); } channelHandlerContext.write(ResponseMessageType.PREPARE_STORE_COPY_RESPONSE); response = CreateSuccessfulResponse(checkPointer, prepareStoreCopyFiles); } } finally { channelHandlerContext.writeAndFlush(response).addListener(closeablesListener); _protocol.expect(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 descriptorsGetTransmitted() public virtual void DescriptorsGetTransmitted() { // given File[] files = new File[] { new File("File a.txt"), new File("file-b"), new File("aoifnoasndfosidfoisndfoisnodainfsonidfaosiidfna"), new File("") }; LongSet indexIds = LongSets.immutable.of(13); // when PrepareStoreCopyResponse prepareStoreCopyResponse = PrepareStoreCopyResponse.Success(files, indexIds, 1L); SendToChannel(prepareStoreCopyResponse, _embeddedChannel); // then it can be deserialised PrepareStoreCopyResponse readPrepareStoreCopyResponse = _embeddedChannel.readInbound(); assertEquals(prepareStoreCopyResponse.Files.Length, readPrepareStoreCopyResponse.Files.Length); foreach (File file in files) { assertEquals(1, Stream.of(readPrepareStoreCopyResponse.Files).map(File.getName).filter(f => f.Equals(file.Name)).count()); } assertEquals(prepareStoreCopyResponse.IndexIds, readPrepareStoreCopyResponse.IndexIds); }
private static void SendToChannel(PrepareStoreCopyResponse prepareStoreCopyResponse, EmbeddedChannel embeddedChannel) { embeddedChannel.writeOutbound(prepareStoreCopyResponse); ByteBuf @object = embeddedChannel.readOutbound(); embeddedChannel.writeInbound(@object); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private PrepareStoreCopyResponse createSuccessfulResponse(org.neo4j.kernel.impl.transaction.log.checkpoint.CheckPointer checkPointer, PrepareStoreCopyFiles prepareStoreCopyFiles) throws java.io.IOException private PrepareStoreCopyResponse CreateSuccessfulResponse(CheckPointer checkPointer, PrepareStoreCopyFiles prepareStoreCopyFiles) { LongSet indexIds = prepareStoreCopyFiles.NonAtomicIndexIds; File[] files = prepareStoreCopyFiles.ListReplayableFiles(); long lastCommittedTxId = checkPointer.LastCheckPointedTransactionId(); return(PrepareStoreCopyResponse.Success(files, indexIds, lastCommittedTxId)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private PrepareStoreCopyResponse prepareStoreCopy(org.neo4j.helpers.AdvertisedSocketAddress from, org.neo4j.causalclustering.identity.StoreId expectedStoreId, StoreFileStreamProvider storeFileStream) throws org.neo4j.causalclustering.catchup.CatchUpClientException, StoreCopyFailedException private PrepareStoreCopyResponse PrepareStoreCopy(AdvertisedSocketAddress from, StoreId expectedStoreId, StoreFileStreamProvider storeFileStream) { _log.info("Requesting store listing from: " + from); PrepareStoreCopyResponse prepareStoreCopyResponse = _catchUpClient.makeBlockingRequest(from, new PrepareStoreCopyRequest(expectedStoreId), prepareStoreCopyAdaptor(storeFileStream, _log)); if (prepareStoreCopyResponse.Status() != PrepareStoreCopyResponse.Status.Success) { throw new StoreCopyFailedException("Preparing store failed due to: " + prepareStoreCopyResponse.Status()); } return(prepareStoreCopyResponse); }
protected internal override void channelRead0(ChannelHandlerContext channelHandlerContext, PrepareStoreCopyRequest prepareStoreCopyRequest) { channelHandlerContext.writeAndFlush(ResponseMessageType.PREPARE_STORE_COPY_RESPONSE); //JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter: IList <File> list = _outerInstance.filesystem.Select(FakeFile::getFile).ToList(); File[] files = new File[list.Count]; files = list.toArray(files); long transactionId = 123L; LongSet indexIds = LongSets.immutable.of(13); channelHandlerContext.writeAndFlush(PrepareStoreCopyResponse.Success(files, indexIds, transactionId)); _catchupServerProtocol.expect(CatchupServerProtocol.State.MESSAGE_TYPE); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: long copyStoreFiles(org.neo4j.causalclustering.catchup.CatchupAddressProvider catchupAddressProvider, org.neo4j.causalclustering.identity.StoreId expectedStoreId, StoreFileStreamProvider storeFileStreamProvider, System.Func<TerminationCondition> requestWiseTerminationCondition, java.io.File destDir) throws StoreCopyFailedException internal virtual long CopyStoreFiles(CatchupAddressProvider catchupAddressProvider, StoreId expectedStoreId, StoreFileStreamProvider storeFileStreamProvider, System.Func <TerminationCondition> requestWiseTerminationCondition, File destDir) { try { PrepareStoreCopyResponse prepareStoreCopyResponse = PrepareStoreCopy(catchupAddressProvider.Primary(), expectedStoreId, storeFileStreamProvider); CopyFilesIndividually(prepareStoreCopyResponse, expectedStoreId, catchupAddressProvider, storeFileStreamProvider, requestWiseTerminationCondition, destDir); CopyIndexSnapshotIndividually(prepareStoreCopyResponse, expectedStoreId, catchupAddressProvider, storeFileStreamProvider, requestWiseTerminationCondition); return(prepareStoreCopyResponse.LastTransactionId()); } catch (Exception e) when(e is CatchupAddressResolutionException || e is CatchUpClientException) { throw new StoreCopyFailedException(e); } }
public override bool Equals(object o) { if (this == o) { return(true); } if (o == null || this.GetType() != o.GetType()) { return(false); } PrepareStoreCopyResponse that = ( PrepareStoreCopyResponse )o; return(Arrays.Equals(_files, that._files) && _indexIds.Equals(that._indexIds) && Objects.Equals(_transactionId, that._transactionId) && _status == that._status); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void copyFilesIndividually(PrepareStoreCopyResponse prepareStoreCopyResponse, org.neo4j.causalclustering.identity.StoreId expectedStoreId, org.neo4j.causalclustering.catchup.CatchupAddressProvider addressProvider, StoreFileStreamProvider storeFileStream, System.Func<TerminationCondition> terminationConditions, java.io.File destDir) throws StoreCopyFailedException private void CopyFilesIndividually(PrepareStoreCopyResponse prepareStoreCopyResponse, StoreId expectedStoreId, CatchupAddressProvider addressProvider, StoreFileStreamProvider storeFileStream, System.Func <TerminationCondition> terminationConditions, File destDir) { StoreCopyClientMonitor storeCopyClientMonitor = _monitors.newMonitor(typeof(StoreCopyClientMonitor)); storeCopyClientMonitor.StartReceivingStoreFiles(); long lastTransactionId = prepareStoreCopyResponse.LastTransactionId(); foreach (File file in prepareStoreCopyResponse.Files) { storeCopyClientMonitor.StartReceivingStoreFile(Paths.get(destDir.ToString(), file.Name).ToString()); PersistentCallToSecondary(new GetStoreFileRequest(expectedStoreId, file, lastTransactionId), filesCopyAdaptor(storeFileStream, _log), addressProvider, terminationConditions()); storeCopyClientMonitor.FinishReceivingStoreFile(Paths.get(destDir.ToString(), file.Name).ToString()); } storeCopyClientMonitor.FinishReceivingStoreFiles(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void transactionIdGetsTransmitted() public virtual void TransactionIdGetsTransmitted() { // given long transactionId = long.MaxValue; // when a transaction id is serialised PrepareStoreCopyResponse prepareStoreCopyResponse = PrepareStoreCopyResponse.Success(new File[0], LongSets.immutable.empty(), transactionId); SendToChannel(prepareStoreCopyResponse, _embeddedChannel); // then it can be deserialised PrepareStoreCopyResponse readPrepareStoreCopyResponse = _embeddedChannel.readInbound(); assertEquals(prepareStoreCopyResponse.LastTransactionId(), readPrepareStoreCopyResponse.LastTransactionId()); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void copyIndexSnapshotIndividually(PrepareStoreCopyResponse prepareStoreCopyResponse, org.neo4j.causalclustering.identity.StoreId expectedStoreId, org.neo4j.causalclustering.catchup.CatchupAddressProvider addressProvider, StoreFileStreamProvider storeFileStream, System.Func<TerminationCondition> terminationConditions) throws StoreCopyFailedException private void CopyIndexSnapshotIndividually(PrepareStoreCopyResponse prepareStoreCopyResponse, StoreId expectedStoreId, CatchupAddressProvider addressProvider, StoreFileStreamProvider storeFileStream, System.Func <TerminationCondition> terminationConditions) { StoreCopyClientMonitor storeCopyClientMonitor = _monitors.newMonitor(typeof(StoreCopyClientMonitor)); long lastTransactionId = prepareStoreCopyResponse.LastTransactionId(); LongIterator indexIds = prepareStoreCopyResponse.IndexIds.longIterator(); storeCopyClientMonitor.StartReceivingIndexSnapshots(); while (indexIds.hasNext()) { long indexId = indexIds.next(); storeCopyClientMonitor.StartReceivingIndexSnapshot(indexId); PersistentCallToSecondary(new GetIndexFilesRequest(expectedStoreId, indexId, lastTransactionId), filesCopyAdaptor(storeFileStream, _log), addressProvider, terminationConditions()); storeCopyClientMonitor.FinishReceivingIndexSnapshot(indexId); } storeCopyClientMonitor.FinishReceivingIndexSnapshots(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGiveErrorResponseIfStoreMismatch() public virtual void ShouldGiveErrorResponseIfStoreMismatch() { // given store id doesn't match // when PrepareStoreCopyRequest is written to channel _embeddedChannel.writeInbound(new PrepareStoreCopyRequest(_storeIdMismatching)); // then there is a store id mismatch message assertEquals(ResponseMessageType.PREPARE_STORE_COPY_RESPONSE, _embeddedChannel.readOutbound()); PrepareStoreCopyResponse response = PrepareStoreCopyResponse.Error(PrepareStoreCopyResponse.Status.EStoreIdMismatch); assertEquals(response, _embeddedChannel.readOutbound()); // and the expected message type is reset back to message type 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 shouldCommunicateErrorIfStoreIdDoesNotMatchRequest() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldCommunicateErrorIfStoreIdDoesNotMatchRequest() { // given (setup) required runtime subject dependencies AddData(_graphDb); SimpleCatchupClient simpleCatchupClient = new SimpleCatchupClient(_graphDb, _fsa, _catchupClient, _catchupServer, _temporaryDirectory, _logProvider); // when the list of files are requested from the server with the wrong storeId PrepareStoreCopyResponse prepareStoreCopyResponse = simpleCatchupClient.RequestListOfFilesFromServer(_wrongStoreId); simpleCatchupClient.Close(); // then the response is not a list of files but an error assertEquals(PrepareStoreCopyResponse.Status.EStoreIdMismatch, prepareStoreCopyResponse.Status()); // and the list of files is empty because the request should have failed File[] remoteFiles = prepareStoreCopyResponse.Files; assertArrayEquals(new File[] {}, remoteFiles); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldGetSuccessfulResponseFromPrepareStoreCopyRequest() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldGetSuccessfulResponseFromPrepareStoreCopyRequest() { // given storeId matches LongSet indexIds = LongSets.immutable.of(1); File[] files = new File[] { new File("file") }; long lastCheckpoint = 1; ConfigureProvidedStoreCopyFiles(new StoreResource[0], files, indexIds, lastCheckpoint); // when store listing is requested _embeddedChannel.writeInbound(_channelHandlerContext, new PrepareStoreCopyRequest(_storeIdMatching)); // and the contents of the store listing response is sent assertEquals(ResponseMessageType.PREPARE_STORE_COPY_RESPONSE, _embeddedChannel.readOutbound()); PrepareStoreCopyResponse response = PrepareStoreCopyResponse.Success(files, indexIds, lastCheckpoint); assertEquals(response, _embeddedChannel.readOutbound()); // and the protocol is reset to expect any message type after listing has been transmitted assertTrue(_catchupServerProtocol.isExpecting(CatchupServerProtocol.State.MESSAGE_TYPE)); }
protected internal override void channelRead0(ChannelHandlerContext ctx, PrepareStoreCopyRequest msg) { ctx.write(ResponseMessageType.PREPARE_STORE_COPY_RESPONSE); ctx.writeAndFlush(PrepareStoreCopyResponse.Success(new File[] { new File(_outerInstance.fileName) }, LongSets.immutable.empty(), 1)); _catchupServerProtocol.expect(CatchupServerProtocol.State.MESSAGE_TYPE); }