コード例 #1
0
 public AbstractComponentSwitcherAnonymousInnerClass(HighAvailabilityMemberStateMachineTest outerInstance, UnknownType mock, DelegateInvocationHandler <Master> handler, System.Threading.CountdownEvent latch, AtomicReference <Master> @ref) : base(mock)
 {
     this.outerInstance = outerInstance;
     this._handler      = handler;
     this._latch        = latch;
     this.@ref          = @ref;
 }
コード例 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before()
        public virtual void Before()
        {
            _master         = mock(typeof(Master));
            _masterDelegate = new DelegateInvocationHandler <Master>(typeof(Master));
            _fs             = FileSystemRule.get();
            _fac            = new HaIdGeneratorFactory(_masterDelegate, NullLogProvider.Instance, mock(typeof(RequestContextFactory)), _fs, new CommunityIdTypeConfigurationProvider());
        }
コード例 #3
0
 public LockManagerSwitcher(DelegateInvocationHandler <Locks> @delegate, DelegateInvocationHandler <Master> master, RequestContextFactory requestContextFactory, AvailabilityGuard availabilityGuard, Factory <Locks> locksFactory, LogProvider logProvider, Config config) : base(@delegate)
 {
     this._master = master;
     this._requestContextFactory = requestContextFactory;
     this._availabilityGuard     = availabilityGuard;
     this._locksFactory          = locksFactory;
     this._logProvider           = logProvider;
     this._config = config;
 }
コード例 #4
0
 public HaIdGeneratorFactory(DelegateInvocationHandler <Master> master, LogProvider logProvider, RequestContextFactory requestContextFactory, FileSystemAbstraction fs, IdTypeConfigurationProvider idTypeConfigurationProvider)
 {
     this._fs = fs;
     this._idTypeConfigurationProvider = idTypeConfigurationProvider;
     this._localFactory          = new DefaultIdGeneratorFactory(fs, idTypeConfigurationProvider);
     this._master                = master;
     this._log                   = logProvider.getLog(this.GetType());
     this._requestContextFactory = requestContextFactory;
 }
コード例 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void switchesToPending() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void SwitchesToPending()
        {
            DelegateInvocationHandler <Component> @delegate = new DelegateInvocationHandler <Component>(typeof(Component));
            TestComponentSwitcher switcher = new TestComponentSwitcher(@delegate);

            switcher.SwitchToPending();

            assertEquals(DelegateClass(@delegate), typeof(PendingComponent));
        }
コード例 #6
0
 public SwitchToMaster(LogService logService, HaIdGeneratorFactory idGeneratorFactory, Config config, System.Func <SlaveFactory> slaveFactorySupplier, System.Func <Locks, ConversationManager> conversationManagerFactory, System.Func <ConversationManager, LifeSupport, Master> masterFactory, System.Func <Master, ConversationManager, MasterServer> masterServerFactory, DelegateInvocationHandler <Master> masterDelegateHandler, ClusterMemberAvailability clusterMemberAvailability, System.Func <NeoStoreDataSource> dataSourceSupplier)
 {
     this.ConversationManagerFactory = conversationManagerFactory;
     this.MasterFactory              = masterFactory;
     this.MasterServerFactory        = masterServerFactory;
     this._userLog                   = logService.GetUserLog(this.GetType());
     this._idGeneratorFactory        = idGeneratorFactory;
     this._config                    = config;
     this._slaveFactorySupplier      = slaveFactorySupplier;
     this._masterDelegateHandler     = masterDelegateHandler;
     this._clusterMemberAvailability = clusterMemberAvailability;
     this._dataSourceSupplier        = dataSourceSupplier;
 }
コード例 #7
0
 public override void Close()
 {
     _userLog = null;
     ConversationManagerFactory = null;
     MasterFactory              = null;
     MasterServerFactory        = null;
     _idGeneratorFactory        = null;
     _config                    = null;
     _slaveFactorySupplier      = null;
     _masterDelegateHandler     = null;
     _clusterMemberAvailability = null;
     _dataSourceSupplier        = null;
 }
