//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldCorrectlyReturnCoreMemberRoles() public virtual void ShouldCorrectlyReturnCoreMemberRoles() { //given int numMembers = 3; IList <MemberId> members = IntStream.range(0, numMembers).mapToObj(ignored => new MemberId(System.Guid.randomUUID())).collect(Collectors.toList()); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") com.hazelcast.core.IAtomicReference<org.neo4j.causalclustering.core.consensus.LeaderInfo> leaderRef = mock(com.hazelcast.core.IAtomicReference.class); IAtomicReference <LeaderInfo> leaderRef = mock(typeof(IAtomicReference)); MemberId chosenLeaderId = members[0]; when(leaderRef.get()).thenReturn(new LeaderInfo(chosenLeaderId, 0L)); //JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") com.hazelcast.core.IMap<String,java.util.UUID> uuidDBMap = mock(com.hazelcast.core.IMap.class); IMap <string, System.Guid> uuidDBMap = mock(typeof(IMap)); when(uuidDBMap.Keys).thenReturn(Collections.singleton(DEFAULT_DB_NAME)); when(_hzInstance.getAtomicReference <LeaderInfo>(startsWith(DB_NAME_LEADER_TERM_PREFIX))).thenReturn(leaderRef); when(_hzInstance.getMap <string, System.Guid>(eq(CLUSTER_UUID_DB_NAME_MAP))).thenReturn(uuidDBMap); // when IDictionary <MemberId, RoleInfo> roleMap = HazelcastClusterTopology.GetCoreRoles(_hzInstance, new HashSet <MemberId, RoleInfo>(members)); // then assertEquals("First member was expected to be leader.", RoleInfo.Leader, roleMap[chosenLeaderId]); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void refreshRoles() throws InterruptedException private void RefreshRoles() { WaitOnHazelcastInstanceCreation(); LeaderInfo localLeaderInfo = _leaderInfo.get(); Optional <LeaderInfo> localStepDownInfo = _stepDownInfo.get(); if (localStepDownInfo.Present) { HazelcastClusterTopology.CasLeaders(_hazelcastInstance, localStepDownInfo.get(), _localDBName, Log); _stepDownInfo.compareAndSet(localStepDownInfo, null); } else if (localLeaderInfo.MemberId() != null && localLeaderInfo.MemberId().Equals(MyselfConflict)) { HazelcastClusterTopology.CasLeaders(_hazelcastInstance, localLeaderInfo, _localDBName, Log); } _coreRoles = HazelcastClusterTopology.GetCoreRoles(_hazelcastInstance, AllCoreServers().members().Keys); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private void refreshRoles() throws HazelcastInstanceNotActiveException private void RefreshRoles() { _coreRoles = _hzInstance.apply(hz => HazelcastClusterTopology.GetCoreRoles(hz, AllCoreServers().members().Keys)); }