org.apache.hadoop.chukwa
Class ChunkImpl

java.lang.Object
  extended by org.apache.hadoop.chukwa.ChunkImpl
All Implemented Interfaces:
Chunk, org.apache.hadoop.io.Writable

public class ChunkImpl
extends Object
implements org.apache.hadoop.io.Writable, Chunk


Field Summary
protected  DataFactory dataFactory
           
static int PROTOCOL_VERSION
           
 
Constructor Summary
ChunkImpl(String dataType, String streamName, long seq, byte[] data, Adaptor source)
           
 
Method Summary
 void addTag(String tags)
          Add tag.
 String getApplication()
           
static ChunkImpl getBlankChunk()
           
 byte[] getData()
           
 String getDataType()
           
 String getDebugInfo()
           
 Adaptor getInitiator()
          Retrieve a reference to the adaptor that sent this event.
 int getLength()
           
 int getProtocolVersion()
           
 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()
           
static ChunkImpl read(DataInput in)
           
 void readFields(DataInput in)
           
 void setApplication(String a)
           
 void setData(byte[] logEvent)
           
 void setDataType(String t)
           
 void setDebugInfo(String a)
           
static void setHostAddress(String host)
           
 void setInitiator(Adaptor a)
           
 void setLogSource()
           
 void setProtocolVersion(int pv)
           
 void setRecordOffsets(Collection<Integer> carriageReturns)
           
 void setRecordOffsets(int[] offsets)
           
 void setSeqID(long l)
           
 void setSource(String logSource)
           
 void setStreamName(String logApplication)
           
 String toString()
           
 void write(DataOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROTOCOL_VERSION

public static int PROTOCOL_VERSION

dataFactory

protected DataFactory dataFactory
Constructor Detail

ChunkImpl

public ChunkImpl(String dataType,
                 String streamName,
                 long seq,
                 byte[] data,
                 Adaptor source)
Method Detail

setHostAddress

public static void setHostAddress(String host)

getBlankChunk

public static ChunkImpl getBlankChunk()

getData

public byte[] getData()
Specified by:
getData in interface Chunk
Returns:
the user data in the chunk
See Also:
Chunk.getData()

setData

public void setData(byte[] logEvent)
Specified by:
setData in interface Chunk
Parameters:
logEvent - the user data in the chunk
See Also:
Chunk.setData(byte[])

getStreamName

public String getStreamName()
Description copied from interface: Chunk
Get the name of the stream that this Chunk is a chunk of

Specified by:
getStreamName in interface Chunk
Returns:
the name of this stream; e.g. file name
See Also:
Chunk.getStreamName()

setStreamName

public void setStreamName(String logApplication)
Specified by:
setStreamName in interface Chunk

getSource

public String getSource()
Specified by:
getSource in interface Chunk

setSource

public void setSource(String logSource)
Specified by:
setSource in interface Chunk

getDebugInfo

public String getDebugInfo()

setDebugInfo

public void setDebugInfo(String a)

getSeqID

public long getSeqID()
Specified by:
getSeqID in interface Chunk
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.
See Also:
Chunk.getSeqID()

setSeqID

public void setSeqID(long l)
Specified by:
setSeqID in interface Chunk

getProtocolVersion

public int getProtocolVersion()

setProtocolVersion

public void setProtocolVersion(int pv)

getApplication

public String getApplication()
Specified by:
getApplication in interface Chunk

setApplication

public void setApplication(String a)
Specified by:
setApplication in interface Chunk

getInitiator

public Adaptor getInitiator()
Description copied from interface: Chunk
Retrieve a reference to the adaptor that sent this event. Used by LocalAgent and Connectors to deliver acks to the appropriate place.

Specified by:
getInitiator in interface Chunk

setInitiator

public void setInitiator(Adaptor a)

setLogSource

public void setLogSource()

getRecordOffsets

public int[] getRecordOffsets()
Description copied from interface: Chunk
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.

Specified by:
getRecordOffsets in interface Chunk
Returns:
a list of record end offsets

setRecordOffsets

public void setRecordOffsets(int[] offsets)
Specified by:
setRecordOffsets in interface Chunk

getDataType

public String getDataType()
Specified by:
getDataType in interface Chunk

setDataType

public void setDataType(String t)
Specified by:
setDataType in interface Chunk

addTag

public void addTag(String tags)
Description copied from interface: Chunk
Add tag.

Specified by:
addTag in interface Chunk

getTags

public String getTags()
Specified by:
getTags in interface Chunk
Returns:
tags.
See Also:
Chunk.getTags()

getTag

public String getTag(String tagName)
Description copied from interface: Chunk
Returns the value of a single tag, assuming tags are of the form tagname="val"

Specified by:
getTag in interface Chunk
Parameters:
tagName - the tag to return
Returns:
null if not matched.
See Also:
Chunk.getTag(java.lang.String)

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Throws:
IOException
See Also:
Writable.readFields(java.io.DataInput)

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface Chunk
Specified by:
write in interface org.apache.hadoop.io.Writable
Throws:
IOException
See Also:
Writable.write(java.io.DataOutput)

read

public static ChunkImpl read(DataInput in)
                      throws IOException
Throws:
IOException

toString

public String toString()
Overrides:
toString in class Object

getSerializedSizeEstimate

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

Specified by:
getSerializedSizeEstimate in interface Chunk
Returns:
size in bytes that this Chunk might take once serialized.
See Also:
Chunk.getSerializedSizeEstimate()

setRecordOffsets

public void setRecordOffsets(Collection<Integer> carriageReturns)

getLength

public int getLength()


Copyright © ${year} The Apache Software Foundation