Esempio n. 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();
                }
            }
        }
Esempio n. 2
0
//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);
            }
        }