Skip to content

Commit

Permalink
HBASE-23095 Reuse FileStatus in StoreFileInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
karthikhw committed Sep 30, 2019
1 parent 3697e36 commit 6f4baae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.sun.istack.Nullable;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
Expand Down Expand Up @@ -111,11 +112,11 @@ public class StoreFileInfo {
*/
public StoreFileInfo(final Configuration conf, final FileSystem fs, final Path initialPath)
throws IOException {
this(conf, fs, initialPath, null, null);
this(conf, fs, null, initialPath);
}

private StoreFileInfo(final Configuration conf, final FileSystem fs, final Path initialPath,
final Long createdTimestamp, final Long size) throws IOException {
private StoreFileInfo(final Configuration conf, final FileSystem fs,
@Nullable final FileStatus fileStatus, final Path initialPath) throws IOException {
assert fs != null;
assert initialPath != null;
assert conf != null;
Expand Down Expand Up @@ -143,13 +144,13 @@ private StoreFileInfo(final Configuration conf, final FileSystem fs, final Path
" reference to " + referencePath);
} else if (isHFile(p)) {
// HFile
if (createdTimestamp != null && size != null) {
this.createdTimestamp = createdTimestamp;
this.size = size;
} else {
FileStatus fileStatus = fs.getFileStatus(initialPath);
if (fileStatus != null) {
this.createdTimestamp = fileStatus.getModificationTime();
this.size = fileStatus.getLen();
} else {
FileStatus fStatus = fs.getFileStatus(initialPath);
this.createdTimestamp = fStatus.getModificationTime();
this.size = fStatus.getLen();
}
this.reference = null;
this.link = null;
Expand All @@ -166,7 +167,7 @@ private StoreFileInfo(final Configuration conf, final FileSystem fs, final Path
*/
public StoreFileInfo(final Configuration conf, final FileSystem fs, final FileStatus fileStatus)
throws IOException {
this(conf, fs, fileStatus.getPath(), fileStatus.getModificationTime(), fileStatus.getLen());
this(conf, fs, fileStatus, fileStatus.getPath());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,41 @@
*/
package org.apache.hadoop.hbase.snapshot;

import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
import org.apache.hadoop.hbase.regionserver.HRegionFileSystem;
import org.apache.hadoop.hbase.regionserver.StoreFileInfo;
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.FSUtils;
import org.junit.*;

import java.io.IOException;
import java.util.*;

import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDataManifest;
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription;
import org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest;

import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;


/**
* Validate if storefile length match
* both snapshop manifest and filesystem.
Expand Down

0 comments on commit 6f4baae

Please sign in to comment.