예제 #1
0
 public override AbstractFetcherThread CreateFetcherThread(int fetcherId, Broker sourceBroker)
 {
     return
         new ConsumerFetcherThread(
             string.Format("ConsumerFetcherThread-{0}-{1}-{2}", this.consumerIdString, fetcherId, sourceBroker.Id),
             this.config,
             sourceBroker,
             this.partitionMap,
             this);
 }
예제 #2
0
        public PartitionMetadata(int partitionId, Broker leader, IEnumerable<Broker> replicas, IEnumerable<Broker> isr = null, short errorCode = ErrorMapping.NoError)
        {
            if (isr == null)
            {
                isr = Enumerable.Empty<Broker>();
            }

            this.PartitionId = partitionId;
            this.Leader = leader;
            this.Replicas = replicas;
            this.Isr = isr;
            this.ErrorCode = errorCode;
        }
예제 #3
0
        public ConsumerFetcherThread(
            string name,
            ConsumerConfig config,
            Broker sourceBroker,
            IDictionary<TopicAndPartition, PartitionTopicInfo> partitionMap,
            ConsumerFetcherManager consumerFetcherManager) : base(
            name, 
            config.ClientId + "-" + name, 
            sourceBroker, 
            config.SocketTimeoutMs,
            config.SocketReceiveBufferBytes, 
            config.FetchMessageMaxBytes, 
            Request.OrdinaryConsumerId,
            config.FetchWaitMaxMs,
            config.FetchMinBytes, 
            true)

        {
            this.partitionMap = partitionMap;
            this.config = config;
            this.consumerFetcherManager = consumerFetcherManager;
        }
예제 #4
0
        internal AbstractFetcherThread(
            string name,
            string clientId,
            Broker sourceBroker,
            int socketTimeout,
            int socketBufferSize,
            int fetchSize,
            int fetcherBrokerId = -1,
            int maxWait = 0,
            int minBytes = 1,
            bool isInterruptible = true)
            : base(name, isInterruptible)
        {
            this.clientId = clientId;
            this.sourceBroker = sourceBroker;
            this.socketTimeout = socketTimeout;
            this.socketBufferSize = socketBufferSize;
            this.fetchSize = fetchSize;
            this.fetcherBrokerId = fetcherBrokerId;
            this.maxWait = maxWait;
            this.minBytes = minBytes;

            this.partitionMapLock = new ReentrantLock();
            this.partitionMapCond = this.partitionMapLock.NewCondition();
            this.simpleConsumer = new SimpleConsumer(
                sourceBroker.Host, sourceBroker.Port, socketTimeout, socketBufferSize, clientId);
            this.brokerInfo = string.Format("host_{0}-port_{1}", sourceBroker.Host, sourceBroker.Port);

            this.metricId = new ClientIdAndBroker(clientId, this.brokerInfo);

            this.FetcherStats = new FetcherStats(this.metricId);
            this.FetcherLagStats = new FetcherLagStats(this.metricId);
            this.fetchRequestBuilder =
                new FetchRequestBuilder().ClientId(clientId)
                                         .ReplicaId(fetcherBrokerId)
                                         .MaxWait(maxWait)
                                         .MinBytes(minBytes);
        }
예제 #5
0
 public static SyncProducer CreateSyncProducer(ProducerConfig config, Broker broker)
 {
     return new SyncProducer(new SyncProducerConfig(config, broker.Host, broker.Port));
 }
예제 #6
0
 protected bool Equals(Broker other)
 {
     return this.Id == other.Id && string.Equals(this.Host, other.Host) && this.Port == other.Port;
 }
예제 #7
0
 private string FormatBroker(Broker broker)
 {
     return string.Format("{0} ({1}:{2})", broker.Id, broker.Host, broker.Port);
 }
예제 #8
0
 // to be defined in subclass to create a specific fetcher
 public abstract AbstractFetcherThread CreateFetcherThread(int fetcherId, Broker sourceBroker);
예제 #9
0
 public BrokerAndInitialOffset(Broker broker, long initOffset)
 {
     this.Broker = broker;
     this.InitOffset = initOffset;
 }
예제 #10
0
 public BrokerAndFetcherId(Broker broker, int fetcherId)
 {
     this.Broker = broker;
     this.FetcherId = fetcherId;
 }
예제 #11
0
 public void Add(Broker broker)
 {
     this.brokers[broker.Id] = broker;
 }