Esempio n. 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void bootstrapCluster() throws Exception
        private void BootstrapCluster()
        {
            string instance1            = "cluster://localhost:5001";
            string instance2            = "cluster://localhost:5002";
            string instance3            = "cluster://localhost:5003";
            ClusterConfiguration config = new ClusterConfiguration("default", NullLogProvider.Instance, instance1, instance2, instance3);

            ClusterState state = new ClusterState(new IList <ClusterInstance> {
                newClusterInstance(new InstanceId(1), new URI(instance1), new Monitors(), config, 10, NullLogProvider.Instance), newClusterInstance(new InstanceId(2), new URI(instance2), new Monitors(), config, 10, NullLogProvider.Instance), newClusterInstance(new InstanceId(3), new URI(instance3), new Monitors(), config, 10, NullLogProvider.Instance)
            }, emptySet());

            state = state.PerformAction(new MessageDeliveryAction(Message.to(ClusterMessage.create, new URI(instance3), "defaultcluster").setHeader(Message.HEADER_CONVERSATION_ID, "-1").setHeader(Message.HEADER_FROM, instance3)));
            state = state.PerformAction(new MessageDeliveryAction(Message.to(ClusterMessage.join, new URI(instance2), new object[]
            {
                "defaultcluster", new URI[] { new URI(instance3) }
            }).setHeader(Message.HEADER_CONVERSATION_ID, "-1").setHeader(Message.HEADER_FROM, instance2)));
            state = state.PerformAction(new MessageDeliveryAction(Message.to(ClusterMessage.join, new URI(instance1), new object[]
            {
                "defaultcluster", new URI[] { new URI(instance3) }
            }).setHeader(Message.HEADER_CONVERSATION_ID, "-1").setHeader(Message.HEADER_FROM, instance1)));

            state.AddPendingActions(new InstanceCrashedAction(instance3));

            _unexploredKnownStates.AddLast(state);

            _db.newState(state);
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void twoStatesWithSameSetupAndPendingMessagesShouldBeEqual() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void TwoStatesWithSameSetupAndPendingMessagesShouldBeEqual()
        {
            // Given
            ClusterConfiguration config = new ClusterConfiguration("default", NullLogProvider.Instance, "cluster://localhost:5001", "cluster://localhost:5002", "cluster://localhost:5003");

            ClusterState state = new ClusterState(new IList <ClusterInstance> {
                newClusterInstance(new InstanceId(1), new URI("cluster://localhost:5001"), new Monitors(), config, 10, NullLogProvider.Instance), newClusterInstance(new InstanceId(2), new URI("cluster://localhost:5002"), new Monitors(), config, 10, NullLogProvider.Instance), newClusterInstance(new InstanceId(3), new URI("cluster://localhost:5003"), new Monitors(), config, 10, NullLogProvider.Instance)
            }, emptySet());

            // When
            ClusterState firstState = state.PerformAction(new MessageDeliveryAction(Message.to(ClusterMessage.join, new URI("cluster://localhost:5002"), new object[]
            {
                "defaultcluster", new URI[] { new URI("cluster://localhost:5003") }
            }).setHeader(Message.HEADER_CONVERSATION_ID, "-1").setHeader(Message.HEADER_FROM, "cluster://localhost:5002")));
            ClusterState secondState = state.PerformAction(new MessageDeliveryAction(Message.to(ClusterMessage.join, new URI("cluster://localhost:5002"), new object[]
            {
                "defaultcluster", new URI[] { new URI("cluster://localhost:5003") }
            }).setHeader(Message.HEADER_CONVERSATION_ID, "-1").setHeader(Message.HEADER_FROM, "cluster://localhost:5002")));

            // Then
            assertEquals(firstState, secondState);
            assertEquals(firstState.GetHashCode(), secondState.GetHashCode());
        }