示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void perform(io.netty.channel.ChannelHandlerContext ctx) throws java.io.IOException
        internal virtual void Perform(ChannelHandlerContext ctx)
        {
            CheckPointer checkPointer   = _checkPointerSupplier.get();
            Resource     checkPointLock = _mutex.storeCopy(() => checkPointer.TryCheckPoint(new SimpleTriggerInfo("Store copy")));

            Future <Void> completion = null;

            try
            {
                using (RawCursor <StoreResource, IOException> resources = _resourceStreamFactory.create())
                {
                    while (resources.Next())
                    {
                        StoreResource resource = resources.get();
                        _protocol.stream(ctx, resource);
                    }
                    completion = _protocol.end(ctx, SUCCESS);
                }
            }
            finally
            {
                if (completion != null)
                {
                    completion.addListener(f => checkPointLock.close());
                }
                else
                {
                    checkPointLock.Close();
                }
            }
        }
示例#2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnExpectedListOfFileNamesForEachType() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnExpectedListOfFileNamesForEachType()
        {
            // given
            StoreFileMetadata[] expectedFiles = new StoreFileMetadata[]
            {
                new StoreFileMetadata(_databaseLayout.file("a"), 1),
                new StoreFileMetadata(_databaseLayout.file("b"), 2)
            };
            ExpectedFiles = expectedFiles;

            //when
            File[]          files = _prepareStoreCopyFiles.listReplayableFiles();
            StoreResource[] atomicFilesSnapshot = _prepareStoreCopyFiles.AtomicFilesSnapshot;

            //then
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            File[] expectedFilesConverted = java.util.expectedFiles.Select(StoreFileMetadata::file).ToArray(File[] ::new);
//JAVA TO C# CONVERTER TODO TASK: Method reference constructor syntax is not converted by Java to C# Converter:
            StoreResource[] exeptedAtomicFilesConverted = java.util.expectedFiles.Select(f => new StoreResource(f.file(), GetRelativePath(f), f.recordSize(), _fileSystemAbstraction)).ToArray(StoreResource[] ::new);
            assertArrayEquals(expectedFilesConverted, files);
            assertEquals(exeptedAtomicFilesConverted.Length, atomicFilesSnapshot.Length);
            for (int i = 0; i < exeptedAtomicFilesConverted.Length; i++)
            {
                StoreResource expected      = exeptedAtomicFilesConverted[i];
                StoreResource storeResource = atomicFilesSnapshot[i];
                assertEquals(expected.Path(), storeResource.Path());
                assertEquals(expected.RecordSize(), storeResource.RecordSize());
            }
        }
示例#3
0
        private void HandleFileExists(ChannelHandlerContext channelHandlerContext, File file)
        {
            _log.info("FakeServer File %s does exist", file);
            channelHandlerContext.writeAndFlush(ResponseMessageType.FILE);
            channelHandlerContext.writeAndFlush(new FileHeader(file.Name));
            StoreResource storeResource = StoreResourceFromEntry(file);

            channelHandlerContext.writeAndFlush(new FileSender(storeResource));
            (new StoreFileStreamingProtocol()).End(channelHandlerContext, StoreCopyFinishedResponse.Status.Success);
        }
示例#4
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || this.GetType() != o.GetType())
            {
                return(false);
            }
            StoreResource that = ( StoreResource )o;

            return(_recordSize == that._recordSize && Objects.Equals(_file, that._file) && Objects.Equals(_path, that._path));
        }
示例#5
0
 protected internal override void channelRead0(ChannelHandlerContext channelHandlerContext, GetIndexFilesRequest snapshotRequest)
 {
     _outerInstance.log.info("Received request for index %s", snapshotRequest.IndexId());
     try
     {
         foreach (FakeFile indexFile in _outerInstance.indexFiles)
         {
             _outerInstance.log.info("FakeServer File %s does exist", indexFile.File);
             channelHandlerContext.writeAndFlush(ResponseMessageType.FILE);
             channelHandlerContext.writeAndFlush(new FileHeader(indexFile.File.Name));
             StoreResource storeResource = outerInstance.storeResourceFromEntry(indexFile.File);
             channelHandlerContext.writeAndFlush(new FileSender(storeResource));
         }
         (new StoreFileStreamingProtocol()).End(channelHandlerContext, StoreCopyFinishedResponse.Status.Success);
     }
     finally
     {
         _catchupServerProtocol.expect(CatchupServerProtocol.State.MESSAGE_TYPE);
     }
 }
示例#6
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, T request) throws Exception
        protected internal override void ChannelRead0(ChannelHandlerContext ctx, T request)
        {
            _log.debug("Handling request %s", request);
            StoreCopyFinishedResponse.Status responseStatus = StoreCopyFinishedResponse.Status.EUnknown;
            try
            {
                NeoStoreDataSource neoStoreDataSource = _dataSource.get();
                if (!hasSameStoreId(request.expectedStoreId(), neoStoreDataSource))
                {
                    responseStatus = StoreCopyFinishedResponse.Status.EStoreIdMismatch;
                }
                else if (!isTransactionWithinReach(request.requiredTransactionId(), _checkPointerService))
                {
                    responseStatus = StoreCopyFinishedResponse.Status.ETooFarBehind;
                    _checkPointerService.tryAsyncCheckpoint(e => _log.error("Failed to do a checkpoint that was invoked after a too far behind error on store copy request", e));
                }
                else
                {
                    File databaseDirectory = neoStoreDataSource.DatabaseLayout.databaseDirectory();
                    using (ResourceIterator <StoreFileMetadata> resourceIterator = Files(request, neoStoreDataSource))
                    {
                        while (resourceIterator.MoveNext())
                        {
                            StoreFileMetadata storeFileMetadata = resourceIterator.Current;
                            StoreResource     storeResource     = new StoreResource(storeFileMetadata.File(), relativePath(databaseDirectory, storeFileMetadata.File()), storeFileMetadata.RecordSize(), _fs);
                            _storeFileStreamingProtocol.stream(ctx, storeResource);
                        }
                    }
                    responseStatus = StoreCopyFinishedResponse.Status.Success;
                }
            }
            finally
            {
                _storeFileStreamingProtocol.end(ctx, responseStatus);
                _protocol.expect(CatchupServerProtocol.State.MESSAGE_TYPE);
            }
        }
示例#7
0
 /// <summary>
 /// This sends operations on the outgoing pipeline or the file, including
 /// chunking <seealso cref="org.neo4j.causalclustering.catchup.storecopy.FileSender"/> handlers.
 /// <para>
 /// Note that we do not block here.
 /// </para>
 /// </summary>
 internal virtual void Stream(ChannelHandlerContext ctx, StoreResource resource)
 {
     ctx.write(ResponseMessageType.FILE);
     ctx.write(new FileHeader(resource.Path(), resource.RecordSize()));
     ctx.write(new FileSender(resource));
 }
示例#8
0
 internal FileSender(StoreResource resource)
 {
     this._resource   = resource;
     this._byteBuffer = ByteBuffer.allocateDirect(MAX_SIZE);
 }