-
Notifications
You must be signed in to change notification settings - Fork 626
HDDS-7625. Do not compress OM/SCM checkpoints #4130
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
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -40,9 +40,6 @@ | |
| import org.apache.commons.compress.archivers.ArchiveEntry; | ||
| import org.apache.commons.compress.archivers.ArchiveOutputStream; | ||
| import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; | ||
| import org.apache.commons.compress.compressors.CompressorException; | ||
| import org.apache.commons.compress.compressors.CompressorOutputStream; | ||
| import org.apache.commons.compress.compressors.CompressorStreamFactory; | ||
| import org.apache.commons.compress.utils.IOUtils; | ||
| import org.apache.commons.lang3.StringUtils; | ||
|
|
||
|
|
@@ -171,7 +168,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) { | |
| response.setContentType("application/x-tgz"); | ||
| response.setHeader("Content-Disposition", | ||
| "attachment; filename=\"" + | ||
| file.toString() + ".tgz\""); | ||
| file + ".tar\""); | ||
|
|
||
| Instant start = Instant.now(); | ||
| writeDBCheckpointToStream(checkpoint, | ||
|
|
@@ -211,30 +208,21 @@ public static void writeDBCheckpointToStream(DBCheckpoint checkpoint, | |
| OutputStream destination) | ||
|
Contributor
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. Let's remove this method, and replace the usage of DBCheckpointServlet.writeDBCheckpointToStream() with HddsServerUtil.writeDBCheckpointToStream(). (There are three usages) |
||
| throws IOException { | ||
|
|
||
| try (CompressorOutputStream gzippedOut = new CompressorStreamFactory() | ||
| .createCompressorOutputStream(CompressorStreamFactory.GZIP, | ||
| destination)) { | ||
|
|
||
| try (ArchiveOutputStream archiveOutputStream = | ||
| new TarArchiveOutputStream(gzippedOut)) { | ||
|
|
||
| Path checkpointPath = checkpoint.getCheckpointLocation(); | ||
| try (Stream<Path> files = Files.list(checkpointPath)) { | ||
| for (Path path : files.collect(Collectors.toList())) { | ||
| if (path != null) { | ||
| Path fileName = path.getFileName(); | ||
| if (fileName != null) { | ||
| includeFile(path.toFile(), fileName.toString(), | ||
| archiveOutputStream); | ||
| } | ||
| try (ArchiveOutputStream archiveOutputStream = | ||
| new TarArchiveOutputStream(destination)) { | ||
|
|
||
| Path checkpointPath = checkpoint.getCheckpointLocation(); | ||
| try (Stream<Path> files = Files.list(checkpointPath)) { | ||
| for (Path path : files.collect(Collectors.toList())) { | ||
| if (path != null) { | ||
| Path fileName = path.getFileName(); | ||
| if (fileName != null) { | ||
| includeFile(path.toFile(), fileName.toString(), | ||
| archiveOutputStream); | ||
|
Contributor
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. This method and its helper Also, please update the method comment ( |
||
| } | ||
| } | ||
| } | ||
| } | ||
| } catch (CompressorException e) { | ||
| throw new IOException( | ||
| "Can't compress the checkpoint: " + | ||
| checkpoint.getCheckpointLocation(), e); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -31,7 +31,6 @@ | |||||
| import java.nio.file.Paths; | ||||||
| import java.security.KeyPair; | ||||||
| import java.sql.Timestamp; | ||||||
| import java.util.zip.GZIPOutputStream; | ||||||
|
|
||||||
| import com.google.inject.Singleton; | ||||||
| import org.apache.hadoop.hdds.HddsConfigKeys; | ||||||
|
|
@@ -46,7 +45,6 @@ | |||||
| import org.apache.commons.compress.archivers.tar.TarArchiveEntry; | ||||||
| import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; | ||||||
| import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; | ||||||
| import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; | ||||||
| import static org.apache.hadoop.hdds.server.ServerUtils.getDirectoryFromConfig; | ||||||
| import static org.apache.hadoop.hdds.server.ServerUtils.getOzoneMetaDirPath; | ||||||
| import static org.apache.hadoop.ozone.recon.ReconServerConfigKeys.OZONE_RECON_SCM_DB_DIR; | ||||||
|
|
@@ -107,20 +105,17 @@ public File getReconDbDir(ConfigurationSource conf, String dirConfigKey) { | |||||
| * Given a source directory, create a tar.gz file from it. | ||||||
|
Contributor
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.
Suggested change
|
||||||
| * | ||||||
| * @param sourcePath the path to the directory to be archived. | ||||||
| * @return tar.gz file | ||||||
| * @return tar file | ||||||
| * @throws IOException | ||||||
| */ | ||||||
| public static File createTarFile(Path sourcePath) throws IOException { | ||||||
| TarArchiveOutputStream tarOs = null; | ||||||
| FileOutputStream fileOutputStream = null; | ||||||
| GZIPOutputStream gzipOutputStream = null; | ||||||
| try { | ||||||
| String sourceDir = sourcePath.toString(); | ||||||
| String fileName = sourceDir.concat(".tar.gz"); | ||||||
| String fileName = sourceDir.concat(".tar"); | ||||||
| fileOutputStream = new FileOutputStream(fileName); | ||||||
| gzipOutputStream = | ||||||
| new GZIPOutputStream(new BufferedOutputStream(fileOutputStream)); | ||||||
| tarOs = new TarArchiveOutputStream(gzipOutputStream); | ||||||
| tarOs = new TarArchiveOutputStream(fileOutputStream); | ||||||
| File folder = new File(sourceDir); | ||||||
| File[] filesInDir = folder.listFiles(); | ||||||
| if (filesInDir != null) { | ||||||
|
|
@@ -133,7 +128,6 @@ public static File createTarFile(Path sourcePath) throws IOException { | |||||
| try { | ||||||
| org.apache.hadoop.io.IOUtils.closeStream(tarOs); | ||||||
| org.apache.hadoop.io.IOUtils.closeStream(fileOutputStream); | ||||||
| org.apache.hadoop.io.IOUtils.closeStream(gzipOutputStream); | ||||||
| } catch (Exception e) { | ||||||
| LOG.error("Exception encountered when closing " + | ||||||
| "TAR file output stream: " + e); | ||||||
|
|
@@ -177,12 +171,8 @@ public void untarCheckpointFile(File tarFile, Path destPath) | |||||
| throws IOException { | ||||||
|
|
||||||
| FileInputStream fileInputStream = null; | ||||||
| BufferedInputStream buffIn = null; | ||||||
| GzipCompressorInputStream gzIn = null; | ||||||
| try { | ||||||
| fileInputStream = new FileInputStream(tarFile); | ||||||
| buffIn = new BufferedInputStream(fileInputStream); | ||||||
| gzIn = new GzipCompressorInputStream(buffIn); | ||||||
|
|
||||||
| //Create Destination directory if it does not exist. | ||||||
| if (!destPath.toFile().exists()) { | ||||||
|
|
@@ -193,7 +183,7 @@ public void untarCheckpointFile(File tarFile, Path destPath) | |||||
| } | ||||||
|
|
||||||
| try (TarArchiveInputStream tarInStream = | ||||||
| new TarArchiveInputStream(gzIn)) { | ||||||
| new TarArchiveInputStream(fileInputStream)) { | ||||||
| TarArchiveEntry entry; | ||||||
|
|
||||||
| while ((entry = (TarArchiveEntry) tarInStream.getNextEntry()) != null) { | ||||||
|
|
@@ -223,8 +213,6 @@ public void untarCheckpointFile(File tarFile, Path destPath) | |||||
| } | ||||||
| } | ||||||
| } finally { | ||||||
| IOUtils.closeStream(gzIn); | ||||||
| IOUtils.closeStream(buffIn); | ||||||
| IOUtils.closeStream(fileInputStream); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
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.
Also update related tests: