HBASE-7547 Fix findbugs warnings in snapshot classes (Ted Yu)
git-svn-id: https://svn.apache.org/repos/asf/hbase/branches/hbase-7290@1445847 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e3ce13909d
commit
1e414a4413
|
@ -2441,7 +2441,7 @@ public class HBaseAdmin implements Abortable, Closeable {
|
||||||
.setName(snapshotName).setTable(tableName).build();
|
.setName(snapshotName).setTable(tableName).build();
|
||||||
|
|
||||||
// actually restore the snapshot
|
// actually restore the snapshot
|
||||||
RestoreSnapshotResponse response = internalRestoreSnapshotAsync(snapshot);
|
internalRestoreSnapshotAsync(snapshot);
|
||||||
|
|
||||||
final IsRestoreSnapshotDoneRequest request = IsRestoreSnapshotDoneRequest.newBuilder()
|
final IsRestoreSnapshotDoneRequest request = IsRestoreSnapshotDoneRequest.newBuilder()
|
||||||
.setSnapshot(snapshot).build();
|
.setSnapshot(snapshot).build();
|
||||||
|
|
|
@ -219,7 +219,7 @@ public final class MasterSnapshotVerifier {
|
||||||
String fileName = hfile.getPath().getName();
|
String fileName = hfile.getPath().getName();
|
||||||
Path file = new Path(realCfDir, fileName);
|
Path file = new Path(realCfDir, fileName);
|
||||||
Path archived = new Path(archivedCfDir, fileName);
|
Path archived = new Path(archivedCfDir, fileName);
|
||||||
if (!fs.exists(file) && !fs.equals(archived)) {
|
if (!fs.exists(file) && !file.equals(archived)) {
|
||||||
throw new CorruptedSnapshotException("Can't find hfile: " + hfile.getPath()
|
throw new CorruptedSnapshotException("Can't find hfile: " + hfile.getPath()
|
||||||
+ " in the real (" + archivedCfDir + ") or archive (" + archivedCfDir
|
+ " in the real (" + archivedCfDir + ") or archive (" + archivedCfDir
|
||||||
+ ") directory for the primary table.", snapshot);
|
+ ") directory for the primary table.", snapshot);
|
||||||
|
|
|
@ -275,7 +275,7 @@ public class SnapshotFileCache implements Stoppable {
|
||||||
/**
|
/**
|
||||||
* Information about a snapshot directory
|
* Information about a snapshot directory
|
||||||
*/
|
*/
|
||||||
public class SnapshotDirectoryInfo {
|
private static class SnapshotDirectoryInfo {
|
||||||
long lastModified;
|
long lastModified;
|
||||||
Collection<String> files;
|
Collection<String> files;
|
||||||
|
|
||||||
|
|
|
@ -650,7 +650,7 @@ public final class ExportSnapshot extends Configured implements Tool {
|
||||||
|
|
||||||
// ExportSnapshot
|
// ExportSnapshot
|
||||||
private void printUsageAndExit() {
|
private void printUsageAndExit() {
|
||||||
System.err.printf("Usage: bin/hbase %s [options]\n", getClass().getName());
|
System.err.printf("Usage: bin/hbase %s [options]%n", getClass().getName());
|
||||||
System.err.println(" where [options] are:");
|
System.err.println(" where [options] are:");
|
||||||
System.err.println(" -h|-help Show this help and exit.");
|
System.err.println(" -h|-help Show this help and exit.");
|
||||||
System.err.println(" -snapshot NAME Snapshot to restore.");
|
System.err.println(" -snapshot NAME Snapshot to restore.");
|
||||||
|
|
|
@ -76,11 +76,14 @@ public class ReferenceServerWALsTask extends SnapshotTask {
|
||||||
// Iterate through each of the log files and add a reference to it.
|
// Iterate through each of the log files and add a reference to it.
|
||||||
// assumes that all the files under the server's logs directory is a log
|
// assumes that all the files under the server's logs directory is a log
|
||||||
FileStatus[] serverLogs = FSUtils.listStatus(fs, logDir, null);
|
FileStatus[] serverLogs = FSUtils.listStatus(fs, logDir, null);
|
||||||
if (serverLogs == null) LOG.info("No logs for server directory:" + logDir
|
if (serverLogs == null) {
|
||||||
+ ", done referencing files.");
|
LOG.debug("No logs for server directory:" + logDir + ", done referencing files.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (LOG.isDebugEnabled()) LOG.debug("Adding references for WAL files:"
|
if (LOG.isDebugEnabled()) {
|
||||||
+ Arrays.toString(serverLogs));
|
LOG.debug("Adding references for WAL files:" + Arrays.toString(serverLogs));
|
||||||
|
}
|
||||||
|
|
||||||
for (FileStatus file : serverLogs) {
|
for (FileStatus file : serverLogs) {
|
||||||
this.rethrowException();
|
this.rethrowException();
|
||||||
|
|
|
@ -41,14 +41,12 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||||
import org.apache.hadoop.hbase.HRegionInfo;
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
import org.apache.hadoop.hbase.backup.HFileArchiver;
|
import org.apache.hadoop.hbase.backup.HFileArchiver;
|
||||||
import org.apache.hadoop.hbase.catalog.MetaEditor;
|
|
||||||
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher;
|
import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher;
|
||||||
import org.apache.hadoop.hbase.io.HFileLink;
|
import org.apache.hadoop.hbase.io.HFileLink;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
|
||||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||||
import org.apache.hadoop.hbase.regionserver.StoreFile;
|
import org.apache.hadoop.hbase.regionserver.StoreFile;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
|
||||||
import org.apache.hadoop.hbase.util.FSUtils;
|
import org.apache.hadoop.hbase.util.FSUtils;
|
||||||
import org.apache.hadoop.hbase.util.FSVisitor;
|
import org.apache.hadoop.hbase.util.FSVisitor;
|
||||||
import org.apache.hadoop.hbase.util.ModifyRegionUtils;
|
import org.apache.hadoop.hbase.util.ModifyRegionUtils;
|
||||||
|
@ -132,8 +130,6 @@ public class RestoreSnapshotHelper {
|
||||||
* @return the set of regions touched by the restore operation
|
* @return the set of regions touched by the restore operation
|
||||||
*/
|
*/
|
||||||
public RestoreMetaChanges restoreHdfsRegions() throws IOException {
|
public RestoreMetaChanges restoreHdfsRegions() throws IOException {
|
||||||
long startTime = EnvironmentEdgeManager.currentTimeMillis();
|
|
||||||
|
|
||||||
LOG.debug("starting restore");
|
LOG.debug("starting restore");
|
||||||
Set<String> snapshotRegionNames = SnapshotReferenceUtil.getSnapshotRegionNames(fs, snapshotDir);
|
Set<String> snapshotRegionNames = SnapshotReferenceUtil.getSnapshotRegionNames(fs, snapshotDir);
|
||||||
if (snapshotRegionNames == null) {
|
if (snapshotRegionNames == null) {
|
||||||
|
@ -152,7 +148,7 @@ public class RestoreSnapshotHelper {
|
||||||
String regionName = regionInfo.getEncodedName();
|
String regionName = regionInfo.getEncodedName();
|
||||||
if (snapshotRegionNames.contains(regionName)) {
|
if (snapshotRegionNames.contains(regionName)) {
|
||||||
LOG.info("region to restore: " + regionName);
|
LOG.info("region to restore: " + regionName);
|
||||||
snapshotRegionNames.remove(regionInfo);
|
snapshotRegionNames.remove(regionName);
|
||||||
metaChanges.addRegionToRestore(regionInfo);
|
metaChanges.addRegionToRestore(regionInfo);
|
||||||
} else {
|
} else {
|
||||||
LOG.info("region to remove: " + regionName);
|
LOG.info("region to remove: " + regionName);
|
||||||
|
@ -196,7 +192,7 @@ public class RestoreSnapshotHelper {
|
||||||
/**
|
/**
|
||||||
* Describe the set of operations needed to update META after restore.
|
* Describe the set of operations needed to update META after restore.
|
||||||
*/
|
*/
|
||||||
public class RestoreMetaChanges {
|
public static class RestoreMetaChanges {
|
||||||
private List<HRegionInfo> regionsToRestore = null;
|
private List<HRegionInfo> regionsToRestore = null;
|
||||||
private List<HRegionInfo> regionsToRemove = null;
|
private List<HRegionInfo> regionsToRemove = null;
|
||||||
private List<HRegionInfo> regionsToAdd = null;
|
private List<HRegionInfo> regionsToAdd = null;
|
||||||
|
@ -325,13 +321,11 @@ public class RestoreSnapshotHelper {
|
||||||
|
|
||||||
// Add families not present in the table
|
// Add families not present in the table
|
||||||
for (Map.Entry<String, List<String>> familyEntry: snapshotFiles.entrySet()) {
|
for (Map.Entry<String, List<String>> familyEntry: snapshotFiles.entrySet()) {
|
||||||
byte[] family = Bytes.toBytes(familyEntry.getKey());
|
|
||||||
Path familyDir = new Path(regionDir, familyEntry.getKey());
|
Path familyDir = new Path(regionDir, familyEntry.getKey());
|
||||||
if (!fs.mkdirs(familyDir)) {
|
if (!fs.mkdirs(familyDir)) {
|
||||||
throw new IOException("Unable to create familyDir=" + familyDir);
|
throw new IOException("Unable to create familyDir=" + familyDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> hfilesToAdd = new LinkedList<String>();
|
|
||||||
for (String hfileName: familyEntry.getValue()) {
|
for (String hfileName: familyEntry.getValue()) {
|
||||||
LOG.trace("Adding HFileLink " + hfileName + " to table=" + tableName);
|
LOG.trace("Adding HFileLink " + hfileName + " to table=" + tableName);
|
||||||
restoreStoreFile(familyDir, regionInfo, hfileName);
|
restoreStoreFile(familyDir, regionInfo, hfileName);
|
||||||
|
@ -384,7 +378,7 @@ public class RestoreSnapshotHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the regions on disk
|
// create the regions on disk
|
||||||
List<HRegionInfo> clonedRegions = ModifyRegionUtils.createRegions(conf, tableDir.getParent(),
|
ModifyRegionUtils.createRegions(conf, tableDir.getParent(),
|
||||||
tableDesc, clonedRegionsInfo, new ModifyRegionUtils.RegionFillTask() {
|
tableDesc, clonedRegionsInfo, new ModifyRegionUtils.RegionFillTask() {
|
||||||
public void fillRegion(final HRegion region) throws IOException {
|
public void fillRegion(final HRegion region) throws IOException {
|
||||||
cloneRegion(region, snapshotRegions.get(region.getRegionInfo().getEncodedName()));
|
cloneRegion(region, snapshotRegions.get(region.getRegionInfo().getEncodedName()));
|
||||||
|
|
|
@ -210,7 +210,7 @@ public final class SnapshotInfo extends Configured implements Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showFiles) {
|
if (showFiles) {
|
||||||
System.out.printf("%8s %s/%s/%s/%s %s\n",
|
System.out.printf("%8s %s/%s/%s/%s %s%n",
|
||||||
(size < 0 ? "-" : StringUtils.humanReadableInt(size)),
|
(size < 0 ? "-" : StringUtils.humanReadableInt(size)),
|
||||||
table, region, family, hfile,
|
table, region, family, hfile,
|
||||||
(inArchive ? "(archive)" : (size < 0) ? "(NOT FOUND)" : ""));
|
(inArchive ? "(archive)" : (size < 0) ? "(NOT FOUND)" : ""));
|
||||||
|
@ -225,7 +225,7 @@ public final class SnapshotInfo extends Configured implements Tool {
|
||||||
logsCount.addAndGet(1);
|
logsCount.addAndGet(1);
|
||||||
|
|
||||||
if (showFiles) {
|
if (showFiles) {
|
||||||
System.out.printf("%8s recovered.edits %s on region %s\n",
|
System.out.printf("%8s recovered.edits %s on region %s%n",
|
||||||
StringUtils.humanReadableInt(size), logfile, region);
|
StringUtils.humanReadableInt(size), logfile, region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ public final class SnapshotInfo extends Configured implements Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showFiles) {
|
if (showFiles) {
|
||||||
System.out.printf("%8s log %s on server %s %s\n",
|
System.out.printf("%8s log %s on server %s %s%n",
|
||||||
(size < 0 ? "-" : StringUtils.humanReadableInt(size)),
|
(size < 0 ? "-" : StringUtils.humanReadableInt(size)),
|
||||||
logfile, server,
|
logfile, server,
|
||||||
(size < 0 ? "(NOT FOUND)" : ""));
|
(size < 0 ? "(NOT FOUND)" : ""));
|
||||||
|
@ -255,24 +255,24 @@ public final class SnapshotInfo extends Configured implements Tool {
|
||||||
System.out.println();
|
System.out.println();
|
||||||
if (hfilesMissing.get() > 0 || logsMissing.get() > 0) {
|
if (hfilesMissing.get() > 0 || logsMissing.get() > 0) {
|
||||||
System.out.println("**************************************************************");
|
System.out.println("**************************************************************");
|
||||||
System.out.printf("BAD SNAPSHOT: %d hfile(s) and %d log(s) missing.\n",
|
System.out.printf("BAD SNAPSHOT: %d hfile(s) and %d log(s) missing.%n",
|
||||||
hfilesMissing.get(), logsMissing.get());
|
hfilesMissing.get(), logsMissing.get());
|
||||||
System.out.println("**************************************************************");
|
System.out.println("**************************************************************");
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.printf("%d HFiles (%d in archive), total size %s (%.2f%% %s shared with the source table)\n",
|
System.out.printf("%d HFiles (%d in archive), total size %s (%.2f%% %s shared with the source table)%n",
|
||||||
hfilesCount.get() + hfileArchiveCount.get(), hfileArchiveCount.get(),
|
hfilesCount.get() + hfileArchiveCount.get(), hfileArchiveCount.get(),
|
||||||
StringUtils.humanReadableInt(hfileSize.get() + hfileArchiveSize.get()),
|
StringUtils.humanReadableInt(hfileSize.get() + hfileArchiveSize.get()),
|
||||||
((float)hfileSize.get() / (hfileSize.get() + hfileArchiveSize.get())) * 100,
|
((float)hfileSize.get() / (hfileSize.get() + hfileArchiveSize.get())) * 100,
|
||||||
StringUtils.humanReadableInt(hfileSize.get())
|
StringUtils.humanReadableInt(hfileSize.get())
|
||||||
);
|
);
|
||||||
System.out.printf("%d Logs, total size %s\n",
|
System.out.printf("%d Logs, total size %s%n",
|
||||||
logsCount.get(), StringUtils.humanReadableInt(logSize.get()));
|
logsCount.get(), StringUtils.humanReadableInt(logSize.get()));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printUsageAndExit() {
|
private void printUsageAndExit() {
|
||||||
System.err.printf("Usage: bin/hbase %s [options]\n", getClass().getName());
|
System.err.printf("Usage: bin/hbase %s [options]%n", getClass().getName());
|
||||||
System.err.println(" where [options] are:");
|
System.err.println(" where [options] are:");
|
||||||
System.err.println(" -h|-help Show this help and exit.");
|
System.err.println(" -h|-help Show this help and exit.");
|
||||||
System.err.println(" -snapshot NAME Snapshot to examine.");
|
System.err.println(" -snapshot NAME Snapshot to examine.");
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class TakeSnapshotUtils {
|
||||||
Multimap<String, String> realLogs = getMapOfServersAndLogs(fs, logsDir, serverNames);
|
Multimap<String, String> realLogs = getMapOfServersAndLogs(fs, logsDir, serverNames);
|
||||||
if (realLogs != null) {
|
if (realLogs != null) {
|
||||||
assertNotNull(snapshot, "No server logs added to snapshot", snapshotLogs);
|
assertNotNull(snapshot, "No server logs added to snapshot", snapshotLogs);
|
||||||
} else if (realLogs == null) {
|
} else {
|
||||||
assertNull(snapshot, "Snapshotted server logs that don't exist", snapshotLogs);
|
assertNull(snapshot, "Snapshotted server logs that don't exist", snapshotLogs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue