eu.stratosphere.nephele.io.OutputGate Maven / Gradle / Ivy
/***********************************************************************************************************************
* Copyright (C) 2010-2013 by the Stratosphere project (http://stratosphere.eu)
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
**********************************************************************************************************************/
package eu.stratosphere.nephele.io;
import java.io.IOException;
import java.util.List;
import eu.stratosphere.core.io.IOReadableWritable;
import eu.stratosphere.nephele.io.channels.AbstractOutputChannel;
import eu.stratosphere.nephele.io.channels.ChannelID;
import eu.stratosphere.nephele.io.channels.bytebuffered.InMemoryOutputChannel;
import eu.stratosphere.nephele.io.channels.bytebuffered.NetworkOutputChannel;
/**
* In Nephele output gates are a specialization of general gates and connect
* record writers and output channels. As channels, output gates are always
* parameterized to a specific type of record which they can transport.
*
* @param
* the type of record that can be transported through this gate
*/
public interface OutputGate extends Gate {
/**
* Returns the type of record that can be transported through this gate.
*
* @return the type of record that can be transported through this gate
*/
Class getType();
/**
* Writes a record to one of the associated output channels. Currently, the
* channels are chosen in a simple round-robin fashion. This operation may
* block until the respective channel has received the data.
*
* @param record
* the record to be written
* @throws IOException
* thrown if any error occurs during channel I/O
*/
void writeRecord(T record) throws IOException, InterruptedException;
/**
* Returns all the OutputChannels connected to this gate
*
* @return the list of OutputChannels connected to this RecordWriter
*/
List> getOutputChannels();
/**
* Flushes all connected output channels.
*
* @throws IOException
* thrown if an error occurs while flushing an output channel
* @throws InterruptedException
* thrown if the thread is interrupted while waiting for the data to be flushed
*/
void flush() throws IOException, InterruptedException;
/**
* Checks if this output gate operates in broadcast mode, i.e. all records passed to it are transferred through all
* connected output channels.
*
* @return true
if this output gate operates in broadcast mode, false
otherwise
*/
boolean isBroadcast();
/**
* Returns the number of output channels associated with this output gate.
*
* @return the number of output channels associated with this output gate
*/
int getNumberOfOutputChannels();
/**
* Returns the output channel from position pos
of the gate's
* internal channel list.
*
* @param pos
* the position to retrieve the channel from
* @return the channel from the given position or null
if such
* position does not exist.
*/
AbstractOutputChannel getOutputChannel(int pos);
/**
* Returns the output gate's channel selector.
*
* @return the output gate's channel selector or null
if the gate operates in broadcast mode
*/
ChannelSelector getChannelSelector();
/**
* Requests the output gate to closed. This means the application will send
* no records through this gate anymore.
*
* @throws IOException
* @throws InterruptedException
*/
void requestClose() throws IOException, InterruptedException;
/**
* Removes all output channels from the output gate.
*/
void removeAllOutputChannels();
/**
* Creates a new network output channel and assigns it to the given output gate.
*
* @param outputGate
* the output gate the channel shall be assigned to
* @param channelID
* the ID of the channel
* @param connectedChannelID
* the ID of the channel this channel is connected to
* @param compressionLevel
* the level of compression to be used for this channel
* @return the new network output channel
*/
NetworkOutputChannel createNetworkOutputChannel(OutputGate outputGate, ChannelID channelID,
ChannelID connectedChannelID);
/**
* Creates a new in-memory output channel and assigns it to the given output gate.
*
* @param outputGate
* the output gate the channel shall be assigned to
* @param channelID
* the ID of the channel
* @param connectedChannelID
* the ID of the channel this channel is connected to
* @param compressionLevel
* the level of compression to be used for this channel
* @return the new in-memory output channel
*/
InMemoryOutputChannel createInMemoryOutputChannel(OutputGate outputGate, ChannelID channelID,
ChannelID connectedChannelID);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy