Class StoreFileListFile
java.lang.Object
org.apache.hadoop.hbase.regionserver.storefiletracker.StoreFileListFile
To fully avoid listing, here we use two files for tracking. When loading, we will try to read
both the two files, if only one exists, we will trust this one, if both exist, we will compare
the timestamp to see which one is newer and trust that one. And we will record in memory that
which one is trusted by us, and when we need to update the store file list, we will write to the
other file.
So in this way, we could avoid listing when we want to load the store file list file.
To prevent loading partial file, we use the first 4 bytes as file length, and also append a 4
bytes crc32 checksum at the end. This is because the protobuf message parser sometimes can return
without error on partial bytes if you stop at some special points, but the return message will
have incorrect field value. We should try our best to prevent this happens because loading an
incorrect store file list file usually leads to data loss.
To prevent failing silently while downgrading, where we may miss some newly introduced fields in
StoreFileTrackerProtos.StoreFileList
which are necessary, we introduce a 'version' field in
StoreFileTrackerProtos.StoreFileList
. If we find out that we are reading a StoreFileTrackerProtos.StoreFileList
with higher
version, we will fail immediately and tell users that you need extra steps while downgrading, to
prevent potential data loss.-
Field Summary
Modifier and TypeFieldDescriptionprivate final StoreContext
private static final org.slf4j.Logger
private static final int
private int
private long
(package private) static final String
(package private) static final Pattern
(package private) static final String
private static final String
(package private) static final char
private final org.apache.hadoop.fs.Path
private final org.apache.hadoop.fs.Path[]
(package private) static final long
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
cleanUpTrackFiles
(long loadedSeqId, NavigableMap<Long, List<org.apache.hadoop.fs.Path>> seqId2TrackFiles) private void
initializeTrackFiles
(long seqId) private NavigableMap<Long,
List<org.apache.hadoop.fs.Path>> (package private) org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList
load
(boolean readOnly) (package private) static org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList
load
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) (package private) org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList
load
(org.apache.hadoop.fs.Path path) private int
select
(org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList[] lists) (package private) void
update
(org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList.Builder builder) We will set the timestamp and version in this method so just pass the builder in(package private) static void
write
(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path file, org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList storeFileList)
-
Field Details
-
LOG
-
VERSION
- See Also:
-
TRACK_FILE_DIR
- See Also:
-
TRACK_FILE_PREFIX
- See Also:
-
TRACK_FILE_ROTATE_PREFIX
- See Also:
-
TRACK_FILE_SEPARATOR
- See Also:
-
TRACK_FILE_PATTERN
-
MAX_FILE_SIZE
- See Also:
-
ctx
-
trackFileDir
-
trackFiles
-
prevTimestamp
-
nextTrackFile
-
-
Constructor Details
-
StoreFileListFile
-
-
Method Details
-
load
static org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList load(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException - Throws:
IOException
-
load
org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList load(org.apache.hadoop.fs.Path path) throws IOException - Throws:
IOException
-
select
private int select(org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList[] lists) -
listFiles
- Throws:
IOException
-
initializeTrackFiles
-
load
org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList load(boolean readOnly) throws IOException - Throws:
IOException
-
write
static void write(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path file, org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList storeFileList) throws IOException - Throws:
IOException
-
update
void update(org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList.Builder builder) throws IOException We will set the timestamp and version in this method so just pass the builder in- Throws:
IOException
-