org.apache.kafka.clients.consumer.Consumer.offsetsForTimes()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.3k)|赞(0)|评价(0)|浏览(291)

本文整理了Java中org.apache.kafka.clients.consumer.Consumer.offsetsForTimes()方法的一些代码示例,展示了Consumer.offsetsForTimes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Consumer.offsetsForTimes()方法的具体详情如下:
包路径:org.apache.kafka.clients.consumer.Consumer
类名称:Consumer
方法名:offsetsForTimes

Consumer.offsetsForTimes介绍

暂无

代码示例

代码示例来源:origin: openzipkin/brave

@Override public Map<TopicPartition, OffsetAndTimestamp> offsetsForTimes(
  Map<TopicPartition, Long> timestampsToSearch) {
 return delegate.offsetsForTimes(timestampsToSearch);
}

代码示例来源:origin: openzipkin/brave

public Map<TopicPartition, OffsetAndTimestamp> offsetsForTimes(
  Map<TopicPartition, Long> timestampsToSearch, Duration timeout) {
 return delegate.offsetsForTimes(timestampsToSearch, timeout);
}

代码示例来源:origin: linkedin/cruise-control

Map<TopicPartition, OffsetAndTimestamp> offsetsForTimes = _metricConsumer.offsetsForTimes(timestampToSeek);

代码示例来源:origin: org.apache.kafka/kafka_2.11

private void resetToDatetime(Consumer<byte[], byte[]> client, Set<TopicPartition> inputTopicPartitions, Long timestamp) {
  final Map<TopicPartition, Long> topicPartitionsAndTimes = new HashMap<>(inputTopicPartitions.size());
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    topicPartitionsAndTimes.put(topicPartition, timestamp);
  }
  final Map<TopicPartition, OffsetAndTimestamp> topicPartitionsAndOffset = client.offsetsForTimes(topicPartitionsAndTimes);
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    client.seek(topicPartition, topicPartitionsAndOffset.get(topicPartition).offset());
  }
}

代码示例来源:origin: org.apache.kafka/kafka_2.12

private void resetToDatetime(Consumer<byte[], byte[]> client, Set<TopicPartition> inputTopicPartitions, Long timestamp) {
  final Map<TopicPartition, Long> topicPartitionsAndTimes = new HashMap<>(inputTopicPartitions.size());
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    topicPartitionsAndTimes.put(topicPartition, timestamp);
  }
  final Map<TopicPartition, OffsetAndTimestamp> topicPartitionsAndOffset = client.offsetsForTimes(topicPartitionsAndTimes);
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    client.seek(topicPartition, topicPartitionsAndOffset.get(topicPartition).offset());
  }
}

代码示例来源:origin: org.apache.kafka/kafka

private void resetToDatetime(Consumer<byte[], byte[]> client, Set<TopicPartition> inputTopicPartitions, Long timestamp) {
  final Map<TopicPartition, Long> topicPartitionsAndTimes = new HashMap<>(inputTopicPartitions.size());
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    topicPartitionsAndTimes.put(topicPartition, timestamp);
  }
  final Map<TopicPartition, OffsetAndTimestamp> topicPartitionsAndOffset = client.offsetsForTimes(topicPartitionsAndTimes);
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    client.seek(topicPartition, topicPartitionsAndOffset.get(topicPartition).offset());
  }
}

代码示例来源:origin: org.apache.kafka/kafka_2.11

private void resetByDuration(Consumer<byte[], byte[]> client, Set<TopicPartition> inputTopicPartitions, Duration duration) throws DatatypeConfigurationException {
  final Date now = new Date();
  duration.negate().addTo(now);
  final long timestamp = now.getTime();
  final Map<TopicPartition, Long> topicPartitionsAndTimes = new HashMap<>(inputTopicPartitions.size());
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    topicPartitionsAndTimes.put(topicPartition, timestamp);
  }
  final Map<TopicPartition, OffsetAndTimestamp> topicPartitionsAndOffset = client.offsetsForTimes(topicPartitionsAndTimes);
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    client.seek(topicPartition, topicPartitionsAndOffset.get(topicPartition).offset());
  }
}

代码示例来源:origin: org.apache.kafka/kafka_2.12

private void resetByDuration(Consumer<byte[], byte[]> client, Set<TopicPartition> inputTopicPartitions, Duration duration) throws DatatypeConfigurationException {
  final Date now = new Date();
  duration.negate().addTo(now);
  final long timestamp = now.getTime();
  final Map<TopicPartition, Long> topicPartitionsAndTimes = new HashMap<>(inputTopicPartitions.size());
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    topicPartitionsAndTimes.put(topicPartition, timestamp);
  }
  final Map<TopicPartition, OffsetAndTimestamp> topicPartitionsAndOffset = client.offsetsForTimes(topicPartitionsAndTimes);
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    client.seek(topicPartition, topicPartitionsAndOffset.get(topicPartition).offset());
  }
}

代码示例来源:origin: org.apache.kafka/kafka

private void resetByDuration(Consumer<byte[], byte[]> client, Set<TopicPartition> inputTopicPartitions, Duration duration) throws DatatypeConfigurationException {
  final Date now = new Date();
  duration.negate().addTo(now);
  final long timestamp = now.getTime();
  final Map<TopicPartition, Long> topicPartitionsAndTimes = new HashMap<>(inputTopicPartitions.size());
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    topicPartitionsAndTimes.put(topicPartition, timestamp);
  }
  final Map<TopicPartition, OffsetAndTimestamp> topicPartitionsAndOffset = client.offsetsForTimes(topicPartitionsAndTimes);
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    client.seek(topicPartition, topicPartitionsAndOffset.get(topicPartition).offset());
  }
}

代码示例来源:origin: opentracing-contrib/java-kafka-client

@Override
public Map<TopicPartition, OffsetAndTimestamp> offsetsForTimes(Map<TopicPartition, Long> map,
  Duration duration) {
 return consumer.offsetsForTimes(map, duration);
}

代码示例来源:origin: opentracing-contrib/java-kafka-client

@Override
public Map<TopicPartition, OffsetAndTimestamp> offsetsForTimes(
  Map<TopicPartition, Long> timestampsToSearch) {
 return consumer.offsetsForTimes(timestampsToSearch);
}

代码示例来源:origin: io.opentracing.contrib/opentracing-kafka-client

@Override
public Map<TopicPartition, OffsetAndTimestamp> offsetsForTimes(Map<TopicPartition, Long> map,
  Duration duration) {
 return consumer.offsetsForTimes(map, duration);
}

代码示例来源:origin: io.opentracing.contrib/opentracing-kafka-client

@Override
public Map<TopicPartition, OffsetAndTimestamp> offsetsForTimes(
  Map<TopicPartition, Long> timestampsToSearch) {
 return consumer.offsetsForTimes(timestampsToSearch);
}

代码示例来源:origin: linkedin/li-apache-kafka-clients

@Override
public Map<TopicPartition, OffsetAndTimestamp> offsetsForTimes(Map<TopicPartition, Long> timestampsToSearch, Duration timeout) {
 return _kafkaConsumer.offsetsForTimes(timestampsToSearch, timeout);
}

代码示例来源:origin: io.zipkin.brave/brave-instrumentation-kafka-clients

public Map<TopicPartition, OffsetAndTimestamp> offsetsForTimes(
  Map<TopicPartition, Long> timestampsToSearch, Duration timeout) {
 return delegate.offsetsForTimes(timestampsToSearch, timeout);
}

代码示例来源:origin: io.zipkin.brave/brave-instrumentation-kafka-clients

@Override public Map<TopicPartition, OffsetAndTimestamp> offsetsForTimes(
  Map<TopicPartition, Long> timestampsToSearch) {
 return delegate.offsetsForTimes(timestampsToSearch);
}

代码示例来源:origin: vert-x3/vertx-kafka-client

@Override
public void offsetsForTimes(TopicPartition topicPartition, long timestamp, Handler<AsyncResult<OffsetAndTimestamp>> handler) {
 this.submitTask((consumer, future) -> {
  Map<TopicPartition, Long> input = new HashMap<>();
  input.put(topicPartition, timestamp);
  Map<TopicPartition, OffsetAndTimestamp> offsetsForTimes = this.consumer.offsetsForTimes(input);
  if (future != null) {
   future.complete(offsetsForTimes.get(topicPartition));
  }
 }, handler);
}

代码示例来源:origin: vert-x3/vertx-kafka-client

@Override
public void offsetsForTimes(Map<TopicPartition, Long> topicPartitionTimestamps, Handler<AsyncResult<Map<TopicPartition, OffsetAndTimestamp>>> handler) {
 this.submitTask((consumer, future) -> {
  Map<TopicPartition, OffsetAndTimestamp> offsetsForTimes = this.consumer.offsetsForTimes(topicPartitionTimestamps);
  if (future != null) {
   future.complete(offsetsForTimes);
  }
 }, handler);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.kafka_2.11

private void resetToDatetime(Consumer<byte[], byte[]> client, Set<TopicPartition> inputTopicPartitions, Long timestamp) {
  final Map<TopicPartition, Long> topicPartitionsAndTimes = new HashMap<>(inputTopicPartitions.size());
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    topicPartitionsAndTimes.put(topicPartition, timestamp);
  }
  final Map<TopicPartition, OffsetAndTimestamp> topicPartitionsAndOffset = client.offsetsForTimes(topicPartitionsAndTimes);
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    client.seek(topicPartition, topicPartitionsAndOffset.get(topicPartition).offset());
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.kafka_2.11

private void resetByDuration(Consumer<byte[], byte[]> client, Set<TopicPartition> inputTopicPartitions, Duration duration) throws DatatypeConfigurationException {
  final Date now = new Date();
  duration.negate().addTo(now);
  final long timestamp = now.getTime();
  final Map<TopicPartition, Long> topicPartitionsAndTimes = new HashMap<>(inputTopicPartitions.size());
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    topicPartitionsAndTimes.put(topicPartition, timestamp);
  }
  final Map<TopicPartition, OffsetAndTimestamp> topicPartitionsAndOffset = client.offsetsForTimes(topicPartitionsAndTimes);
  for (final TopicPartition topicPartition : inputTopicPartitions) {
    client.seek(topicPartition, topicPartitionsAndOffset.get(topicPartition).offset());
  }
}

相关文章