All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.stratosphere.nephele.taskmanager.bufferprovider.BufferProvider Maven / Gradle / Ivy

There is a newer version: 0.5.2-hadoop2
Show newest version
/***********************************************************************************************************************
 * 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.taskmanager.bufferprovider;

import java.io.IOException;

import eu.stratosphere.nephele.io.channels.Buffer;

public interface BufferProvider {

	/**
	 * Requests an empty buffer with a minimum size of minimumSizeOfBuffer. The method returns
	 * immediately, even if the request could not be fulfilled. Note that minimumSizeOfBuffer must not
	 * exceed the value returned by the method getMaximumBufferSize().
	 * 
	 * @param minimumSizeOfBuffer
	 *        the minimum size of the requested read buffer in bytes
	 * @return the buffer with at least the requested size or null if no such buffer is currently available
	 * @throws IOException
	 *         thrown if an I/O error occurs while allocating the buffer
	 */
	Buffer requestEmptyBuffer(int minimumSizeOfBuffer) throws IOException;

	/**
	 * Requests an empty buffer with a minimum size of minimumSizeOfBuffer. The method blocks
	 * until the request can be fulfilled. Note that minimumSizeOfBuffer must not
	 * exceed the value returned by the method getMaximumBufferSize().
	 * 
	 * @param minimumSizeOfBuffer
	 *        the minimum size of the requested read buffer in bytes
	 * @return the buffer with at least the requested size
	 * @throws IOException
	 *         thrown if an I/O error occurs while allocating the buffer
	 * @throws InterruptedException
	 *         thrown if the thread waiting for the buffer is interrupted
	 */
	Buffer requestEmptyBufferBlocking(int minimumSizeOfBuffer) throws IOException,
			InterruptedException;

	/**
	 * Returns the maximum buffer size in bytes available at this buffer provider.
	 * 
	 * @return the maximum buffer size in bytes available at this buffer provider
	 */
	int getMaximumBufferSize();

	/**
	 * Returns if this buffer provider is shared between different entities (for examples tasks).
	 * 
	 * @return true if this buffer provider is shared, false otherwise
	 */
	boolean isShared();

	/**
	 * Reports an asynchronous event. Calling this method interrupts each blocking method of the buffer provider and
	 * allows the blocked thread to respond to the event.
	 */
	void reportAsynchronousEvent();

	/**
	 * Registers the given {@link BufferAvailabilityListener} with an empty buffer pool to receive a notification when
	 * at least one buffer has become available again. After the notification, the listener is automatically
	 * unregistered again.
	 * 
	 * @param bufferAvailabilityListener
	 *        the listener to be registered
	 * @return true if the registration has been successful or false if the registration
	 *         failed because the buffer pool has not been empty or has already been destroyed
	 */
	boolean registerBufferAvailabilityListener(BufferAvailabilityListener bufferAvailabilityListener);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy