コード例 #1
0
ファイル: ConsumerConnector.cs プロジェクト: paralect/brod
 public ConsumerConnector(String stateStorageDirectory, String brokerAddress, BrokerInfoResponse configuration, ZMQ.Context context)
 {
     _stateStorageDirectory = stateStorageDirectory;
     _brokerAddress = brokerAddress;
     _configuration = configuration;
     _context = context;
 }
コード例 #2
0
 public ConsumerMessageStream(String stateStorageDirectory, String brokerAddress, BrokerInfoResponse configuration, ZMQ.Context context)
 {
     _stateStorageDirectory = stateStorageDirectory;
     _brokerAddress = brokerAddress;
     _configuration = configuration;
     _context = context;
     Messages = new ConcurrentQueue<Tuple<Int32, Message>>();
 }
コード例 #3
0
ファイル: Consumer.cs プロジェクト: paralect/brod
        public Consumer(String brokerAddress)
        {
            _context = _sharedContext;
            _address = brokerAddress;

            _sender = new RequestSender(_address, ZMQ.SocketType.REQ, _context.ZmqContext);
            _infoResponse = _sender.Send(new BrokerInfoRequest()) as BrokerInfoResponse;

            if (_infoResponse == null)
                throw new Exception("Cannot create producer, because broker info request was unsuccessfull");
        }
コード例 #4
0
ファイル: Producer.cs プロジェクト: paralect/brod
        /// <summary>
        /// Constructs Producer with specified broker address
        /// </summary>
        public Producer(String brokerAddress)
        {
            _brokerAddress = brokerAddress;
            _sender = new RequestSender(_brokerAddress, ZMQ.SocketType.REQ, _context.ZmqContext);
            _infoResponse = _sender.Send(new BrokerInfoRequest()) as BrokerInfoResponse;

            if (_infoResponse == null)
                throw new Exception("Cannot create producer, because broker info request was unsuccessfull");

            var pullAddress = String.Format("{0}:{1}", _infoResponse.HostName, _infoResponse.PullPort);
            _pushSender = new RequestSender(pullAddress, ZMQ.SocketType.PUSH, _context.ZmqContext);
        }
コード例 #5
0
ファイル: RequestHandlers.cs プロジェクト: paralect/brod
        public Response HandleBrokerInfo(BinaryStream stream)
        {
            // Not used for now
            var request = BrokerInfoRequest.ReadFromStream(stream);

            var response = new BrokerInfoResponse();
            response.HostName = _configuration.HostName;
            response.BrokerId = _configuration.BrokerId;
            response.PullPort = _configuration.PullPort;
            response.NumberOfPartitions = _configuration.NumberOfPartitions;
            response.NumberOfPartitionsPerTopic = _configuration.NumberOfPartitionsPerTopic;

            return response;
        }
コード例 #6
0
ファイル: BrokerInfoResponse.cs プロジェクト: paralect/brod
        public static BrokerInfoResponse ReadFromStream(BinaryStream stream)
        {
            var request = new BrokerInfoResponse();
            request.HostName = stream.Reader.ReadString();
            request.BrokerId = stream.Reader.ReadInt32();
            request.PullPort = stream.Reader.ReadInt32();
            request.NumberOfPartitions = stream.Reader.ReadInt32();

            // Reading dictionary of <String, Int32>
            var length = stream.Reader.ReadInt32();
            for (int i = 0; i < length; i++)
            {
                var topic = stream.Reader.ReadString();
                var partitionsNumber = stream.Reader.ReadInt32();
                request.NumberOfPartitionsPerTopic.Add(topic, partitionsNumber);
            }

            return request;
        }
コード例 #7
0
ファイル: BrokerInfoResponse.cs プロジェクト: paralect/brod
        public static BrokerInfoResponse ReadFromStream(BinaryStream stream)
        {
            var request = new BrokerInfoResponse();

            request.HostName           = stream.Reader.ReadString();
            request.BrokerId           = stream.Reader.ReadInt32();
            request.PullPort           = stream.Reader.ReadInt32();
            request.NumberOfPartitions = stream.Reader.ReadInt32();

            // Reading dictionary of <String, Int32>
            var length = stream.Reader.ReadInt32();

            for (int i = 0; i < length; i++)
            {
                var topic            = stream.Reader.ReadString();
                var partitionsNumber = stream.Reader.ReadInt32();
                request.NumberOfPartitionsPerTopic.Add(topic, partitionsNumber);
            }

            return(request);
        }