org.apache.flume.channel
Class BasicChannelSemantics

java.lang.Object
  extended by org.apache.flume.channel.AbstractChannel
      extended by org.apache.flume.channel.BasicChannelSemantics
All Implemented Interfaces:
Channel, Configurable, LifecycleAware, NamedComponent
Direct Known Subclasses:
FileChannel, MemoryChannel, RecoverableMemoryChannel

@InterfaceAudience.Public
@InterfaceStability.Stable
public abstract class BasicChannelSemantics
extends AbstractChannel

An implementation of basic Channel semantics, including the implied thread-local semantics of the Transaction class, which is required to extend BasicTransactionSemantics.


Constructor Summary
BasicChannelSemantics()
           
 
Method Summary
protected abstract  BasicTransactionSemantics createTransaction()
           Called to create new Transaction objects, which must extend BasicTransactionSemantics.
 Transaction getTransaction()
           Initializes the channel if it is not already, then checks to see if there is an open transaction for this thread, creating a new one via createTransaction if not.
protected  void initialize()
           Called upon first getTransaction() request, while synchronized on this Channel instance.
 void put(Event event)
           Ensures that a transaction exists for this thread and then delegates the put to the thread's BasicTransactionSemantics instance.
 Event take()
           Ensures that a transaction exists for this thread and then delegates the take to the thread's BasicTransactionSemantics instance.
 
Methods inherited from class org.apache.flume.channel.AbstractChannel
configure, getLifecycleState, getName, setName, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicChannelSemantics

public BasicChannelSemantics()
Method Detail

initialize

protected void initialize()

Called upon first getTransaction() request, while synchronized on this Channel instance. Use this method to delay the initializization resources until just before the first transaction begins.


createTransaction

protected abstract BasicTransactionSemantics createTransaction()

Called to create new Transaction objects, which must extend BasicTransactionSemantics. Each object is used for only one transaction, but is stored in a thread-local and retrieved by getTransaction for the duration of that transaction.


put

public void put(Event event)
         throws ChannelException

Ensures that a transaction exists for this thread and then delegates the put to the thread's BasicTransactionSemantics instance.

Parameters:
event - the event to transport.
Throws:
ChannelException - in case this operation fails.
See Also:
Transaction.begin()

take

public Event take()
           throws ChannelException

Ensures that a transaction exists for this thread and then delegates the take to the thread's BasicTransactionSemantics instance.

Returns:
the next available event or null if no events are available.
Throws:
ChannelException - in case this operation fails.
See Also:
Transaction.begin()

getTransaction

public Transaction getTransaction()

Initializes the channel if it is not already, then checks to see if there is an open transaction for this thread, creating a new one via createTransaction if not.

Returns:
the current Transaction object for the calling thread



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