Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldConsultUnsatisfiedDependencyHandlerOnFailingDependencyClasses()
        public virtual void ShouldConsultUnsatisfiedDependencyHandlerOnFailingDependencyClasses()
        {
            // GIVEN
            KernelContext context = mock(typeof(KernelContext));
            KernelExtensionFailureStrategy handler = mock(typeof(KernelExtensionFailureStrategy));
            Dependencies dependencies = new Dependencies();               // that hasn't got anything.
            UninitializableKernelExtensionFactory extensionFactory = new UninitializableKernelExtensionFactory();
            GlobalKernelExtensions extensions = new GlobalKernelExtensions(context, iterable(extensionFactory), dependencies, handler);

            // WHEN
            LifeSupport life = new LifeSupport();

            life.Add(extensions);
            try
            {
                life.Start();

                // THEN
                verify(handler).handle(eq(extensionFactory), any(typeof(System.ArgumentException)));
            }
            finally
            {
                life.Shutdown();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Performs a switch to the master state. Starts communication endpoints, switches components to the master state
        /// and broadcasts the appropriate Master Is Available event. </summary>
        /// <param name="haCommunicationLife"> The LifeSupport instance to register communication endpoints. </param>
        /// <param name="me"> The URI that the communication endpoints should bind to </param>
        /// <returns> The URI at which the master communication was bound. </returns>
//JAVA TO C# CONVERTER NOTE: Members cannot have the same name as their enclosing type:
        public virtual URI SwitchToMasterConflict(LifeSupport haCommunicationLife, URI me)
        {
            _userLog.info("I am %s, moving to master", MyId(_config));

            // Do not wait for currently active transactions to complete before continuing switching.
            // - A master in a cluster is very important, without it the cluster cannot process any write requests
            // - Awaiting open transactions to complete assumes that this instance just now was a slave that is
            //   switching to master, which means the previous master where these active transactions were hosted
            //   is no longer available so these open transactions cannot continue and complete anyway,
            //   so what's the point waiting for them?
            // - Read transactions may still be able to complete, but the correct response to failures in those
            //   is to have them throw transient error exceptions hinting that they should be retried,
            //   at which point they may get redirected to another instance, or to this instance if it has completed
            //   the switch until then.

            _idGeneratorFactory.switchToMaster();
            NeoStoreDataSource dataSource = _dataSourceSupplier.get();

            dataSource.AfterModeSwitch();

            Locks locks = dataSource.DependencyResolver.resolveDependency(typeof(Locks));
            ConversationManager conversationManager = ConversationManagerFactory.apply(locks);
            Master master = MasterFactory.apply(conversationManager, haCommunicationLife);

            MasterServer masterServer = MasterServerFactory.apply(master, conversationManager);

            haCommunicationLife.Add(masterServer);
            _masterDelegateHandler.Delegate = master;

            haCommunicationLife.Start();

            URI masterHaURI = GetMasterUri(me, masterServer, _config);

            _clusterMemberAvailability.memberIsAvailable(MASTER, masterHaURI, dataSource.StoreId);
            _userLog.info("I am %s, successfully moved to master", MyId(_config));

            _slaveFactorySupplier.get().StoreId = dataSource.StoreId;

            return(masterHaURI);
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldResolveMasterClientFactory()
        public virtual void ShouldResolveMasterClientFactory()
        {
            // Given
            LogEntryReader <ReadableClosablePositionAwareChannel> logEntryReader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            MasterClientResolver resolver = new MasterClientResolver(NullLogProvider.Instance, Org.Neo4j.com.storecopy.ResponseUnpacker_Fields.NoOpResponseUnpacker, mock(typeof(InvalidEpochExceptionHandler)), 1, 1, 1, 1024, Suppliers.singleton(logEntryReader));

            LifeSupport life = new LifeSupport();

            try
            {
                life.Start();
                MasterClient masterClient1 = resolver.Instantiate("cluster://localhost", 44, null, new Monitors(), StoreId.DEFAULT, life);
                assertThat(masterClient1, instanceOf(typeof(MasterClient320)));
            }
            finally
            {
                life.Shutdown();
            }

            IllegalProtocolVersionException illegalProtocolVersionException = new IllegalProtocolVersionException(MasterClient214.PROTOCOL_VERSION.ApplicationProtocol, MasterClient310.PROTOCOL_VERSION.ApplicationProtocol, "Protocol is too modern");

            // When
            resolver.Handle(illegalProtocolVersionException);

            // Then
            life = new LifeSupport();
            try
            {
                life.Start();
                MasterClient masterClient2 = resolver.Instantiate("cluster://localhost", 55, null, new Monitors(), StoreId.DEFAULT, life);

                assertThat(masterClient2, instanceOf(typeof(MasterClient214)));
            }
            finally
            {
                life.Shutdown();
            }
        }
Esempio n. 4
0
        private void ShouldGatherForensicsInFullBackupRequest(bool forensics)
        {
            // GIVEN
            Response <Void> response = Response.empty();
            StoreId         storeId  = response.StoreId;
            string          host     = "localhost";
            int             port     = PortAuthority.allocatePort();
            LifeSupport     life     = new LifeSupport();

            LogEntryReader <ReadableClosablePositionAwareChannel> reader = new VersionAwareLogEntryReader <ReadableClosablePositionAwareChannel>();
            NullLogProvider    logProvider        = NullLogProvider.Instance;
            ResponseUnpacker   responseUnpacker   = mock(typeof(ResponseUnpacker));
            ByteCounterMonitor byteCounterMonitor = mock(typeof(ByteCounterMonitor));
            RequestMonitor     requestMonitor     = mock(typeof(RequestMonitor));
            BackupClient       client             = new BackupClient(host, port, null, logProvider, storeId, 10_000, responseUnpacker, byteCounterMonitor, requestMonitor, reader);

            life.Add(client);
            ControlledBackupInterface backup = new ControlledBackupInterface();
            HostnamePort hostnamePort        = new HostnamePort(host, port);

            life.Add(new BackupServer(backup, hostnamePort, logProvider, byteCounterMonitor, requestMonitor));
            life.Start();

            try
            {
                // WHEN
                StoreWriter writer = mock(typeof(StoreWriter));
                client.FullBackup(writer, forensics);

                // THEN
                assertEquals(forensics, backup.ReceivedForensics);
            }
            finally
            {
                life.Shutdown();
            }
        }