Ejemplo n.º 1
0
        public override Fallible <BackupStageOutcome> PerformFullBackup(DatabaseLayout targetDatabaseLayout, Config config, OptionalHostnamePort userProvidedAddress)
        {
            AdvertisedSocketAddress fromAddress = _addressResolver.resolveCorrectCCAddress(config, userProvidedAddress);

            _log.info("Resolved address for catchup protocol is " + fromAddress);
            StoreId storeId;

            try
            {
                storeId = _backupDelegator.fetchStoreId(fromAddress);
                _log.info("Remote store id is " + storeId);
            }
            catch (StoreIdDownloadFailedException e)
            {
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.WrongProtocol, e));
            }

            Optional <StoreId> expectedStoreId = ReadLocalStoreId(targetDatabaseLayout);

            if (expectedStoreId.Present)
            {
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Failure, new StoreIdDownloadFailedException(format("Cannot perform a full backup onto preexisting backup. Remote store id was %s but local is %s", storeId, expectedStoreId))));
            }

            try
            {
                _backupDelegator.copy(fromAddress, storeId, targetDatabaseLayout);
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Success, null));
            }
            catch (StoreCopyFailedException e)
            {
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Failure, e));
            }
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSetLastPulledTransactionId() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldSetLastPulledTransactionId()
        {
            // given
            long    lastFlushedTxId           = 12;
            StoreId wantedStoreId             = new StoreId(1, 2, 3, 4);
            AdvertisedSocketAddress localhost = new AdvertisedSocketAddress("127.0.0.1", 1234);
            CatchupAddressProvider  catchupAddressProvider = CatchupAddressProvider.fromSingleAddress(localhost);

            StoreCopyClient storeCopyClient = mock(typeof(StoreCopyClient));

            when(storeCopyClient.CopyStoreFiles(eq(catchupAddressProvider), eq(wantedStoreId), any(typeof(StoreFileStreamProvider)), any(), any())).thenReturn(lastFlushedTxId);

            TxPullClient txPullClient = mock(typeof(TxPullClient));

            when(txPullClient.PullTransactions(eq(localhost), eq(wantedStoreId), anyLong(), any())).thenReturn(new TxPullRequestResult(SUCCESS_END_OF_STREAM, 13));

            TransactionLogCatchUpWriter writer = mock(typeof(TransactionLogCatchUpWriter));

            RemoteStore remoteStore = new RemoteStore(NullLogProvider.Instance, mock(typeof(FileSystemAbstraction)), null, storeCopyClient, txPullClient, Factory(writer), Config.defaults(), new Monitors());

            // when
            remoteStore.Copy(catchupAddressProvider, wantedStoreId, DatabaseLayout.of(new File("destination")), true);

            // then
            long previousTxId = lastFlushedTxId - 1;               // the interface is defined as asking for the one preceding

            verify(txPullClient).pullTransactions(eq(localhost), eq(wantedStoreId), eq(previousTxId), any());
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldRemoveChannelViaCallback()
        public virtual void ShouldRemoveChannelViaCallback()
        {
            // given
            AdvertisedSocketAddress address  = new AdvertisedSocketAddress("localhost", 1984);
            ReconnectingChannels    channels = new ReconnectingChannels();

            channels.PutIfAbsent(address, mock(typeof(ReconnectingChannel)));

            IdleChannelReaperHandler reaper = new IdleChannelReaperHandler(channels);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.net.InetSocketAddress socketAddress = address.socketAddress();
            InetSocketAddress socketAddress = address.SocketAddressConflict();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final io.netty.channel.Channel channel = mock(io.netty.channel.Channel.class);
            Channel channel = mock(typeof(Channel));

            when(channel.remoteAddress()).thenReturn(socketAddress);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final io.netty.channel.ChannelHandlerContext context = mock(io.netty.channel.ChannelHandlerContext.class);
            ChannelHandlerContext context = mock(typeof(ChannelHandlerContext));

            when(context.channel()).thenReturn(channel);

            // when
            reaper.UserEventTriggered(context, IdleStateEvent.ALL_IDLE_STATE_EVENT);

            // then
            assertNull(channels.Get(address));
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void noPortResolvesToDefault_cc()
        public virtual void NoPortResolvesToDefaultCc()
        {
            Config config = Config.builder().withSetting(OnlineBackupSettings.online_backup_server, "any:1234").build();
            AdvertisedSocketAddress resolved = Subject.resolveCorrectCCAddress(config, new OptionalHostnamePort("localhost", null, null));

            // then
            assertEquals(1234, resolved.Port);
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: org.neo4j.causalclustering.catchup.CatchupResult tryCatchingUp(org.neo4j.helpers.AdvertisedSocketAddress fromAddress, org.neo4j.causalclustering.identity.StoreId expectedStoreId, org.neo4j.io.layout.DatabaseLayout databaseLayout) throws org.neo4j.causalclustering.catchup.storecopy.StoreCopyFailedException
        internal virtual CatchupResult TryCatchingUp(AdvertisedSocketAddress fromAddress, StoreId expectedStoreId, DatabaseLayout databaseLayout)
        {
            try
            {
                return(_remoteStore.tryCatchingUp(fromAddress, expectedStoreId, databaseLayout, true, true));
            }
            catch (IOException e)
            {
                throw new StoreCopyFailedException(e);
            }
        }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void tryCatchingUpDelegatesToRemoteStore() throws org.neo4j.causalclustering.catchup.storecopy.StoreCopyFailedException, java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TryCatchingUpDelegatesToRemoteStore()
        {
            // given
            AdvertisedSocketAddress fromAddress = new AdvertisedSocketAddress("neo4j.com", 5432);
            StoreId        expectedStoreId      = new StoreId(7, 2, 5, 98);
            DatabaseLayout databaseLayout       = DatabaseLayout.of(new File("."));

            // when
            Subject.tryCatchingUp(fromAddress, expectedStoreId, databaseLayout);

            // then
            verify(_remoteStore).tryCatchingUp(fromAddress, expectedStoreId, databaseLayout, true, true);
        }
Ejemplo n.º 7
0
        public override void UserEventTriggered(ChannelHandlerContext ctx, object evt)
        {
            if (evt is IdleStateEvent && evt == IdleStateEvent.ALL_IDLE_STATE_EVENT)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.net.InetSocketAddress socketAddress = (java.net.InetSocketAddress) ctx.channel().remoteAddress();
                InetSocketAddress socketAddress = ( InetSocketAddress )ctx.channel().remoteAddress();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.helpers.AdvertisedSocketAddress address = new org.neo4j.helpers.AdvertisedSocketAddress(socketAddress.getHostName(), socketAddress.getPort());
                AdvertisedSocketAddress address = new AdvertisedSocketAddress(socketAddress.HostName, socketAddress.Port);

                _channels.remove(address);
            }
        }
Ejemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void fetchStoreIdDelegatesToStoreCopyClient() throws org.neo4j.causalclustering.catchup.storecopy.StoreIdDownloadFailedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FetchStoreIdDelegatesToStoreCopyClient()
        {
            // given
            AdvertisedSocketAddress fromAddress = new AdvertisedSocketAddress("neo4.com", 935);

            // and
            StoreId expectedStoreId = new StoreId(6, 2, 9, 3);

            when(_storeCopyClient.fetchStoreId(fromAddress)).thenReturn(expectedStoreId);

            // when
            StoreId storeId = Subject.fetchStoreId(fromAddress);

            // then
            assertEquals(expectedStoreId, storeId);
        }
Ejemplo n.º 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void selectionPrioritiesAreKept() throws CatchupAddressResolutionException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SelectionPrioritiesAreKept()
        {
            // given various strategies with different priorities
            UpstreamDatabaseStrategySelector upstreamDatabaseStrategySelector = new UpstreamDatabaseStrategySelector(new CountedSelectionStrategy(this, _defaultMember, 5), Arrays.asList(new CountedSelectionStrategy(this, _firstMember, 1), new CountedSelectionStrategy(this, _secondMember, 1)), NullLogProvider.Instance);

            // and
            UpstreamStrategyAddressSupplier upstreamStrategyAddressSupplier = new UpstreamStrategyAddressSupplier(upstreamDatabaseStrategySelector, _topologyService);

            // when
            AdvertisedSocketAddress firstResult  = upstreamStrategyAddressSupplier.Get();
            AdvertisedSocketAddress secondResult = upstreamStrategyAddressSupplier.Get();
            AdvertisedSocketAddress thirdResult  = upstreamStrategyAddressSupplier.Get();

            // then
            assertEquals(_firstAddress, firstResult);
            assertEquals(_secondAddress, secondResult);
            assertEquals(_defaultAddress, thirdResult);
        }
Ejemplo n.º 10
0
        private Fallible <BackupStageOutcome> Catchup(AdvertisedSocketAddress fromAddress, StoreId storeId, DatabaseLayout databaseLayout)
        {
            CatchupResult catchupResult;

            try
            {
                catchupResult = _backupDelegator.tryCatchingUp(fromAddress, storeId, databaseLayout);
            }
            catch (StoreCopyFailedException e)
            {
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Failure, e));
            }
            if (catchupResult == CatchupResult.SUCCESS_END_OF_STREAM)
            {
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Success, null));
            }
            return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Failure, new StoreCopyFailedException("End state of catchup was not a successful end of stream")));
        }
Ejemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCopyStoreFilesAndPullTransactions() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCopyStoreFilesAndPullTransactions()
        {
            // given
            StoreId         storeId         = new StoreId(1, 2, 3, 4);
            StoreCopyClient storeCopyClient = mock(typeof(StoreCopyClient));
            TxPullClient    txPullClient    = mock(typeof(TxPullClient));

            when(txPullClient.PullTransactions(any(), any(), anyLong(), any())).thenReturn(new TxPullRequestResult(SUCCESS_END_OF_STREAM, 13));
            TransactionLogCatchUpWriter writer = mock(typeof(TransactionLogCatchUpWriter));

            RemoteStore remoteStore = new RemoteStore(NullLogProvider.Instance, mock(typeof(FileSystemAbstraction)), null, storeCopyClient, txPullClient, Factory(writer), Config.defaults(), new Monitors());

            // when
            AdvertisedSocketAddress localhost = new AdvertisedSocketAddress("127.0.0.1", 1234);
            CatchupAddressProvider  catchupAddressProvider = CatchupAddressProvider.fromSingleAddress(localhost);

            remoteStore.Copy(catchupAddressProvider, storeId, DatabaseLayout.of(new File("destination")), true);

            // then
            verify(storeCopyClient).copyStoreFiles(eq(catchupAddressProvider), eq(storeId), any(typeof(StoreFileStreamProvider)), any(), any());
            verify(txPullClient).pullTransactions(eq(localhost), eq(storeId), anyLong(), any());
        }