コード例 #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUp()
        public virtual void SetUp()
        {
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") org.neo4j.kernel.ha.DelegateInvocationHandler<org.neo4j.kernel.ha.UpdatePuller> invocationHandler = mock(org.neo4j.kernel.ha.DelegateInvocationHandler.class);
            DelegateInvocationHandler <UpdatePuller> invocationHandler = mock(typeof(DelegateInvocationHandler));
            PullerFactory pullerFactory = mock(typeof(PullerFactory));

            _slaveUpdatePuller = mock(typeof(SlaveUpdatePuller));
            when(pullerFactory.CreateSlaveUpdatePuller()).thenReturn(_slaveUpdatePuller);
            when(invocationHandler.setDelegate(_slaveUpdatePuller)).thenReturn(_slaveUpdatePuller);

            _modeSwitcher = new UpdatePullerSwitcher(invocationHandler, pullerFactory);
        }
コード例 #9
0
 internal SwitchToSlave(HaIdGeneratorFactory idGeneratorFactory, Monitors monitors, RequestContextFactory requestContextFactory, DelegateInvocationHandler <Master> masterDelegateHandler, ClusterMemberAvailability clusterMemberAvailability, MasterClientResolver masterClientResolver, Monitor monitor, PullerFactory pullerFactory, UpdatePuller updatePuller, System.Func <Slave, SlaveServer> slaveServerFactory, Config config, LogService logService, PageCache pageCache, DatabaseLayout databaseLayout, System.Func <TransactionIdStore> transactionIdStoreSupplier, System.Func <DatabaseTransactionStats> transactionStatsSupplier, System.Func <NeoStoreDataSource> neoDataSourceSupplier, StoreCopyClient storeCopyClient)
 {
     this._idGeneratorFactory        = idGeneratorFactory;
     this.Monitors                   = monitors;
     this.RequestContextFactory      = requestContextFactory;
     this._masterDelegateHandler     = masterDelegateHandler;
     this._clusterMemberAvailability = clusterMemberAvailability;
     this._masterClientResolver      = masterClientResolver;
     this.UserLog = logService.GetUserLog(this.GetType());
     this.MsgLog  = logService.GetInternalLog(this.GetType());
     this.Monitor = monitor;
     this._updatePullerFactory = pullerFactory;
     this.UpdatePuller         = updatePuller;
     this._slaveServerFactory  = slaveServerFactory;
     this.Config         = config;
     this.PageCache      = pageCache;
     this.DatabaseLayout = databaseLayout;
     this._transactionIdStoreSupplier = transactionIdStoreSupplier;
     this._transactionStatsSupplier   = transactionStatsSupplier;
     this._neoDataSourceSupplier      = neoDataSourceSupplier;
     this._storeCopyClient            = storeCopyClient;
 }
