Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnNoWriteEndpointsIfThereIsNoAddressForTheLeader() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnNoWriteEndpointsIfThereIsNoAddressForTheLeader()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.discovery.CoreTopologyService topologyService = mock(org.neo4j.causalclustering.discovery.CoreTopologyService.class);
            CoreTopologyService topologyService = mock(typeof(CoreTopologyService));

            IDictionary <MemberId, CoreServerInfo> coreMembers = new Dictionary <MemberId, CoreServerInfo>();

            coreMembers[member(0)] = addressesForCore(0, false);

            when(topologyService.LocalCoreServers()).thenReturn(new CoreTopology(_clusterId, false, coreMembers));
            when(topologyService.LocalReadReplicas()).thenReturn(new ReadReplicaTopology(emptyMap()));

            LeaderLocator leaderLocator = mock(typeof(LeaderLocator));

            when(leaderLocator.Leader).thenReturn(member(1));

            LegacyGetServersProcedure procedure = new LegacyGetServersProcedure(topologyService, leaderLocator, Config, Instance);

            // when
            ClusterView clusterView = Run(procedure);

            // then

            ClusterView.Builder builder = new ClusterView.Builder();
            builder.ReadAddress(addressesForCore(0, false).connectors().boltAddress());
            builder.RouteAddress(addressesForCore(0, false).connectors().boltAddress());

            assertEquals(builder.Build(), clusterView);
        }
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 ttlShouldBeInSeconds() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TtlShouldBeInSeconds()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.discovery.CoreTopologyService coreTopologyService = mock(org.neo4j.causalclustering.discovery.CoreTopologyService.class);
            CoreTopologyService coreTopologyService = mock(typeof(CoreTopologyService));

            LeaderLocator leaderLocator = mock(typeof(LeaderLocator));

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.discovery.CoreTopology clusterTopology = new org.neo4j.causalclustering.discovery.CoreTopology(clusterId, false, new java.util.HashMap<>());
            CoreTopology clusterTopology = new CoreTopology(_clusterId, false, new Dictionary <MemberId, CoreServerInfo>());

            when(coreTopologyService.LocalCoreServers()).thenReturn(clusterTopology);
            when(coreTopologyService.LocalReadReplicas()).thenReturn(new ReadReplicaTopology(emptyMap()));

            // set the TTL in minutes
            Config.augment(cluster_routing_ttl, "10m");

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LegacyGetServersProcedure proc = new LegacyGetServersProcedure(coreTopologyService, leaderLocator, config, getInstance());
            LegacyGetServersProcedure proc = new LegacyGetServersProcedure(coreTopologyService, leaderLocator, Config, Instance);

            // when
            IList <object[]> results = new IList <object[]> {
                proc.Apply(null, new object[0], null)
            };

            // then
            object[] rows         = results[0];
            long     ttlInSeconds = ( long )rows[0];

            assertEquals(600, ttlInSeconds);
        }
Ejemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") private ClusterView run(LegacyGetServersProcedure proc) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        private ClusterView Run(LegacyGetServersProcedure proc)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Object[] rows = asList(proc.apply(null, new Object[0], null)).get(0);
            object[] rows = asList(proc.Apply(null, new object[0], null)).get(0);
            assertEquals(Config.get(cluster_routing_ttl).Seconds, ( long )rows[0]);
            return(ClusterView.parse((IList <IDictionary <string, object> >)rows[1]));
        }
Ejemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private Object[] getEndpoints(LegacyGetServersProcedure proc) throws org.neo4j.internal.kernel.api.exceptions.ProcedureException
        private object[] GetEndpoints(LegacyGetServersProcedure proc)
        {
            IList <object[]> results = new IList <object[]> {
                proc.Apply(null, new object[0], null)
            };

            object[] rows = results[0];
            IList <IDictionary <string, object[]> > servers   = (IList <IDictionary <string, object[]> >)rows[1];
            IDictionary <string, object[]>          endpoints = servers[ServerClass];

            return(endpoints["addresses"]);
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldHaveCorrectSignature()
        public virtual void ShouldHaveCorrectSignature()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LegacyGetServersProcedure proc = new LegacyGetServersProcedure(null, null, config, getInstance());
            LegacyGetServersProcedure proc = new LegacyGetServersProcedure(null, null, Config, Instance);

            // when
            ProcedureSignature signature = proc.Signature();

            // then
            assertThat(signature.OutputSignature(), containsInAnyOrder(FieldSignature.outputField("ttl", NTInteger), FieldSignature.outputField("servers", NTList(NTMap))));
        }
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 shouldReturnEndpointsInDifferentOrders() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReturnEndpointsInDifferentOrders()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.discovery.CoreTopologyService coreTopologyService = mock(org.neo4j.causalclustering.discovery.CoreTopologyService.class);
            CoreTopologyService coreTopologyService = mock(typeof(CoreTopologyService));

            LeaderLocator leaderLocator = mock(typeof(LeaderLocator));

            when(leaderLocator.Leader).thenReturn(member(0));

            IDictionary <MemberId, CoreServerInfo> coreMembers = new Dictionary <MemberId, CoreServerInfo>();

            coreMembers[member(0)] = addressesForCore(0, false);
            coreMembers[member(1)] = addressesForCore(1, false);
            coreMembers[member(2)] = addressesForCore(2, false);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.discovery.CoreTopology clusterTopology = new org.neo4j.causalclustering.discovery.CoreTopology(clusterId, false, coreMembers);
            CoreTopology clusterTopology = new CoreTopology(_clusterId, false, coreMembers);

            when(coreTopologyService.LocalCoreServers()).thenReturn(clusterTopology);
            when(coreTopologyService.LocalReadReplicas()).thenReturn(new ReadReplicaTopology(emptyMap()));

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LegacyGetServersProcedure proc = new LegacyGetServersProcedure(coreTopologyService, leaderLocator, config, getInstance());
            LegacyGetServersProcedure proc = new LegacyGetServersProcedure(coreTopologyService, leaderLocator, _config, Instance);

            // when
            object[] endpoints = GetEndpoints(proc);

            //then
            object[] endpointsInDifferentOrder = GetEndpoints(proc);
            for (int i = 0; i < 100; i++)
            {
                if (Arrays.deepEquals(endpointsInDifferentOrder, endpoints))
                {
                    endpointsInDifferentOrder = GetEndpoints(proc);
                }
                else
                {
                    //Different order of servers, no need to retry.
                    break;
                }
            }
            assertFalse(Arrays.deepEquals(endpoints, endpointsInDifferentOrder));
        }