org.apache.hadoop.chukwa
Interface Chunk

All Known Implementing Classes:
ChunkImpl

public interface Chunk

A chunk is a sequence of bytes at a particular logical offset in a stream, and containing one or more "records". Chunks have various metadata, such as source, format, and pointers to record boundaries within the chunk.


Method Summary
 void addTag(String tag)
          Add tag.
 byte[] getData()
           
 String getDataType()
           
 Adaptor getInitiator()
          Retrieve a reference to the adaptor that sent this event.
 int[] getRecordOffsets()
          get/set the end offsets of records in the buffer.
 long getSeqID()
           
 int getSerializedSizeEstimate()
          Estimate the size of this Chunk on the wire, assuming each char of metadata takes two bytes to serialize.
 String getSource()
           
 String getStreamName()
          Get the name of the stream that this Chunk is a chunk of
 String getTag(String tagName)
          Returns the value of a single tag, assuming tags are of the form tagname="val"
 String getTags()
           
 void setData(byte[] logEvent)
           
 void setDataType(String t)
           
 void setRecordOffsets(int[] offsets)
           
 void setSeqID(long l)
           
 void setSource(String logSource)
           
 void setStreamName(String streamName)
           
 void write(DataOutput data)
           
 

Method Detail

getSource

String getSource()

setSource

void setSource(String logSource)

getStreamName

String getStreamName()
Get the name of the stream that this Chunk is a chunk of

Returns:
the name of this stream; e.g. file name

setStreamName

void setStreamName(String streamName)

getDataType

String getDataType()

setDataType

void setDataType(String t)

getData

byte[] getData()
Returns:
the user data in the chunk

setData

void setData(byte[] logEvent)
Parameters:
logEvent - the user data in the chunk

getRecordOffsets

int[] getRecordOffsets()
get/set the end offsets of records in the buffer. We use end, rather than start offsets, since the first start offset is always 0, but the last end offset specifies how much of the buffer is valid. More precisely, offsets[i] is the offset in the Chunk of the last byte of record i in this chunk.

Returns:
a list of record end offsets

setRecordOffsets

void setRecordOffsets(int[] offsets)

getSeqID

long getSeqID()
Returns:
the byte offset of the first byte not in this chunk. We pick this convention so that subtracting sequence IDs yields length. Furthermore, seqID - length = first byte pos.

setSeqID

void setSeqID(long l)

getInitiator

Adaptor getInitiator()
Retrieve a reference to the adaptor that sent this event. Used by LocalAgent and Connectors to deliver acks to the appropriate place.


getSerializedSizeEstimate

int getSerializedSizeEstimate()
Estimate the size of this Chunk on the wire, assuming each char of metadata takes two bytes to serialize. This is pessimistic.

Returns:
size in bytes that this Chunk might take once serialized.

getTags

String getTags()
Returns:
tags.

addTag

void addTag(String tag)
Add tag.


getTag

String getTag(String tagName)
Returns the value of a single tag, assuming tags are of the form tagname="val"

Parameters:
tagName - the tag to return
Returns:
null if not matched.

write

void write(DataOutput data)
           throws IOException
Throws:
IOException


Copyright © ${year} The Apache Software Foundation