org.apache.flume.channel
Class MemoryChannel

java.lang.Object
  extended by org.apache.flume.channel.MemoryChannel
All Implemented Interfaces:
Channel, Configurable

public class MemoryChannel
extends Object
implements Channel, Configurable

Memory channel that with full transaction support Uses transaction object for each thread (source and sink) attached to channel. The events are stored in the thread safe Dequeue. * The put and take are directly executed in the common queue. Channel has a marker for the last committed event in order to avoid sink reading uncommitted data. The transactions keep track of the actions to perform undo when rolled back.


Nested Class Summary
 class MemoryChannel.MemTransaction
           
 
Constructor Summary
MemoryChannel()
          Channel constructor
 
Method Summary
 void configure(Context context)
          set the event queue capacity
protected  MemoryChannel.MemTransaction findTransaction()
           
protected  void forgetTransaction(MemoryChannel.MemTransaction myTxn)
          Remove the given transaction from the list of open transactions
 String getName()
           
 Transaction getTransaction()
           
 void put(Event event)
          Puts the given event in the channel.
 void shutdown()
          Instructs the channel to release any resources held in preparation of shutting down.
 Event take()
          Returns the next event from the channel if available.
protected  void undoPut(MemoryChannel.MemTransaction myTxn)
          undo of put for all the events in the undoPut queue, remove those from the event queue
protected  void undoTake(MemoryChannel.MemTransaction myTxn)
          undo of take operation for each event in the undoTake list, add it back to the event queue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryChannel

public MemoryChannel()
Channel constructor

Method Detail

configure

public void configure(Context context)
set the event queue capacity

Specified by:
configure in interface Configurable

put

public void put(Event event)
Description copied from interface: Channel

Puts the given event in the channel.

Note: This method must be invoked within an active Transaction boundary. Failure to do so can lead to unpredictable results.

Specified by:
put in interface Channel
Parameters:
event - the event to transport.
See Also:
Transaction.begin()

undoPut

protected void undoPut(MemoryChannel.MemTransaction myTxn)
undo of put for all the events in the undoPut queue, remove those from the event queue

Parameters:
myTxn -

take

public Event take()
Description copied from interface: Channel

Returns the next event from the channel if available. If the channel does not have any events available, this method would return null.

Note: This method must be invoked within an active Transaction boundary. Failure to do so can lead to unpredictable results.

Specified by:
take in interface Channel
Returns:
the next available event or null if no events are available.
See Also:
Transaction.begin()

undoTake

protected void undoTake(MemoryChannel.MemTransaction myTxn)
undo of take operation for each event in the undoTake list, add it back to the event queue

Parameters:
myTxn -

getTransaction

public Transaction getTransaction()
Specified by:
getTransaction in interface Channel
Returns:
the transaction instance associated with this channel.

forgetTransaction

protected void forgetTransaction(MemoryChannel.MemTransaction myTxn)
Remove the given transaction from the list of open transactions

Parameters:
myTxn -

findTransaction

protected MemoryChannel.MemTransaction findTransaction()

shutdown

public void shutdown()
Description copied from interface: Channel
Instructs the channel to release any resources held in preparation of shutting down.

Specified by:
shutdown in interface Channel

getName

public String getName()
Specified by:
getName in interface Channel
Returns:
the channel name.


Copyright © 2009-2012 Apache Software Foundation. All Rights Reserved.