@Override public MessageIterator get( final String topic, final Partition partition, final long offset, final int maxSize, final long timeout, final TimeUnit timeUnit) throws MetaClientException, InterruptedException { this.producerZooKeeper.publishTopic(topic); final Broker broker = new Broker(partition.getBrokerId(), this.producerZooKeeper.selectBroker(topic, partition)); final TopicPartitionRegInfo topicPartitionRegInfo = new TopicPartitionRegInfo(topic, partition, offset); return this.fetch( new FetchRequest(broker, 0, topicPartitionRegInfo, maxSize), timeout, timeUnit); }
@Override public DequeueResult dequeue( String topic, Partition partition, long offset, int maxSize, long timeout, TimeUnit timeUnit) throws MetaClientException, InterruptedException { this.producerZooKeeper.publishTopic(topic); String brokerUrl = this.producerZooKeeper.selectBroker(topic, partition); if (brokerUrl != null) { final Broker broker = new Broker(partition.getBrokerId(), brokerUrl); final TopicPartitionRegInfo topicPartitionRegInfo = new TopicPartitionRegInfo(topic, partition, offset); return this.fetchSync( new FetchRequest(broker, 0, topicPartitionRegInfo, maxSize), timeout, timeUnit); } else { log.warn( "the partiontion " + topic + " " + partition + " selectBroker failed, please retry."); } return new DequeueResult(DequeueStatus.STATUS_OTHER_ERROR, null, 0); }