コード例 #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void whenHAModeSwitcherSwitchesToSlaveTheOtherModeSwitcherDoNotGetTheOldMasterClient() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void WhenHAModeSwitcherSwitchesToSlaveTheOtherModeSwitcherDoNotGetTheOldMasterClient()
        {
            InstanceId me      = new InstanceId(1);
            StoreId    storeId = newStoreIdForCurrentVersion();
            HighAvailabilityMemberContext context = mock(typeof(HighAvailabilityMemberContext));

            when(context.MyId).thenReturn(me);
            AvailabilityGuard      guard        = mock(typeof(DatabaseAvailabilityGuard));
            ObservedClusterMembers members      = mock(typeof(ObservedClusterMembers));
            ClusterMember          masterMember = mock(typeof(ClusterMember));

            when(masterMember.HARole).thenReturn("master");
            when(masterMember.HasRole("master")).thenReturn(true);
            when(masterMember.InstanceId).thenReturn(new InstanceId(2));
            when(masterMember.StoreId).thenReturn(storeId);
            ClusterMember self = new ClusterMember(me);

            when(members.Members).thenReturn(Arrays.asList(self, masterMember));
            when(members.CurrentMember).thenReturn(self);
            DependencyResolver    dependencyResolver = mock(typeof(DependencyResolver));
            FileSystemAbstraction fs = mock(typeof(FileSystemAbstraction));

            when(fs.FileExists(any(typeof(File)))).thenReturn(true);
            when(dependencyResolver.ResolveDependency(typeof(FileSystemAbstraction))).thenReturn(fs);
            when(dependencyResolver.ResolveDependency(typeof(Monitors))).thenReturn(new Monitors());
            NeoStoreDataSource dataSource = mock(typeof(NeoStoreDataSource));

            when(dataSource.DependencyResolver).thenReturn(dependencyResolver);
            when(dataSource.StoreId).thenReturn(storeId);
            when(dependencyResolver.ResolveDependency(typeof(NeoStoreDataSource))).thenReturn(dataSource);
            when(dependencyResolver.ResolveDependency(typeof(TransactionIdStore))).thenReturn(new SimpleTransactionIdStore());
            when(dependencyResolver.ResolveDependency(typeof(ObservedClusterMembers))).thenReturn(members);
            UpdatePuller updatePuller = mock(typeof(UpdatePuller));

            when(updatePuller.TryPullUpdates()).thenReturn(true);
            when(dependencyResolver.ResolveDependency(typeof(UpdatePuller))).thenReturn(updatePuller);

            ClusterMemberAvailability clusterMemberAvailability = mock(typeof(ClusterMemberAvailability));
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final TriggerableClusterMemberEvents events = new TriggerableClusterMemberEvents();
            TriggerableClusterMemberEvents events = new TriggerableClusterMemberEvents();

            Election election = mock(typeof(Election));
            HighAvailabilityMemberStateMachine stateMachine = new HighAvailabilityMemberStateMachine(context, guard, members, events, election, NullLogProvider.Instance);

            ClusterMembers clusterMembers = new ClusterMembers(members, stateMachine);

            when(dependencyResolver.ResolveDependency(typeof(ClusterMembers))).thenReturn(clusterMembers);

            stateMachine.Init();
            stateMachine.Start();

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.ha.DelegateInvocationHandler<org.neo4j.kernel.ha.com.master.Master> handler = new org.neo4j.kernel.ha.DelegateInvocationHandler<>(org.neo4j.kernel.ha.com.master.Master.class);
            DelegateInvocationHandler <Master> handler = new DelegateInvocationHandler <Master>(typeof(Master));

            MasterClientResolver masterClientResolver = mock(typeof(MasterClientResolver));
            MasterClient         masterClient         = mock(typeof(MasterClient));

            when(masterClient.ProtocolVersion).thenReturn(MasterClient214.PROTOCOL_VERSION);
            when(masterClient.Handshake(anyLong(), any(typeof(StoreId)))).thenReturn(new ResponseAnonymousInnerClass(this, storeId, mock(typeof(ResourceReleaser)), handler));
            when(masterClient.ToString()).thenReturn("TheExpectedMasterClient!");
            when(masterClientResolver.Instantiate(anyString(), anyInt(), anyString(), any(typeof(Monitors)), any(typeof(StoreId)), any(typeof(LifeSupport)))).thenReturn(masterClient);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.CountDownLatch latch = new java.util.concurrent.CountDownLatch(2);
            System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(2);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicBoolean switchedSuccessfully = new java.util.concurrent.atomic.AtomicBoolean();
            AtomicBoolean switchedSuccessfully = new AtomicBoolean();

            SwitchToSlave.Monitor monitor = new MonitorAnonymousInnerClass(this, latch, switchedSuccessfully);

            Config config = Config.defaults(ClusterSettings.server_id, me.ToString());

            DatabaseTransactionStats transactionCounters = mock(typeof(DatabaseTransactionStats));

            when(transactionCounters.NumberOfActiveTransactions).thenReturn(0L);

            PageCache pageCacheMock = mock(typeof(PageCache));
            PagedFile pagedFileMock = mock(typeof(PagedFile));

            when(pagedFileMock.LastPageId).thenReturn(1L);
            when(pageCacheMock.Map(any(typeof(File)), anyInt())).thenReturn(pagedFileMock);

            TransactionIdStore transactionIdStoreMock = mock(typeof(TransactionIdStore));

            when(transactionIdStoreMock.LastCommittedTransaction).thenReturn(new TransactionId(0, 0, 0));
            SwitchToSlaveCopyThenBranch switchToSlave = new SwitchToSlaveCopyThenBranch(DatabaseLayout.of(new File("")), NullLogService.Instance, mock(typeof(FileSystemAbstraction)), config, mock(typeof(HaIdGeneratorFactory)), handler, mock(typeof(ClusterMemberAvailability)), mock(typeof(RequestContextFactory)), mock(typeof(PullerFactory), RETURNS_MOCKS), Iterables.empty(), masterClientResolver, monitor, new Org.Neo4j.com.storecopy.StoreCopyClientMonitor_Adapter(), Suppliers.singleton(dataSource), Suppliers.singleton(transactionIdStoreMock), slave =>
            {
                SlaveServer mock = mock(typeof(SlaveServer));
                when(mock.SocketAddress).thenReturn(new InetSocketAddress("localhost", 123));
                return(mock);
            }, updatePuller, pageCacheMock, mock(typeof(Monitors)), () => transactionCounters);

            ComponentSwitcherContainer   switcherContainer = new ComponentSwitcherContainer();
            HighAvailabilityModeSwitcher haModeSwitcher    = new HighAvailabilityModeSwitcher(switchToSlave, mock(typeof(SwitchToMaster)), election, clusterMemberAvailability, mock(typeof(ClusterClient)), storeSupplierMock(), me, switcherContainer, NeoStoreDataSourceSupplierMock(), NullLogService.Instance);

            haModeSwitcher.Init();
            haModeSwitcher.Start();
            haModeSwitcher.ListeningAt(URI.create("http://localhost:12345"));

            stateMachine.AddHighAvailabilityMemberListener(haModeSwitcher);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<org.neo4j.kernel.ha.com.master.Master> ref = new java.util.concurrent.atomic.AtomicReference<>(null);
            AtomicReference <Master> @ref = new AtomicReference <Master>(null);

            //noinspection unchecked
            AbstractComponentSwitcher <object> otherModeSwitcher = new AbstractComponentSwitcherAnonymousInnerClass(this, mock(typeof(DelegateInvocationHandler)), handler, latch, @ref);

            switcherContainer.Add(otherModeSwitcher);
            // When
            events.SwitchToSlave(me);

            // Then
            latch.await();
            assertTrue("mode switch failed", switchedSuccessfully.get());
            Master actual = @ref.get();

            // let's test the toString()s since there are too many wrappers of proxies
            assertEquals(masterClient.ToString(), actual.ToString());

            stateMachine.Stop();
            stateMachine.Shutdown();
            haModeSwitcher.Stop();
            haModeSwitcher.Shutdown();
        }
