@Private
public class StripedBlockUtil
extends java.lang.Object
| Modifier and Type | Class | Description |
|---|---|---|
static class |
StripedBlockUtil.AlignedStripe |
Given a requested byte range on a striped block group, an AlignedStripe
represents an inclusive
StripedBlockUtil.VerticalRange that is aligned with both
the byte range and boundaries of all internal blocks. |
static class |
StripedBlockUtil.BlockReadStats |
Struct holding the read statistics.
|
static class |
StripedBlockUtil.ChunkByteBuffer |
A utility to manage ByteBuffer slices for a reader.
|
static class |
StripedBlockUtil.StripeRange |
Used to indicate the buffered data's range in the block group.
|
static class |
StripedBlockUtil.StripingCell |
Cell is the unit of encoding used in
DFSStripedOutputStream. |
static class |
StripedBlockUtil.StripingChunk |
Indicates the coverage of an
StripedBlockUtil.AlignedStripe on an internal block,
and the state of the chunk in the context of the read request. |
static class |
StripedBlockUtil.StripingChunkReadResult |
This class represents result from a striped read request.
|
static class |
StripedBlockUtil.VerticalRange |
A simple utility class representing an arbitrary vertical inclusive range
starting at
StripedBlockUtil.VerticalRange.offsetInBlock and lasting for StripedBlockUtil.VerticalRange.spanInBlock
bytes in an internal block. |
| Modifier and Type | Field | Description |
|---|---|---|
static org.slf4j.Logger |
LOG |
| Constructor | Description |
|---|---|
StripedBlockUtil() |
| Modifier and Type | Method | Description |
|---|---|---|
static void |
checkBlocks(ExtendedBlock blockGroup,
int i,
ExtendedBlock blocki) |
Check if the information such as IDs and generation stamps in block-i
match the block group.
|
static ExtendedBlock |
constructInternalBlock(ExtendedBlock blockGroup,
int cellSize,
int dataBlkNum,
int idxInBlockGroup) |
This method creates an internal
ExtendedBlock at the given index
of a block group. |
static ExtendedBlock |
constructInternalBlock(ExtendedBlock blockGroup,
ErasureCodingPolicy ecPolicy,
int idxInBlockGroup) |
|
static LocatedBlock |
constructInternalBlock(LocatedStripedBlock bg,
int idxInReturnedLocs,
int cellSize,
int dataBlkNum,
int idxInBlockGroup) |
This method creates an internal block at the given index of a block group.
|
static StripedBlockUtil.AlignedStripe[] |
divideByteRangeIntoStripes(ErasureCodingPolicy ecPolicy,
int cellSize,
LocatedStripedBlock blockGroup,
long rangeStartInBlockGroup,
long rangeEndInBlockGroup,
java.nio.ByteBuffer buf) |
This method divides a requested byte range into an array of inclusive
StripedBlockUtil.AlignedStripe. |
static StripedBlockUtil.AlignedStripe[] |
divideOneStripe(ErasureCodingPolicy ecPolicy,
int cellSize,
LocatedStripedBlock blockGroup,
long rangeStartInBlockGroup,
long rangeEndInBlockGroup,
java.nio.ByteBuffer buf) |
Similar functionality with
divideByteRangeIntoStripes(org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy, int, org.apache.hadoop.hdfs.protocol.LocatedStripedBlock, long, long, java.nio.ByteBuffer), but is used
by stateful read and uses ByteBuffer as reading target buffer. |
static int |
getBlockIndex(Block reportedBlock) |
|
static long |
getInternalBlockLength(long dataSize,
int cellSize,
int numDataBlocks,
int idxInBlockGroup) |
Get the size of an internal block at the given index of a block group.
|
static long |
getInternalBlockLength(long dataSize,
ErasureCodingPolicy ecPolicy,
int idxInBlockGroup) |
|
static StripedBlockUtil.StripingChunkReadResult |
getNextCompletedStripedRead(java.util.concurrent.CompletionService<StripedBlockUtil.BlockReadStats> readService,
java.util.Map<java.util.concurrent.Future<StripedBlockUtil.BlockReadStats>,java.lang.Integer> futures,
long timeoutMillis) |
Get the next completed striped read task.
|
static long |
getSafeLength(ErasureCodingPolicy ecPolicy,
long[] blockLens) |
Compute the safe length given the internal block lengths.
|
static long |
offsetInBlkToOffsetInBG(int cellSize,
int dataBlkNum,
long offsetInBlk,
int idxInBlockGroup) |
Given a byte's offset in an internal block, calculate the offset in
the block group.
|
static LocatedBlock[] |
parseStripedBlockGroup(LocatedStripedBlock bg,
int cellSize,
int dataBlkNum,
int parityBlkNum) |
This method parses a striped block group into individual blocks.
|
static long |
spaceConsumedByStripedBlock(long numDataBlkBytes,
int dataBlkNum,
int parityBlkNum,
int cellSize) |
Get the total usage of the striped blocks, which is the total of data
blocks and parity blocks.
|
public static LocatedBlock[] parseStripedBlockGroup(LocatedStripedBlock bg, int cellSize, int dataBlkNum, int parityBlkNum)
bg - The striped block groupcellSize - The size of a striping celldataBlkNum - The number of data blockspublic static LocatedBlock constructInternalBlock(LocatedStripedBlock bg, int idxInReturnedLocs, int cellSize, int dataBlkNum, int idxInBlockGroup)
idxInReturnedLocs - The index in the stored locations in the
LocatedStripedBlock objectidxInBlockGroup - The logical index in the striped block grouppublic static ExtendedBlock constructInternalBlock(ExtendedBlock blockGroup, ErasureCodingPolicy ecPolicy, int idxInBlockGroup)
public static ExtendedBlock constructInternalBlock(ExtendedBlock blockGroup, int cellSize, int dataBlkNum, int idxInBlockGroup)
ExtendedBlock at the given index
of a block group.public static long getInternalBlockLength(long dataSize,
ErasureCodingPolicy ecPolicy,
int idxInBlockGroup)
public static long getInternalBlockLength(long dataSize,
int cellSize,
int numDataBlocks,
int idxInBlockGroup)
dataSize - Size of the block group only counting data blockscellSize - The size of a striping cellnumDataBlocks - The number of data blocksidxInBlockGroup - The logical index in the striped block grouppublic static long getSafeLength(ErasureCodingPolicy ecPolicy, long[] blockLens)
ecPolicy - The EC policy used for the block groupblockLens - The lengths of internal blockspublic static long offsetInBlkToOffsetInBG(int cellSize,
int dataBlkNum,
long offsetInBlk,
int idxInBlockGroup)
public static StripedBlockUtil.StripingChunkReadResult getNextCompletedStripedRead(java.util.concurrent.CompletionService<StripedBlockUtil.BlockReadStats> readService, java.util.Map<java.util.concurrent.Future<StripedBlockUtil.BlockReadStats>,java.lang.Integer> futures, long timeoutMillis) throws java.lang.InterruptedException
StripedBlockUtil.StripingChunkReadResult indicating the status of the read
task succeeded, and the block index of the task. If the method
times out without getting any completed read tasks, -1 is
returned as block index.java.lang.InterruptedExceptionpublic static long spaceConsumedByStripedBlock(long numDataBlkBytes,
int dataBlkNum,
int parityBlkNum,
int cellSize)
numDataBlkBytes - Size of the block group only counting data blocksdataBlkNum - The number of data blocksparityBlkNum - The number of parity blockscellSize - The size of a striping cellpublic static StripedBlockUtil.AlignedStripe[] divideOneStripe(ErasureCodingPolicy ecPolicy, int cellSize, LocatedStripedBlock blockGroup, long rangeStartInBlockGroup, long rangeEndInBlockGroup, java.nio.ByteBuffer buf)
divideByteRangeIntoStripes(org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy, int, org.apache.hadoop.hdfs.protocol.LocatedStripedBlock, long, long, java.nio.ByteBuffer), but is used
by stateful read and uses ByteBuffer as reading target buffer. Besides the
read range is within a single stripe thus the calculation logic is simpler.public static StripedBlockUtil.AlignedStripe[] divideByteRangeIntoStripes(ErasureCodingPolicy ecPolicy, int cellSize, LocatedStripedBlock blockGroup, long rangeStartInBlockGroup, long rangeEndInBlockGroup, java.nio.ByteBuffer buf)
StripedBlockUtil.AlignedStripe.ecPolicy - The codec policy for the file, which carries the numbers
of data / parity blockscellSize - Cell size of stripeblockGroup - The striped block grouprangeStartInBlockGroup - The byte range's start offset in block grouprangeEndInBlockGroup - The byte range's end offset in block groupbuf - Destination buffer of the read operation for the byte range
At most 5 stripes will be generated from each logical range, as
demonstrated in the header of StripedBlockUtil.AlignedStripe.public static void checkBlocks(ExtendedBlock blockGroup, int i, ExtendedBlock blocki) throws java.io.IOException
java.io.IOExceptionpublic static int getBlockIndex(Block reportedBlock)
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.