|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.klomp.snark.PartialPiece
class PartialPiece
Store the received data either on the heap or in a temp file. The third option, to write chunks directly to the destination file, is unimplemented. This is the class passed from PeerCoordinator to PeerState so PeerState may start requests. It is also passed from PeerState to PeerCoordinator when a piece is not completely downloaded, for example when the Peer disconnects or chokes. New objects for the same piece are created during the end game - this object should not be shared among multiple peers.
Constructor Summary | |
---|---|
PartialPiece(Piece piece,
int len,
File tempDir)
Used by PeerCoordinator. |
Method Summary | |
---|---|
int |
compareTo(Object o)
|
boolean |
equals(Object o)
Make this simple so PeerCoordinator can keep a List. |
int |
getDownloaded()
How many bytes are good - only valid by setDownloaded() |
byte[] |
getHash()
Piece must be complete. |
int |
getLength()
|
int |
getPiece()
piece number |
Request |
getRequest()
Convert this PartialPiece to a request for the next chunk. |
int |
hashCode()
|
void |
read(DataInputStream din,
int off,
int len)
Blocking. |
void |
release()
Release all resources. |
void |
setDownloaded(int offset)
Call this before returning a PartialPiece to the PeerCoordinator |
String |
toString()
|
void |
write(DataOutput out,
int offset,
int len)
Piece must be complete. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PartialPiece(Piece piece, int len, File tempDir)
piece
- Piece number requested.len
- must be equal to the piece lengthMethod Detail |
---|
public Request getRequest()
public int getPiece()
public int getLength()
public int getDownloaded()
public void setDownloaded(int offset)
public byte[] getHash() throws IOException
IOException
public void read(DataInputStream din, int off, int len) throws IOException
IOException
public void write(DataOutput out, int offset, int len) throws IOException
out
- stream to write tooffset
- offset in the piecelen
- length to write
IOException
public void release()
public int compareTo(Object o) throws ClassCastException
compareTo
in interface Comparable
ClassCastException
public int hashCode()
hashCode
in class Object
public boolean equals(Object o)
equals
in class Object
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |