T - The Type of the record that can be transported through the channel.public class InputChannel<T extends IOReadableWritable> extends Channel implements BufferProvider
BufferProvider.BufferAvailabilityRegistrationenvelopeDispatcher| Constructor and Description |
|---|
InputChannel(InputGate<T> inputGate,
int channelIndex,
ChannelID channelID,
ChannelID connectedChannelID,
ChannelType type)
Constructs an input channel with a given input gate associated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
destroy() |
int |
getBufferSize()
Returns the size of buffers (in bytes) available at this buffer provider.
|
ChannelType |
getChannelType() |
AbstractTaskEvent |
getCurrentEvent() |
InputGate<T> |
getInputGate()
Returns the input gate associated with the input channel.
|
JobID |
getJobID() |
BufferOrEvent |
getNextBufferOrEvent() |
boolean |
isClosed() |
boolean |
isInputChannel() |
void |
logQueuedEnvelopes() |
void |
notifyDataUnitConsumed()
Notify the channel that a data unit has been consumed.
|
void |
notifyGateThatInputIsAvailable() |
void |
queueEnvelope(Envelope envelope) |
InputChannelResult |
readRecord(T target) |
BufferProvider.BufferAvailabilityRegistration |
registerBufferAvailabilityListener(BufferAvailabilityListener listener)
Registers the given
BufferAvailabilityListener with an empty buffer pool. |
void |
releaseAllResources() |
void |
reportAsynchronousEvent()
Reports an asynchronous event and interrupts each blocking method of this buffer provider in order to allow the
blocked thread to respond to the event.
|
void |
reportIOException(IOException ioe) |
Buffer |
requestBuffer(int minBufferSize)
Requests a buffer with a minimum size of
minBufferSize. |
Buffer |
requestBufferBlocking(int minBufferSize)
Requests a buffer with a minimum size of
minBufferSize. |
void |
transferEvent(AbstractEvent event) |
void |
transferEventToOutputChannel(AbstractEvent event) |
getConnectedId, getID, getIndex, registerEnvelopeDispatcherpublic InputChannel(InputGate<T> inputGate, int channelIndex, ChannelID channelID, ChannelID connectedChannelID, ChannelType type)
inputGate - the input gate this channel is connected tochannelIndex - the index of the channel in the input gatechannelID - the ID of the channelconnectedChannelID - the ID of the channel this channel is connected topublic InputGate<T> getInputGate()
public boolean isInputChannel()
isInputChannel in class Channelpublic InputChannelResult readRecord(T target) throws IOException
IOExceptionpublic ChannelType getChannelType()
getChannelType in class Channelpublic boolean isClosed()
throws IOException
isClosed in class ChannelIOExceptionpublic void close()
throws IOException,
InterruptedException
IOExceptionInterruptedExceptionpublic void notifyGateThatInputIsAvailable()
public void transferEvent(AbstractEvent event) throws IOException, InterruptedException
transferEvent in class ChannelIOExceptionInterruptedExceptionpublic void reportIOException(IOException ioe)
public void releaseAllResources()
releaseAllResources in class Channelpublic void notifyDataUnitConsumed()
public AbstractTaskEvent getCurrentEvent()
public void queueEnvelope(Envelope envelope)
queueEnvelope in class Channelpublic void logQueuedEnvelopes()
public Buffer requestBuffer(int minBufferSize) throws IOException
BufferProviderminBufferSize. The method returns immediately, even if the
request could not be fulfilled.requestBuffer in interface BufferProviderminBufferSize - minimum size of the requested buffer (in bytes)null if no such buffer is currently availableIOExceptionpublic Buffer requestBufferBlocking(int minBufferSize) throws IOException, InterruptedException
BufferProviderminBufferSize. The method blocks until the request has
been fulfilled or BufferProvider.reportAsynchronousEvent() has been called.requestBufferBlocking in interface BufferProviderminBufferSize - minimum size of the requested buffer (in bytes)IOExceptionInterruptedExceptionpublic int getBufferSize()
BufferProvidergetBufferSize in interface BufferProviderpublic void reportAsynchronousEvent()
BufferProviderreportAsynchronousEvent in interface BufferProviderpublic BufferProvider.BufferAvailabilityRegistration registerBufferAvailabilityListener(BufferAvailabilityListener listener)
BufferProviderBufferAvailabilityListener with an empty buffer pool.
The registration only succeeds, if the buffer pool is empty and has not been destroyed yet.
The registered listener will receive a notification when at least one buffer has become available again. After the notification, the listener will be unregistered.
registerBufferAvailabilityListener in interface BufferProviderlistener - the listener to be registeredtrue if the registration has been successful; false if the registration
failed, because the buffer pool was not empty or has already been destroyedpublic BufferOrEvent getNextBufferOrEvent() throws IOException
IOExceptionpublic void transferEventToOutputChannel(AbstractEvent event) throws IOException, InterruptedException
IOExceptionInterruptedExceptionCopyright © 2014 The Apache Software Foundation. All rights reserved.