Exemplo n.º 1
0
 internal SharedDiscoveryCoreClient(SharedDiscoveryService sharedDiscoveryService, MemberId member, LogProvider logProvider, Config config) : base(config, member, logProvider, logProvider)
 {
     this._localDBName            = config.Get(CausalClusteringSettings.database);
     this._sharedDiscoveryService = sharedDiscoveryService;
     this._coreServerInfo         = CoreServerInfo.From(config);
     this._refusesToBeLeader      = config.Get(CausalClusteringSettings.refuse_to_be_leader);
 }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCollectMembersAsAMap() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCollectMembersAsAMap()
        {
            // given
            int              numMembers       = 5;
            ISet <Member>    hazelcastMembers = new HashSet <Member>();
            IList <MemberId> coreMembers      = new List <MemberId>();

            IList <Config> configs = GenerateConfigs(numMembers);

            for (int i = 0; i < configs.Count; i++)
            {
                MemberId mId = new MemberId(System.Guid.randomUUID());
                coreMembers.Add(mId);

                Config c = configs[i];
                IDictionary <string, object> attributes = buildMemberAttributesForCore(mId, c).Attributes;
                hazelcastMembers.Add(new MemberImpl(new Address("localhost", i), null, attributes, false));
            }

            // when
            IDictionary <MemberId, CoreServerInfo> coreMemberMap = toCoreMemberMap(hazelcastMembers, NullLog.Instance, _hzInstance);

            // then
            for (int i = 0; i < numMembers; i++)
            {
                CoreServerInfo coreServerInfo = coreMemberMap[coreMembers[i]];
                assertEquals(new AdvertisedSocketAddress("tx", i + 1), coreServerInfo.CatchupServer);
                assertEquals(new AdvertisedSocketAddress("raft", i + 1), coreServerInfo.RaftServer);
                assertEquals(new AdvertisedSocketAddress("bolt", i + 1), coreServerInfo.Connectors().boltAddress());
                assertEquals(coreServerInfo.DatabaseName, DEFAULT_DB_NAME);
                assertEquals(coreServerInfo.Groups(), _groups);
            }
        }
Exemplo n.º 3
0
        internal void RegisterCoreMember(SharedDiscoveryCoreClient client)
        {
            CoreServerInfo previousMember = _coreMembers.putIfAbsent(client.MemberId, client.CoreServerInfo);

            if (previousMember == null)
            {
                _listeningClients.Add(client);
                _enoughMembers.Signal();
                NotifyCoreClients();
            }
        }
Exemplo n.º 4
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || this.GetType() != o.GetType())
            {
                return(false);
            }
            CoreServerInfo that = ( CoreServerInfo )o;

            return(_refuseToBeLeader == that._refuseToBeLeader && Objects.Equals(_raftServer, that._raftServer) && Objects.Equals(_catchupServer, that._catchupServer) && Objects.Equals(_clientConnectorAddresses, that._clientConnectorAddresses) && Objects.Equals(_groups, that._groups) && Objects.Equals(_dbName, that._dbName));
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBuildMemberAttributedWithSpecifiedDBNames() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldBuildMemberAttributedWithSpecifiedDBNames()
        {
            //given
            int              numMembers       = 10;
            ISet <Member>    hazelcastMembers = new HashSet <Member>();
            IList <MemberId> coreMembers      = new List <MemberId>();

            IDictionary <int, string> dbNames = CausalClusteringTestHelpers.distributeDatabaseNamesToHostNums(numMembers, _dbNames);

            System.Func <int, Dictionary <string, string> > generator = i =>
            {
                Dictionary <string, string> settings = _defaultSettingsGenerator.apply(i);
                settings.put(CausalClusteringSettings.database.name(), dbNames[i]);
                return(settings);
            };

            IList <Config> configs = GenerateConfigs(numMembers, generator);

            for (int i = 0; i < configs.Count; i++)
            {
                MemberId mId = new MemberId(System.Guid.randomUUID());
                coreMembers.Add(mId);

                Config c = configs[i];
                IDictionary <string, object> attributes = buildMemberAttributesForCore(mId, c).Attributes;
                hazelcastMembers.Add(new MemberImpl(new Address("localhost", i), null, attributes, false));
            }

            // when
            IDictionary <MemberId, CoreServerInfo> coreMemberMap = toCoreMemberMap(hazelcastMembers, NullLog.Instance, _hzInstance);

            // then
            for (int i = 0; i < numMembers; i++)
            {
                CoreServerInfo coreServerInfo = coreMemberMap[coreMembers[i]];
                string         expectedDBName = dbNames[i];
                assertEquals(expectedDBName, coreServerInfo.DatabaseName);
            }
        }
Exemplo n.º 6
0
 public static Config ConfigFor(CoreServerInfo coreServerInfo)
 {
     return(Config.builder().withSetting(CausalClusteringSettings.raft_advertised_address, coreServerInfo.RaftServer.ToString()).withSetting(CausalClusteringSettings.transaction_advertised_address, coreServerInfo.CatchupServer.ToString()).withSetting("dbms.connector.bolt.listen_address", coreServerInfo.Connectors().boltAddress().ToString()).withSetting("dbms.connector.bolt.enabled", true.ToString()).withSetting(CausalClusteringSettings.database, coreServerInfo.DatabaseName).withSetting(CausalClusteringSettings.server_groups, string.join(",", coreServerInfo.Groups())).withSetting(CausalClusteringSettings.refuse_to_be_leader, coreServerInfo.RefusesToBeLeader().ToString()).build());
 }