protected ProducerConsumerTestHarness() { this.port = Configs.First().Port; var props = TestUtils.GetProducerConfig( TestUtils.GetBrokerListFromConfigs(Configs), typeof(StaticPartitioner).AssemblyQualifiedName); this.Producer = new Producer<string, string>(props); this.Consumer = new SimpleConsumer(this.host, this.port, 1000000, 64 * 1024, string.Empty); }
public ProducerTest() { this.ports = TestUtils.ChoosePorts(2); this.port1 = this.ports[0]; this.port2 = this.ports[1]; this.config1 = TestUtils.CreateBrokerConfig( BrokerId1, this.port1, idx => new Dictionary<string, string> { { "num.partitons", "4" } }); this.config2 = TestUtils.CreateBrokerConfig( BrokerId2, this.port2, idx => new Dictionary<string, string> { { "num.partitons", "4" } }); this.server1 = this.StartServer(this.config1); this.server2 = this.StartServer(this.config2); this.servers = new List<Process> { this.server1, this.server2 }; this.consumer1 = new SimpleConsumer("localhost", this.port1, 1000000, 64 * 1024, string.Empty); this.consumer2 = new SimpleConsumer("localhost", this.port2, 100, 64 * 1024, string.Empty); this.WaitForServersToSettle(); }
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); }