org.objectweb.proactive.core.filetransfer
Class FileBlock

java.lang.Object
  extended by org.objectweb.proactive.core.filetransfer.FileBlock
All Implemented Interfaces:
java.io.Serializable

public class FileBlock
extends java.lang.Object
implements java.io.Serializable

This class represents a fraction of a file. It is used to load file blocks from a file, to send them through the network, and later to store the file block on the remote machines.

Author:
ProActive Team 09/2005 (mleyton)
See Also:
Serialized Form

Field Summary
static int DEFAULT_BLOCK_SIZE
           
protected static org.apache.log4j.Logger logger
           
 
Constructor Summary
FileBlock()
          Empty ProActive constructor.
FileBlock(long offset)
           
FileBlock(long offset, int blockSize)
           
 
Method Summary
 int getBlockSize()
           
 java.lang.Exception getException()
           
 long getOffset()
           
 boolean hasException()
           
 void loadNextBlock(java.io.BufferedInputStream bis)
          Loads the FileBlock object with a block from the source file this block references.
 void saveCurrentBlock(java.io.BufferedOutputStream bos)
          Saves the current block into an output stream buffer.
 void setException(java.lang.Exception e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.apache.log4j.Logger logger

DEFAULT_BLOCK_SIZE

public static final int DEFAULT_BLOCK_SIZE
See Also:
Constant Field Values
Constructor Detail

FileBlock

public FileBlock()
Empty ProActive constructor.


FileBlock

public FileBlock(long offset)

FileBlock

public FileBlock(long offset,
                 int blockSize)
Method Detail

loadNextBlock

public void loadNextBlock(java.io.BufferedInputStream bis)
                   throws java.io.IOException
Loads the FileBlock object with a block from the source file this block references. If the parameter is null, then it will create a new buffer from the parameters stored in the block instance. Note that creating a new block requires performing a skip (seek) on the stream, which is very slow. Therefore it is better to pass the buffered stream as parameter.

Throws:
java.io.IOException

saveCurrentBlock

public void saveCurrentBlock(java.io.BufferedOutputStream bos)
                      throws java.io.IOException
Saves the current block into an output stream buffer.

Parameters:
bos - The BufferedOutputStream to save the file
Throws:
java.io.IOException - If an error is encountered.

getOffset

public long getOffset()
Returns:
Returns the offset.

getBlockSize

public int getBlockSize()
Returns:
Returns the blockSize.

getException

public java.lang.Exception getException()

hasException

public boolean hasException()

setException

public void setException(java.lang.Exception e)


Copyright 2001-2007 INRIA All Rights Reserved.