HDDS-1139 : Fix findbugs issues caused by HDDS-1085. Contributed by Aravindan Vijayan.

This commit is contained in:
avijayanhwx 2019-02-19 16:32:47 -08:00 committed by Bharat Viswanadham
parent 0525d85d57
commit e8d7e3b4e6
5 changed files with 26 additions and 8 deletions

View File

@ -93,7 +93,7 @@ public RocksDBCheckpointSnapshot createCheckpointSnapshot(String parentDir)
return null; return null;
} }
class RocksDBCheckpointSnapshot implements DBCheckpointSnapshot { static class RocksDBCheckpointSnapshot implements DBCheckpointSnapshot {
private Path checkpointLocation; private Path checkpointLocation;
private long checkpointTimestamp; private long checkpointTimestamp;

View File

@ -119,7 +119,10 @@ public RDBStore(File dbFile, DBOptions options, Set<TableConfig> families,
OM_DB_CHECKPOINTS_DIR_NAME).toString(); OM_DB_CHECKPOINTS_DIR_NAME).toString();
File checkpointsDir = new File(checkpointsParentDir); File checkpointsDir = new File(checkpointsParentDir);
if (!checkpointsDir.exists()) { if (!checkpointsDir.exists()) {
checkpointsDir.mkdir(); boolean success = checkpointsDir.mkdir();
if (!success) {
LOG.warn("Unable to create RocksDB checkpoint directory");
}
} }
//Initialize checkpoint manager //Initialize checkpoint manager

View File

@ -1881,4 +1881,13 @@
jar and false for the ozone-filesystem-lib.jar jar and false for the ozone-filesystem-lib.jar
</description> </description>
</property> </property>
<property>
<name>ozone.manager.db.snapshot.transfer.bandwidthPerSec</name>
<value>0</value>
<tag>OZONE</tag>
<description>
Maximum bandwidth used for Ozone Manager DB checkpoint download through
the servlet.
</description>
</property>
</configuration> </configuration>

View File

@ -315,8 +315,10 @@ public static File createTarFile(Path sourcePath) throws IOException {
tarOs = new TarArchiveOutputStream(gzipOutputStream); tarOs = new TarArchiveOutputStream(gzipOutputStream);
File folder = new File(sourceDir); File folder = new File(sourceDir);
File[] filesInDir = folder.listFiles(); File[] filesInDir = folder.listFiles();
for (File file : filesInDir) { if (filesInDir != null) {
addFilesToArchive(file.getName(), file, tarOs); for (File file : filesInDir) {
addFilesToArchive(file.getName(), file, tarOs);
}
} }
return new File(fileName); return new File(fileName);
} finally { } finally {
@ -343,8 +345,12 @@ private static void addFilesToArchive(String source, File file,
fileInputStream.close(); fileInputStream.close();
} else if (file.isDirectory()) { } else if (file.isDirectory()) {
tarFileOutputStream.closeArchiveEntry(); tarFileOutputStream.closeArchiveEntry();
for (File cFile : file.listFiles()) { File[] filesInDir = file.listFiles();
addFilesToArchive(cFile.getAbsolutePath(), cFile, tarFileOutputStream); if (filesInDir != null) {
for (File cFile : filesInDir) {
addFilesToArchive(cFile.getAbsolutePath(), cFile,
tarFileOutputStream);
}
} }
} }
} }

View File

@ -50,9 +50,10 @@ public class OMDbSnapshotServlet extends HttpServlet {
private static final Logger LOG = private static final Logger LOG =
LoggerFactory.getLogger(OMDbSnapshotServlet.class); LoggerFactory.getLogger(OMDbSnapshotServlet.class);
private static final long serialVersionUID = 1L;
private transient DBStore omDbStore; private transient DBStore omDbStore;
private DataTransferThrottler throttler = null; private transient DataTransferThrottler throttler = null;
@Override @Override
public void init() throws ServletException { public void init() throws ServletException {
@ -111,7 +112,6 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return; return;
} }
LOG.info("Tar location = " + checkPointTarFile.getAbsolutePath());
checkPointTarFile = OmUtils.createTarFile( checkPointTarFile = OmUtils.createTarFile(
checkpoint.getCheckpointLocation()); checkpoint.getCheckpointLocation());
LOG.info("Tar location = " + checkPointTarFile.getAbsolutePath()); LOG.info("Tar location = " + checkPointTarFile.getAbsolutePath());