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 failedInstanceShouldReceiveCorrectCoordinatorIdUponRejoiningCluster() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void FailedInstanceShouldReceiveCorrectCoordinatorIdUponRejoiningCluster()
        {
            // Given
            HighlyAvailableGraphDatabase initialMaster = _cluster.Master;

            // When
            _cluster.shutdown(initialMaster);
            _cluster.await(masterAvailable(initialMaster));
            _cluster.await(masterSeesSlavesAsAvailable(1));

            // create node on new master to ensure that it has the greatest tx id
            CreateNodeOn(_cluster.Master);
            _cluster.sync();

            LifeSupport         life          = new LifeSupport();
            ClusterClientModule clusterClient = NewClusterClient(life, new InstanceId(1));

            Cleanup.add(life);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.concurrent.atomic.AtomicReference<org.neo4j.cluster.InstanceId> coordinatorIdWhenReJoined = new java.util.concurrent.atomic.AtomicReference<>();
            AtomicReference <InstanceId> coordinatorIdWhenReJoined = new AtomicReference <InstanceId>();

//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(1);
            System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1);
            clusterClient.ClusterClient.addClusterListener(new ClusterListener_AdapterAnonymousInnerClass(this, coordinatorIdWhenReJoined, latch));

            life.Start();

            // Then
            assertTrue(latch.await(20, SECONDS));
            assertEquals(new InstanceId(2), coordinatorIdWhenReJoined.get());
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void before() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Before()
        {
            _directory = TestDirectory.directory("temp");
            _life      = new LifeSupport();
            _life.start();               // So that the clients get started as they are added
            _clients = new ClusterClient[2];
            for (int i = 1; i <= _clients.Length; i++)
            {
                IDictionary <string, string> config = stringMap();
                config[cluster_server.name()] = ":" + (5000 + i);
                config[server_id.name()]      = "" + i;
                config[initial_hosts.name()]  = ":5001";

                LifeSupport         moduleLife          = new LifeSupport();
                ClusterClientModule clusterClientModule = new ClusterClientModule(moduleLife, new Dependencies(), new Monitors(), Config.defaults(config), NullLogService.Instance, new ServerIdElectionCredentialsProvider());

                ClusterClient client = clusterClientModule.ClusterClient;
                System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1);
                client.AddClusterListener(new ClusterListener_AdapterAnonymousInnerClass(this, client, latch));
                _life.add(moduleLife);
                _clients[i - 1] = client;
                assertTrue("Didn't join the cluster", latch.await(20, SECONDS));
            }
        }