public class SplitFileFetcherSegmentStorage
extends java.lang.Object
SplitFileFetcherStorage
Modifier and Type | Field and Description |
---|---|
int |
checkBlocks
Count of check blocks (generated by FEC).
|
int |
crossSegmentCheckBlocks
Count of cross-segment check blocks.
|
int |
dataBlocks
Count of data blocks (actual data divided up into CHKs, though the last one will be
padded).
|
Constructor and Description |
---|
SplitFileFetcherSegmentStorage(SplitFileFetcherStorage parent,
java.io.DataInputStream dis,
int segNo,
boolean writeRetries,
long segmentDataOffset,
long segmentCrossCheckDataOffset,
long segmentKeysOffset,
long segmentStatusOffset,
KeysFetchingLocally keysFetching)
Construct from a saved file.
|
SplitFileFetcherSegmentStorage(SplitFileFetcherStorage parent,
int segNumber,
Metadata.SplitfileAlgorithm splitfileType,
int dataBlocks,
int checkBlocks,
int crossCheckBlocks,
long segmentDataOffset,
long segmentCrossCheckDataOffset,
long segmentKeysOffset,
long segmentStatusOffset,
boolean writeRetries,
SplitFileSegmentKeys keys,
KeysFetchingLocally keysFetching)
Construct a segment.
|
Modifier and Type | Method and Description |
---|---|
int |
allocateCrossCheckBlock(SplitFileFetcherCrossSegmentStorage seg,
java.util.Random random)
Allocate a cross-segment check block.
|
int |
allocateCrossDataBlock(SplitFileFetcherCrossSegmentStorage seg,
java.util.Random random)
Allocate a cross-segment data block.
|
void |
cancel() |
byte[] |
checkAndGetBlockData(int blockNum) |
int |
chooseRandomKey()
Pick a key to fetch.
|
long |
countSendableKeys(long now,
int maxRetries) |
long |
countUnfetchedKeys() |
boolean |
definitelyWantKey(NodeCHK key) |
int |
failedBlocks() |
int |
foundBlocks() |
ClientCHK |
getKey(int blockNum) |
long |
getOverallCooldownTime() |
SplitFileSegmentKeys |
getSegmentKeys() |
void |
getUnfetchedKeys(java.util.List<Key> keys) |
boolean |
hasBlock(int blockNo) |
boolean |
hasSucceeded() |
boolean |
isDecoding() |
boolean |
isDecodingOrFinished() |
boolean |
isFinished() |
boolean |
needsDecode() |
void |
onFinishedCheckingDatastoreNoFetch(ClientContext context)
Called after checking datastore for a datastore-only request.
|
boolean |
onGotKey(NodeCHK key,
CHKBlock block)
A block has been fetched which the caller believes is one of ours.
|
void |
onNonFatalFailure(int blockNumber) |
static int |
paddedStoredSegmentStatusLength(int dataBlocks,
int checkBlocks,
int crossCheckBlocks,
boolean trackRetries,
int checksumLength,
boolean persistent) |
static int |
storedSegmentStatusLength(int dataBlocks,
int checkBlocks,
int crossCheckBlocks,
boolean trackRetries) |
boolean |
tryStartDecode()
Read all the blocks, encode them according to their supposed keys and check that they are
in fact the blocks that they should be.
|
void |
writeFixedMetadata(java.io.DataOutputStream dos)
Write minimal fixed metadata for the segment.
|
void |
writeMetadata()
Write the status metadata to disk, after a series of updates.
|
void |
writeMetadata(boolean force)
Write the status metadata to disk, after a series of updates.
|
public final int dataBlocks
public final int crossSegmentCheckBlocks
public final int checkBlocks
public SplitFileFetcherSegmentStorage(SplitFileFetcherStorage parent, int segNumber, Metadata.SplitfileAlgorithm splitfileType, int dataBlocks, int checkBlocks, int crossCheckBlocks, long segmentDataOffset, long segmentCrossCheckDataOffset, long segmentKeysOffset, long segmentStatusOffset, boolean writeRetries, SplitFileSegmentKeys keys, KeysFetchingLocally keysFetching)
parent
- segNumber
- splitfileType
- dataBlocks
- checkBlocks
- crossCheckBlocks
- segmentDataOffset
- segmentCrossCheckDataOffset
- -1 to mean store the cross-check blocks just after the
data and check blocks for this segment. Otherwise the offset.segmentKeysOffset
- segmentStatusOffset
- writeRetries
- keys
- public SplitFileFetcherSegmentStorage(SplitFileFetcherStorage parent, java.io.DataInputStream dis, int segNo, boolean writeRetries, long segmentDataOffset, long segmentCrossCheckDataOffset, long segmentKeysOffset, long segmentStatusOffset, KeysFetchingLocally keysFetching) throws java.io.IOException, StorageFormatException
parent
- dis
- DataInputStream to which the static settings have been saved. Anything else we
will need to read separately from the RandomAccessBuffer.segNo
- The segment number.writeRetries
- segmentDataOffset
- segmentCrossCheckDataOffset
- -1 to mean store the cross-check blocks just after the
data and check blocks for this segment. Otherwise the offset.segmentKeysOffset
- segmentStatusOffset
- keysFetching
- java.io.IOException
StorageFormatException
public SplitFileSegmentKeys getSegmentKeys() throws java.io.IOException
java.io.IOException
public void writeMetadata() throws java.io.IOException
java.io.IOException
public void writeMetadata(boolean force) throws java.io.IOException
java.io.IOException
public boolean tryStartDecode()
public boolean onGotKey(NodeCHK key, CHKBlock block) throws java.io.IOException
key
- block
- java.io.IOException
- If we were unable to write the block to disk.public static int storedSegmentStatusLength(int dataBlocks, int checkBlocks, int crossCheckBlocks, boolean trackRetries)
public static int paddedStoredSegmentStatusLength(int dataBlocks, int checkBlocks, int crossCheckBlocks, boolean trackRetries, int checksumLength, boolean persistent)
public boolean isFinished()
public boolean isDecodingOrFinished()
public boolean hasSucceeded()
public void onNonFatalFailure(int blockNumber)
public int allocateCrossDataBlock(SplitFileFetcherCrossSegmentStorage seg, java.util.Random random)
seg
- The cross-segment to allocate a block for.random
- PRNG seeded from the splitfile metadata, which determines which blocks to
allocate in a deterministic manner.public int allocateCrossCheckBlock(SplitFileFetcherCrossSegmentStorage seg, java.util.Random random)
seg
- The cross-segment to allocate a block for.random
- PRNG seeded from the splitfile metadata, which determines which blocks to
allocate in a deterministic manner.public boolean definitelyWantKey(NodeCHK key)
public void writeFixedMetadata(java.io.DataOutputStream dos) throws java.io.IOException
java.io.IOException
public long countUnfetchedKeys()
public long countSendableKeys(long now, int maxRetries)
public void getUnfetchedKeys(java.util.List<Key> keys) throws java.io.IOException
java.io.IOException
public int chooseRandomKey()
public void cancel()
public long getOverallCooldownTime()
public boolean needsDecode()
public int foundBlocks()
public int failedBlocks()
public ClientCHK getKey(int blockNum)
public byte[] checkAndGetBlockData(int blockNum) throws java.io.IOException
java.io.IOException
public boolean hasBlock(int blockNo)
public boolean isDecoding()
public void onFinishedCheckingDatastoreNoFetch(ClientContext context)