Java Code Examples for org.apache.samza.system.SystemStreamPartition#getStream()

The following examples show how to use org.apache.samza.system.SystemStreamPartition#getStream() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HdfsSystemConsumer.java    From samza with Apache License 2.0 5 votes vote down vote up
private List<String> getPartitionDescriptor(SystemStreamPartition systemStreamPartition) {
  String streamName = systemStreamPartition.getStream();
  Partition partition = systemStreamPartition.getPartition();
  try {
    return cachedPartitionDescriptorMap.get(streamName).get(partition);
  } catch (ExecutionException e) {
    throw new SamzaException("Failed to obtain descriptor for " + systemStreamPartition, e);
  }
}
 
Example 2
Source File: KafkaSystemAdmin.java    From samza with Apache License 2.0 5 votes vote down vote up
/**
 * Converts the {@link SystemStreamPartition} to {@link TopicPartition}.
 * @param systemStreamPartition the input system stream partition.
 * @return the converted topic partition.
 */
static TopicPartition toTopicPartition(SystemStreamPartition systemStreamPartition) {
  Preconditions.checkNotNull(systemStreamPartition);
  Preconditions.checkNotNull(systemStreamPartition.getPartition());
  Preconditions.checkNotNull(systemStreamPartition.getStream());

  return new TopicPartition(systemStreamPartition.getStream(), systemStreamPartition.getPartition().getPartitionId());
}
 
Example 3
Source File: KafkaConsumerProxy.java    From samza with Apache License 2.0 5 votes vote down vote up
private void refreshLagMetrics() {
  for (Map.Entry<SystemStreamPartition, Long> e : nextOffsets.entrySet()) {
    SystemStreamPartition ssp = e.getKey();
    Long offset = e.getValue();
    TopicAndPartition tp = new TopicAndPartition(ssp.getStream(), ssp.getPartition().getPartitionId());
    Long lag = latestLags.get(ssp);
    LOG.trace("Latest offset of {} is  {}; lag = {}", ssp, offset, lag);
    if (lag != null && offset != null && lag >= 0) {
      long streamEndOffset = offset + lag;
      // update the metrics
      kafkaConsumerMetrics.setHighWatermarkValue(tp, streamEndOffset);
      kafkaConsumerMetrics.setLagValue(tp, lag);
    }
  }
}
 
Example 4
Source File: StartpointManager.java    From samza with Apache License 2.0 5 votes vote down vote up
private static String toReadWriteStoreKey(SystemStreamPartition ssp, TaskName taskName) {
  Preconditions.checkArgument(ssp != null, "SystemStreamPartition should be defined");
  Preconditions.checkArgument(StringUtils.isNotBlank(ssp.getSystem()), "System should be defined");
  Preconditions.checkArgument(StringUtils.isNotBlank(ssp.getStream()), "Stream should be defined");
  Preconditions.checkArgument(ssp.getPartition() != null, "Partition should be defined");

  String storeKey = ssp.getSystem() + "." + ssp.getStream() + "." + String.valueOf(ssp.getPartition().getPartitionId());
  if (taskName != null) {
    storeKey += "." + taskName.getTaskName();
  }
  return storeKey;
}
 
Example 5
Source File: KinesisSystemConsumer.java    From samza with Apache License 2.0 5 votes vote down vote up
@Override
public void register(SystemStreamPartition ssp, String offset) {
  LOG.info("Register called with ssp {} and offset {}. Offset will be ignored.", ssp, offset);
  String stream = ssp.getStream();
  streams.add(stream);
  sspAllocator.free(ssp);
  super.register(ssp, offset);
}
 
Example 6
Source File: KafkaSystemConsumer.java    From samza with Apache License 2.0 4 votes vote down vote up
protected static TopicPartition toTopicPartition(SystemStreamPartition ssp) {
  return new TopicPartition(ssp.getStream(), ssp.getPartition().getPartitionId());
}
 
Example 7
Source File: SamzaObjectMapper.java    From samza with Apache License 2.0 4 votes vote down vote up
@Override
public void serialize(SystemStreamPartition ssp, JsonGenerator jgen, SerializerProvider provider) throws IOException {
  String sspString = ssp.getSystem() + "." + ssp.getStream() + "." + String.valueOf(ssp.getPartition().getPartitionId());
  jgen.writeFieldName(sspString);
}
 
Example 8
Source File: Partition.java    From samza with Apache License 2.0 4 votes vote down vote up
public Partition(SystemStreamPartition systemStreamPartition) {
  this(systemStreamPartition.getSystem(),
       systemStreamPartition.getStream(),
       systemStreamPartition.getPartition().getPartitionId());
}