Beispiel #1
0
        internal static CoreTopology FakeCoreTopology(params MemberId[] memberIds)
        {
            Debug.Assert(memberIds.Length > 0);

            ClusterId clusterId = new ClusterId(System.Guid.randomUUID());
            IDictionary <MemberId, CoreServerInfo> coreMembers = new Dictionary <MemberId, CoreServerInfo>();

            int offset = 0;

            foreach (MemberId memberId in memberIds)
            {
                coreMembers[memberId] = TestTopology.addressesForCore(offset, false);
                offset++;
            }

            return(new CoreTopology(clusterId, false, coreMembers));
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBootstrapWhenBootstrappable() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBootstrapWhenBootstrappable()
        {
            // given
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            IDictionary <MemberId, CoreServerInfo> members = IntStream.range(0, _minCoreHosts).mapToObj(i => Pair.of(new MemberId(System.Guid.randomUUID()), TestTopology.addressesForCore(i, false))).collect(Collectors.toMap(Pair::first, Pair::other));

            CoreTopology bootstrappableTopology = new CoreTopology(null, true, members);

            CoreTopologyService topologyService = mock(typeof(CoreTopologyService));

            when(topologyService.LocalCoreServers()).thenReturn(bootstrappableTopology);
            when(topologyService.SetClusterId(any(), eq("default"))).thenReturn(true);
            CoreSnapshot snapshot = mock(typeof(CoreSnapshot));

            when(_coreBootstrapper.bootstrap(any())).thenReturn(snapshot);

            ClusterBinder binder = ClusterBinder(new StubSimpleStorage <ClusterId>(this), topologyService);

            // when
            BoundState boundState = binder.BindToCluster();

            // then
            verify(_coreBootstrapper).bootstrap(any());
            Optional <ClusterId> clusterId = binder.Get();

            assertTrue(clusterId.Present);
            verify(topologyService).setClusterId(clusterId.get(), "default");
            assertTrue(boundState.Snapshot().Present);
            assertEquals(boundState.Snapshot().get(), snapshot);
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expected = java.util.concurrent.TimeoutException.class) public void shouldTimeoutIfPublishContinuallyFailsWithTransientErrors() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldTimeoutIfPublishContinuallyFailsWithTransientErrors()
        {
            // given
//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            IDictionary <MemberId, CoreServerInfo> members = IntStream.range(0, _minCoreHosts).mapToObj(i => Pair.of(new MemberId(System.Guid.randomUUID()), TestTopology.addressesForCore(i, false))).collect(Collectors.toMap(Pair::first, Pair::other));

            CoreTopology        bootstrappableTopology = new CoreTopology(null, true, members);
            CoreTopologyService topologyService        = mock(typeof(CoreTopologyService));

            when(topologyService.SetClusterId(any(), anyString())).thenThrow(typeof(OperationTimeoutException));                   // Causes a retry
            when(topologyService.LocalCoreServers()).thenReturn(bootstrappableTopology);

            ClusterBinder binder = ClusterBinder(new StubSimpleStorage <ClusterId>(this), topologyService);

            // when
            binder.BindToCluster();
        }