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
FieldsModifier and TypeFieldDescriptionprivate final StoreContextprivate static final org.slf4j.Loggerprivate static final intprivate intprivate long(package private) static final String(package private) static final Pattern(package private) static final Stringprivate static final String(package private) static final charprivate final org.apache.hadoop.fs.Pathprivate final org.apache.hadoop.fs.Path[](package private) static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcleanUpTrackFiles(long loadedSeqId, NavigableMap<Long, List<org.apache.hadoop.fs.Path>> seqId2TrackFiles) private voidinitializeTrackFiles(long seqId) private NavigableMap<Long,List<org.apache.hadoop.fs.Path>> (package private) org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileListload(boolean readOnly) (package private) static org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileListload(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) (package private) org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileListload(org.apache.hadoop.fs.Path path) private intselect(org.apache.hadoop.hbase.shaded.protobuf.generated.StoreFileTrackerProtos.StoreFileList[] lists) (package private) voidupdate(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 voidwrite(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
-