public final class StreamUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static Location |
createGenerationLocation(Location streamBaseLocation,
int generation)
Creates stream base location with the given generation.
|
static Location |
createPartitionLocation(Location baseLocation,
long partitionStart,
long partitionDuration)
Creates the location for the partition directory.
|
static Location |
createStreamLocation(Location partitionLocation,
String prefix,
int seqId,
StreamFileType type)
Creates location for stream file.
|
static StreamFileOffset |
decodeOffset(StreamConfig config,
DataInput in)
Decode a
StreamFileOffset encoded by the encodeOffset(DataOutput, StreamFileOffset)
method. |
static void |
encodeOffset(DataOutput out,
StreamFileOffset offset)
Encode a
StreamFileOffset instance. |
static StreamConfig |
ensureExists(StreamAdmin admin,
Id.Stream streamId) |
static long |
fetchStreamFilesSize(Location streamLocation)
Get the size of the data persisted for the stream under the given stream location.
|
static String |
getBucketName(String name)
Returns the name of the event bucket based on the file name.
|
static Location |
getDeletedLocation(Location streamRootLocation)
Returns the location of the stream deleted location.
|
static int |
getGeneration(Location streamLocation)
Finds the current generation if of a stream.
|
static int |
getGeneration(StreamConfig config)
Finds the current generation id of a stream.
|
static String |
getNamePrefix(String name)
Returns the file prefix based on the given file name.
|
static int |
getNextSequenceId(Location partitionLocation,
String filePrefix)
Finds the next sequence id for the given partition with the given file prefix.
|
static long |
getPartitionEndTime(String partitionName)
Gets the partition end time based on the name of the partition.
|
static String |
getPartitionName(Location eventLocation)
Finds the partition name from the given event file location.
|
static long |
getPartitionStartTime(long timestamp,
long partitionDuration)
Returns the aligned partition start time.
|
static long |
getPartitionStartTime(String partitionName)
Gets the partition start time based on the name of the partition.
|
static int |
getSequenceId(String name)
Returns the sequence number of the given file name.
|
static TableId |
getStateStoreTableId(Id.Namespace namespace)
Gets a TableId for stream consumer state stores within a given namespace.
|
static Id.Stream |
getStreamIdFromLocation(Location streamBaseLocation)
Gets a
Id.Stream given a stream's base directory. |
static boolean |
isPartition(String partitionName)
Returns true if it is valid partition name, false other.
|
static Iterable<Location> |
listAllStreams(Location streamRootLocation)
Lists all stream locations under the given root.
|
public static String getPartitionName(Location eventLocation)
eventLocation - Location to the event file.StreamInputFormatpublic static String getBucketName(String name)
name - Name of the file.StreamInputFormatpublic static String getNamePrefix(String name)
name - Name of the file.StreamInputFormatpublic static int getSequenceId(String name)
name - Name of the file.StreamInputFormatpublic static long getPartitionStartTime(String partitionName)
StreamInputFormatpublic static boolean isPartition(String partitionName)
[0-9]+.[0-9]+public static long getPartitionEndTime(String partitionName)
StreamInputFormatpublic static Location createGenerationLocation(Location streamBaseLocation, int generation) throws IOException
streamBaseLocation - the base directory for the streamgeneration - generation idIOExceptionStreamInputFormatpublic static Location createPartitionLocation(Location baseLocation, long partitionStart, long partitionDuration) throws IOException
baseLocation - Base location for partition directory.partitionStart - Partition start timestamp in milliseconds.partitionDuration - Partition duration in milliseconds.IOExceptionpublic static Location createStreamLocation(Location partitionLocation, String prefix, int seqId, StreamFileType type) throws IOException
partitionLocation - The partition directory location.prefix - File prefix.seqId - Sequence number of the file.type - Type of the stream file.IOExceptionfor naming convention.public static long getPartitionStartTime(long timestamp,
long partitionDuration)
timestamp - Timestamp in milliseconds.partitionDuration - Partition duration in milliseconds.public static void encodeOffset(DataOutput out, StreamFileOffset offset) throws IOException
StreamFileOffset instance.out - Output for encodingoffset - The offset object to encodeIOExceptionpublic static StreamFileOffset decodeOffset(StreamConfig config, DataInput in) throws IOException
StreamFileOffset encoded by the encodeOffset(DataOutput, StreamFileOffset)
method.config - Stream configuration for the stream that the offset is representingin - Input for decodingStreamFileOffsetIOExceptionpublic static StreamConfig ensureExists(StreamAdmin admin, Id.Stream streamId) throws IOException
IOExceptionpublic static int getGeneration(StreamConfig config) throws IOException
config - configuration of the streamIOExceptionpublic static int getGeneration(Location streamLocation) throws IOException
streamLocation - location to scan for generation idIOExceptionpublic static int getNextSequenceId(Location partitionLocation, String filePrefix) throws IOException
partitionLocation - the directory where the stream partition isfilePrefix - prefix of file name to matchIOException - if failed to find the next sequence idpublic static long fetchStreamFilesSize(Location streamLocation) throws IOException
streamLocation - stream to get data size ofstreamNameIOException - in case of any error in fetching the sizepublic static TableId getStateStoreTableId(Id.Namespace namespace)
namespace - the namespace for which the table is for.public static Id.Stream getStreamIdFromLocation(Location streamBaseLocation)
Id.Stream given a stream's base directory.streamBaseLocation - the location of the stream's directorypublic static Location getDeletedLocation(Location streamRootLocation) throws IOException
streamRootLocation - the root location that all streams go underIOExceptionpublic static Iterable<Location> listAllStreams(Location streamRootLocation) throws IOException
streamRootLocation - the root location that all streams go underIOExceptionCopyright © 2016 Cask Data, Inc. Licensed under the Apache License, Version 2.0.