T - The type of record that can be transported through this gate.public class InputGate<T extends IOReadableWritable> extends Gate<T> implements BufferProvider, LocalBufferPoolOwner
DistributionPattern object which dictates the concrete
wiring between two groups of vertices.BufferProvider.BufferAvailabilityRegistration| Constructor and Description |
|---|
InputGate(JobID jobID,
GateID gateID,
int index)
Constructs a new runtime input gate.
|
| Modifier and Type | Method and Description |
|---|---|
InputChannel<T>[] |
channels() |
void |
clearLocalBufferPool()
Clears the local buffer pool and returns all buffers to the global buffer pool.
|
void |
close()
Immediately closes the input gate and all its input channels.
|
int |
getBufferSize()
Returns the size of buffers (in bytes) available at this buffer provider.
|
AbstractTaskEvent |
getCurrentEvent() |
InputChannel<T> |
getInputChannel(int pos)
Returns the input channel from position
pos of the gate's internal channel list. |
int |
getNumberOfChannels()
Returns the number of byte-buffered channels that will retrieve their buffers from the local buffer pool.
|
int |
getNumberOfInputChannels()
Returns the number of input channels associated with this input gate.
|
void |
initializeChannels(GateDeploymentDescriptor inputGateDescriptor) |
boolean |
isClosed()
Checks if the gate is closed.
|
boolean |
isInputGate()
Checks if the considered gate is an input gate.
|
void |
logBufferUtilization()
Logs the current status of the local buffer pool.
|
void |
notifyDataUnitConsumed(int channelIndex)
Notify the gate that is has consumed a data unit from the channel with the given index
|
void |
notifyRecordIsAvailable(int channelIndex)
Notify the gate that the channel with the given index has
at least one record available.
|
void |
publishEvent(AbstractEvent event)
Publishes an event.
|
InputChannelResult |
readRecord(T target)
Reads a record from one of the associated input channels.
|
BufferProvider.BufferAvailabilityRegistration |
registerBufferAvailabilityListener(BufferAvailabilityListener listener)
Registers the given
BufferAvailabilityListener with an empty buffer pool. |
void |
registerGlobalBufferPool(GlobalBufferPool globalBufferPool) |
void |
registerRecordAvailabilityListener(RecordAvailabilityListener<T> listener)
Registers a
RecordAvailabilityListener with this input gate. |
void |
releaseAllChannelResources()
Releases the allocated resources (particularly buffer) of all channels attached to this gate.
|
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.
|
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 |
setDesignatedNumberOfBuffers(int numBuffers)
Sets the designated number of buffers the local buffer pool owner is allowed to fetch from the global buffer pool
and manage locally by means of the
LocalBufferPool. |
String |
toString() |
int |
waitForAnyChannelToBecomeAvailable()
This method returns the index of a channel which has at least
one record available.
|
deliverEvent, getChannelType, getEventNotificationManager, getGateID, getIndex, getJobID, setChannelType, subscribeToEvent, unsubscribeFromEventpublic InputGate(JobID jobID, GateID gateID, int index)
jobID - the ID of the job this input gate belongs togateID - the ID of the gateindex - the index assigned to this input gate at the Environment objectpublic void initializeChannels(GateDeploymentDescriptor inputGateDescriptor)
public boolean isInputGate()
GateisInputGate in class Gate<T extends IOReadableWritable>true if the considered gate is an input gate, false if it is an output gatepublic int getNumberOfInputChannels()
public InputChannel<T> getInputChannel(int pos)
pos of the gate's internal channel list.pos - the position to retrieve the channel fromnull if such position does not exist.public InputChannel<T>[] channels()
public InputChannelResult readRecord(T target) throws IOException, InterruptedException
target - The record object into which to construct the complete record.IOException - Thrown when an error occurred in the network stack relating to this channel.InterruptedException - Thrown, when the thread working on this channel is interrupted.public AbstractTaskEvent getCurrentEvent()
public void notifyRecordIsAvailable(int channelIndex)
channelIndex - the index of the channel which has at least one record availablepublic int waitForAnyChannelToBecomeAvailable()
throws InterruptedException
InterruptedExceptionpublic boolean isClosed()
throws IOException,
InterruptedException
GateisClosed in class Gate<T extends IOReadableWritable>true if the gate is closed, false otherwiseIOException - thrown if any error occurred while closing the gateInterruptedException - thrown if the gate is interrupted while waiting for this operation to completepublic void close()
throws IOException,
InterruptedException
IOException - thrown if an I/O error occurs while closing the gateInterruptedException - thrown if the thread is interrupted while waiting for the gate to be closedpublic String toString()
toString in class Gate<T extends IOReadableWritable>public void publishEvent(AbstractEvent event) throws IOException, InterruptedException
GatepublishEvent in class Gate<T extends IOReadableWritable>event - the event to be publishedIOException - thrown if an error occurs while transmitting the eventInterruptedException - thrown if the thread is interrupted while waiting for the event to be publishedpublic void releaseAllChannelResources()
GatereleaseAllChannelResources in class Gate<T extends IOReadableWritable>public void registerRecordAvailabilityListener(RecordAvailabilityListener<T> listener)
RecordAvailabilityListener with this input gate.listener - the listener object to be registeredpublic void notifyDataUnitConsumed(int channelIndex)
channelIndex - the index of the channel from which a data unit has been consumedpublic 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 int getNumberOfChannels()
LocalBufferPoolOwnergetNumberOfChannels in interface LocalBufferPoolOwnerpublic void setDesignatedNumberOfBuffers(int numBuffers)
LocalBufferPoolOwnerLocalBufferPool.setDesignatedNumberOfBuffers in interface LocalBufferPoolOwnernumBuffers - the numBuffers the local buffer pool owner is allowed to fetch from the global buffer poolpublic void clearLocalBufferPool()
LocalBufferPoolOwnerclearLocalBufferPool in interface LocalBufferPoolOwnerpublic void registerGlobalBufferPool(GlobalBufferPool globalBufferPool)
registerGlobalBufferPool in interface LocalBufferPoolOwnerpublic void logBufferUtilization()
LocalBufferPoolOwnerlogBufferUtilization in interface LocalBufferPoolOwnerpublic void reportAsynchronousEvent()
BufferProviderreportAsynchronousEvent in interface BufferProviderreportAsynchronousEvent in interface LocalBufferPoolOwnerpublic 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 destroyedCopyright © 2015 The Apache Software Foundation. All rights reserved.