Rice Pastry API

org.mpisws.p2p.filetransfer
Class TempFileAllocationStrategy

java.lang.Object
  extended by org.mpisws.p2p.filetransfer.TempFileAllocationStrategy
All Implemented Interfaces:
FileAllocationStrategy

public class TempFileAllocationStrategy
extends java.lang.Object
implements FileAllocationStrategy

Just creates a temp file, ignoring the filename/size. Does not delete on exit, as this is not memory safe.

Author:
Jeff Hoye

Field Summary
protected  java.io.File dir
           
protected  java.lang.String prefix
           
protected  java.lang.String suffix
           
 
Constructor Summary
TempFileAllocationStrategy()
           
TempFileAllocationStrategy(java.lang.String prefix, java.lang.String suffix)
           
TempFileAllocationStrategy(java.lang.String prefix, java.lang.String suffix, java.io.File directory)
           
 
Method Summary
 void fileCancelled(java.nio.ByteBuffer metadata, java.io.File f, long offset, long downloadedLength, long requestedLength, java.lang.Exception reason)
          Notification of a cancelled transfer.
 java.io.File getFile(java.nio.ByteBuffer metadata, long offset, long length)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

prefix

protected java.lang.String prefix

suffix

protected java.lang.String suffix

dir

protected java.io.File dir
Constructor Detail

TempFileAllocationStrategy

public TempFileAllocationStrategy()

TempFileAllocationStrategy

public TempFileAllocationStrategy(java.lang.String prefix,
                                  java.lang.String suffix)

TempFileAllocationStrategy

public TempFileAllocationStrategy(java.lang.String prefix,
                                  java.lang.String suffix,
                                  java.io.File directory)
Method Detail

getFile

public java.io.File getFile(java.nio.ByteBuffer metadata,
                            long offset,
                            long length)
                     throws java.io.IOException
Specified by:
getFile in interface FileAllocationStrategy
Parameters:
metadata - application specific, often the file name
Returns:
Throws:
java.io.IOException

fileCancelled

public void fileCancelled(java.nio.ByteBuffer metadata,
                          java.io.File f,
                          long offset,
                          long downloadedLength,
                          long requestedLength,
                          java.lang.Exception reason)
Description copied from interface: FileAllocationStrategy
Notification of a cancelled transfer.

Specified by:
fileCancelled in interface FileAllocationStrategy
Parameters:
metadata - application specific, often the file name
f - the file that was given by this strategy before
offset - the beginning point in the file of this file transfer
downloadedLength - the actual "valid" downloaded length
requestedLength - the length of the original file transfer request

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection