57 |
* If <code>listener</code> is given, it is informed when |
* If <code>listener</code> is given, it is informed when |
58 |
* the block has either been loaded, or the pool |
* the block has either been loaded, or the pool |
59 |
* has given up on loading it. |
* has given up on loading it. |
60 |
* XXX |
* <p> |
61 |
|
* If the block is already available locally, it will be returned. |
62 |
|
* The <code>BlockListener</code> will not be called at all. |
63 |
|
* If the block must be loaded, <code>null</code> is returned |
64 |
|
* (no exception is thrown). If the block is known not to be |
65 |
|
* available, a <code>FileNotFoundException</code> is thrown. |
66 |
|
* <p> |
67 |
|
* After the block has been loaded, it will be kept locally |
68 |
|
* for some time, but no guarantees are made as to how long. |
69 |
|
* It is reasonable to <code>request()</code> a block, |
70 |
|
* doing nothing if <code>null</code> is returned, |
71 |
|
* and when notification comes in that the block |
72 |
|
* has been loaded, repeat the whole procedure. |
73 |
|
* If the block has already been uncached at the time |
74 |
|
* of the second <code>request()</code> and we get |
75 |
|
* another chance. |
76 |
|
* <p> |
77 |
|
* We could make it so that the <code>BlockListener</code> |
78 |
|
* is always called, even when we can return the block |
79 |
|
* immediately. However it is easier to simulate that |
80 |
|
* behavior on top of the current one than it would be |
81 |
|
* to simulate the current behavior on top of that one, |
82 |
|
* and both are expected to be needed. |
83 |
|
* @throws FileNotFoundException if the block is not found |
84 |
|
* in the pool. |
85 |
*/ |
*/ |
86 |
void request(BlockId id, BlockListener listener); |
Block request(BlockId id, BlockListener listener) throws IOException; |
87 |
|
|
88 |
/** Load a block from the network, if it is not available locally. |
/** Load a block from the network, if it is not available locally. |
|
* XXX |
|
89 |
* Equivalent to <code>request(id, null)</code>. |
* Equivalent to <code>request(id, null)</code>. |
90 |
|
* @throws FileNotFoundException if the block is not found |
91 |
|
* in the pool. |
92 |
*/ |
*/ |
93 |
void request(BlockId id); |
Block request(BlockId id) throws IOException; |
94 |
|
|
95 |
/** Add a block to this pool. |
/** Add a block to this pool. |
96 |
* The data in the block is checked by this class to assure |
* The data in the block is checked by this class to assure |