/** * This method is deprecated in favor of WatermarkManager.buildEndOfStreamEnvelope(SystemStreamPartition ssp). * * @param ssp The SSP that is at end-of-stream. * @return an IncomingMessageEnvelope corresponding to end-of-stream for that SSP. */ public static IncomingMessageEnvelope buildEndOfStreamEnvelope(SystemStreamPartition ssp) { return new IncomingMessageEnvelope(ssp, END_OF_STREAM_OFFSET, null, new EndOfStreamMessage(null)); }
public static IncomingMessageEnvelope buildWatermarkEnvelope(SystemStreamPartition ssp, long watermark) { return new IncomingMessageEnvelope(ssp, null, null, new WatermarkMessage(watermark, null)); }
/** * Copies this StreamSpec, but applies a new partitionCount. * * This method is not static s.t. subclasses can override it. * * @param partitionCount The partitionCount for the returned StreamSpec. * @return A copy of this StreamSpec with the specified partitionCount. */ public StreamSpec copyWithPartitionCount(int partitionCount) { return new StreamSpec(id, physicalName, systemName, partitionCount, config); }
/** * Constructs a Samza stream partition object based upon an existing Samza stream partition. * @param other Reference to an already existing Samza stream partition. */ public SystemStreamPartition(SystemStreamPartition other) { this(other.getSystem(), other.getStream(), other.getPartition()); }
@Override public boolean createStream(StreamSpec streamSpec) { createdStreamName = streamSpec.getPhysicalName(); return true; }
/** * Get partitions counts only. Should be more efficient then getSystemStreamMetadata, but if not implemented * revert to getSystemStreamMetadata. * @param streamNames set of streams to query. * @param cacheTTL cacheTTL to use if caching the values. * @return A map from stream name to SystemStreamMetadata for each stream * requested in the parameter set. */ default Map<String, SystemStreamMetadata> getSystemStreamPartitionCounts(Set<String> streamNames, long cacheTTL) { return getSystemStreamMetadata(streamNames); }
/** * Registers a source with the underlying SystemProducer. * * @param source * The source to register. */ public void register(String source) { systemProducer.register(source); }
/** * force the system producer to flush the messages */ private void flushSystemProducer() { if (systemProducer != null) { systemProducer.flush(SOURCE); } }
/** * Checks whether or not there are any messages after a given iterator on the coordinator stream * * @param iterator The iterator to check if there are any new messages after this point * @return True if there are new messages after the iterator, false otherwise */ public boolean hasNewMessages(SystemStreamPartitionIterator iterator) { if (iterator == null) { return false; } return iterator.hasNext(); }
/** * Gets an iterator on the coordinator stream, starting from the starting offset the consumer was registered with. * * @return an iterator on the coordinator stream pointing to the starting offset the consumer was registered with. */ public SystemStreamPartitionIterator getStartIterator() { return new SystemStreamPartitionIterator(systemConsumer, coordinatorSystemStreamPartition); }
/** * Constructs a Samza stream partition object from specified components. * @param system The name of the system of which this stream is associated with. * @param stream The name of the stream as specified in the stream configuration file. * @param partition The partition in the stream of which this object is associated with. */ public SystemStreamPartition(String system, String stream, Partition partition) { super(system, stream); this.partition = partition; this.hash = computeHashCode(); }
/** * Returns the period separated system stream name for the provided {@code systemStream}. For * example, SystemStream("kafka", "topic") would return "kafka.topic". * * @param systemStream the {@link SystemStream} to get the name for * @return the system stream name */ public static String getNameFromSystemStream(SystemStream systemStream) { return systemStream.getSystem() + "." + systemStream.getStream(); }
/** * This method is deprecated in favor of WatermarkManager.buildEndOfStreamEnvelope(SystemStreamPartition ssp). * * @param ssp The SSP that is at end-of-stream. * @return an IncomingMessageEnvelope corresponding to end-of-stream for that SSP. */ public static IncomingMessageEnvelope buildEndOfStreamEnvelope(SystemStreamPartition ssp) { return new IncomingMessageEnvelope(ssp, END_OF_STREAM_OFFSET, null, new EndOfStreamMessage(null)); }
@Override public boolean createStream(StreamSpec streamSpec) { createdStreamName = streamSpec.getPhysicalName(); return true; }