-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HBASE-25324 Remove unnecessary array to list conversion in SplitLogManager #2703
Changes from 2 commits
a9625bb
2453e09
e0ef403
6da6d6e
ba66dbd
6e058aa
bce4bb6
a125c4d
f0a6e3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,6 @@ | |
import java.util.TreeMap; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
import edu.umd.cs.findbugs.annotations.Nullable; | ||
import org.apache.commons.lang3.ArrayUtils; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.fs.FileStatus; | ||
import org.apache.hadoop.fs.FileSystem; | ||
|
@@ -54,6 +52,7 @@ | |
import org.apache.hadoop.hbase.wal.WAL.Entry; | ||
import org.apache.hadoop.hbase.wal.WAL.Reader; | ||
import org.apache.hadoop.ipc.RemoteException; | ||
import org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUtils; | ||
import org.apache.yetus.audience.InterfaceAudience; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
@@ -62,7 +61,6 @@ | |
import org.apache.hbase.thirdparty.com.google.protobuf.TextFormat; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionStoreSequenceIds; | ||
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.StoreSequenceId; | ||
import javax.validation.constraints.Null; | ||
|
||
/** | ||
* Split RegionServer WAL files. Splits the WAL into new files, | ||
|
@@ -220,17 +218,16 @@ public static List<Path> split(Path walRootDir, Path walsDir, Path archiveDir, F | |
Path rootDir = CommonFSUtils.getRootDir(conf); | ||
FileSystem rootFS = rootDir.getFileSystem(conf); | ||
WALSplitter splitter = new WALSplitter(factory, conf, walRootDir, walFS, rootDir, rootFS); | ||
final FileStatus[] wals = | ||
final List<FileStatus> wals = | ||
SplitLogManager.getFileList(conf, Collections.singletonList(walsDir), null); | ||
List<Path> splits = new ArrayList<>(); | ||
if (ArrayUtils.isNotEmpty(wals)) { | ||
if (CollectionUtils.isNotEmpty(wals)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wals.isEmpty()? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic here: if wals is not (empty or null), we will do the following loop, so i can't clearly figure out your meaning, could you description it in detail ? |
||
for (FileStatus wal: wals) { | ||
SplitWALResult splitWALResult = splitter.splitWAL(wal, null); | ||
if (splitWALResult.isFinished()) { | ||
WALSplitUtil.archive(wal.getPath(), splitWALResult.isCorrupt(), archiveDir, walFS, conf); | ||
if (splitter.outputSink.splits != null) { | ||
splits.addAll(splitter.outputSink.splits); | ||
} | ||
//splitter.outputSink.splits is mark as final, do not need null check | ||
splits.addAll(splitter.outputSink.splits); | ||
virajjasani marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/logfiles.size != 0/logfiles.isEmpty()/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I will use
CollectionUtils.isNotEmpty
instead