コード例 #11
0
 internal HighlyAvailableCommitProcessFactory(DelegateInvocationHandler <TransactionCommitProcess> commitProcessDelegate)
 {
     this._commitProcessDelegate = commitProcessDelegate;
 }
コード例 #12
0
 public CommitProcessSwitcher(TransactionPropagator txPropagator, Master master, DelegateInvocationHandler <TransactionCommitProcess> @delegate, RequestContextFactory requestContextFactory, Monitors monitors, DependencyResolver dependencyResolver, Config config) : base(@delegate)
 {
     this._txPropagator          = txPropagator;
     this._master                = master;
     this._requestContextFactory = requestContextFactory;
     this._dependencyResolver    = dependencyResolver;
     this._monitor               = monitors.NewMonitor(typeof(MasterTransactionCommitProcess.Monitor));
     this._activeDatabaseName    = config.Get(GraphDatabaseSettings.active_database);
 }
コード例 #13
0
 public LabelTokenCreatorSwitcher(DelegateInvocationHandler <TokenCreator> @delegate, DelegateInvocationHandler <Master> master, RequestContextFactory requestContextFactory, System.Func <Kernel> kernelSupplier) : base(@delegate)
 {
     this._master = master;
     this._requestContextFactory = requestContextFactory;
     this._kernelSupplier        = kernelSupplier;
 }
コード例 #14
0
 protected internal AbstractComponentSwitcher(DelegateInvocationHandler <T> @delegate)
 {
     this.@delegate = @delegate;
 }
コード例 #15
0
 public ResponseAnonymousInnerClass(HighAvailabilityMemberStateMachineTest outerInstance, StoreId storeId, UnknownType mock, DelegateInvocationHandler <Master> handler) : base(new HandshakeResult(0, 42), storeId, mock)
 {
     this.outerInstance = outerInstance;
     this._handler      = handler;
 }
コード例 #16
0
 internal TestComponentSwitcher(DelegateInvocationHandler <Component> @delegate) : base(@delegate)
 {
 }
コード例 #17
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private static Class delegateClass(org.neo4j.kernel.ha.DelegateInvocationHandler<?> invocationHandler) throws Throwable
        private static Type DelegateClass <T1>(DelegateInvocationHandler <T1> invocationHandler)
        {
            return(( Type )invocationHandler.Invoke(new object(), typeof(object).GetMethod("getClass"), new object[0]));
        }
コード例 #18
0
 public StatementLocksFactorySwitcher(DelegateInvocationHandler <StatementLocksFactory> @delegate, StatementLocksFactory configuredStatementLocksFactory) : base(@delegate)
 {
     this._configuredStatementLocksFactory = configuredStatementLocksFactory;
 }
コード例 #19
0
 public UpdatePullerSwitcher(DelegateInvocationHandler <UpdatePuller> @delegate, PullerFactory pullerFactory) : base(@delegate)
 {
     this._pullerFactory = pullerFactory;
 }