Ejemplo n.º 12
0
        public override Fallible <BackupStageOutcome> PerformIncrementalBackup(DatabaseLayout databaseLayout, Config config, OptionalHostnamePort userProvidedAddress)
        {
            AdvertisedSocketAddress fromAddress = _addressResolver.resolveCorrectCCAddress(config, userProvidedAddress);

            _log.info("Resolved address for catchup protocol is " + fromAddress);
            StoreId storeId;

            try
            {
                storeId = _backupDelegator.fetchStoreId(fromAddress);
                _log.info("Remote store id is " + storeId);
            }
            catch (StoreIdDownloadFailedException e)
            {
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.WrongProtocol, e));
            }
            Optional <StoreId> expectedStoreId = ReadLocalStoreId(databaseLayout);

            if (!expectedStoreId.Present || !expectedStoreId.get().Equals(storeId))
            {
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Failure, new StoreIdDownloadFailedException(format("Remote store id was %s but local is %s", storeId, expectedStoreId))));
            }
            return(Catchup(fromAddress, storeId, databaseLayout));
        }
Ejemplo n.º 13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: void copy(org.neo4j.helpers.AdvertisedSocketAddress fromAddress, org.neo4j.causalclustering.identity.StoreId expectedStoreId, org.neo4j.io.layout.DatabaseLayout databaseLayout) throws org.neo4j.causalclustering.catchup.storecopy.StoreCopyFailedException
        internal virtual void Copy(AdvertisedSocketAddress fromAddress, StoreId expectedStoreId, DatabaseLayout databaseLayout)
        {
            _remoteStore.copy(new Org.Neo4j.causalclustering.catchup.CatchupAddressProvider_SingleAddressProvider(fromAddress), expectedStoreId, databaseLayout, true);
        }
Ejemplo n.º 14
0
 public CatchupAddressProvider_SingleAddressProvider(AdvertisedSocketAddress socketAddress)
 {
     this.SocketAddress = socketAddress;
 }
Ejemplo n.º 15
0
 public static Endpoint Route(AdvertisedSocketAddress address)
 {
     return(new Endpoint(address, Role.Route));
 }
Ejemplo n.º 16
0
 public Endpoint(AdvertisedSocketAddress address, Role role, string dbName)
 {
     this._address = address;
     this._role    = role;
 }
Ejemplo n.º 17
0
        internal virtual AdvertisedSocketAddress ResolveCorrectCCAddress(Config config, OptionalHostnamePort userProvidedAddress)
        {
            AdvertisedSocketAddress defaultValue = ReadDefaultConfigAddressCC(config);

            return(new AdvertisedSocketAddress(userProvidedAddress.Hostname.orElse(defaultValue.Hostname), userProvidedAddress.Port.GetValueOrDefault(defaultValue.Port)));
        }
Ejemplo n.º 18
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.causalclustering.identity.StoreId fetchStoreId(org.neo4j.helpers.AdvertisedSocketAddress fromAddress) throws org.neo4j.causalclustering.catchup.storecopy.StoreIdDownloadFailedException
        public virtual StoreId FetchStoreId(AdvertisedSocketAddress fromAddress)
        {
            return(_storeCopyClient.fetchStoreId(fromAddress));
        }
Ejemplo n.º 19
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.causalclustering.catchup.TxPullRequestResult pullTransactions(org.neo4j.helpers.AdvertisedSocketAddress fromAddress, org.neo4j.causalclustering.identity.StoreId storeId, long previousTxId, TxPullResponseListener txPullResponseListener) throws org.neo4j.causalclustering.catchup.CatchUpClientException
        public virtual TxPullRequestResult PullTransactions(AdvertisedSocketAddress fromAddress, StoreId storeId, long previousTxId, TxPullResponseListener txPullResponseListener)
        {
            _pullRequestMonitor.txPullRequest(previousTxId);
            return(_catchUpClient.makeBlockingRequest(fromAddress, new TxPullRequest(previousTxId, storeId), new CatchUpResponseAdaptorAnonymousInnerClass(this, previousTxId, txPullResponseListener)));
        }