void Processor.Process(HandlerContext context, object msg) { if (!(msg is Datagram datagram)) { return; } if (datagram.Header.Code != 0) { return; } var packet = new Packet(datagram.Body, 0, datagram.Body.Length); //skip ts packet.ReadInt64(); var subject = packet.ReadUTF8(); //skip consumerGroup packet.ReadUTF8(); //skip online offline state packet.ReadByte(); int clientTypeCode = packet.ReadByte(); var clusterInfo = new NewQmqClusterInfo { Subject = subject, ClientType = (ClientType)clientTypeCode }; var brokerCount = packet.ReadInt16(); for (var i = 0; i < brokerCount; ++i) { var groupName = packet.ReadUTF8(); var master = packet.ReadUTF8(); var ts = packet.ReadInt64(); var state = packet.ReadByte(); var group = new BrokerGroup { Name = groupName, Master = master, UpdateTs = ts, BrokerState = (BrokerState)state }; clusterInfo.AddBrokerGroup(@group); } _clusterMap.TryGetValue(clusterInfo.ClientType.ToString() + '$' + clusterInfo.Subject, out var clusterInfoFuture); if (clusterInfoFuture != null) { clusterInfoFuture.Result = clusterInfo; } }
public static bool IsWritable(BrokerGroup brokerGroup) { return(brokerGroup.BrokerState == BrokerState.W || brokerGroup.BrokerState == BrokerState.Rw); }
public static bool IsReadable(BrokerGroup brokerGroup) { return(brokerGroup.BrokerState == BrokerState.R || brokerGroup.BrokerState == BrokerState.Rw); }
public void AddBrokerGroup(BrokerGroup group) { _brokerGroups.Add(group.Name, group); }