use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project powertac-tournament-scheduler by powertac.
the class LogJob method compressTarGz.
private void compressTarGz(String tarGz, String xmlPath) {
try (TarArchiveOutputStream tOut = new TarArchiveOutputStream(new GzipCompressorOutputStream(new BufferedOutputStream(new FileOutputStream(new File(tarGz)))))) {
addFileToTarGz(tOut, tmpPath + "log", "log");
addFileToTarGz(tOut, tmpPath + "boot-log", "boot-log");
addFileToTarGz(tOut, xmlPath, "");
new File(tarGz).setReadable(true, false);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project agileway by fangjinuo.
the class TarArchiveOutputStreamCustomizer method customize.
@Override
public void customize(ArchiveOutputStream archiveOutputStream) {
TarArchiveOutputStream tarOut = (TarArchiveOutputStream) archiveOutputStream;
tarOut.setAddPaxHeadersForNonAsciiNames(true);
tarOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
tarOut.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_STAR);
}
use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project hadoop by apache.
the class TestFSDownload method createTarFile.
static LocalResource createTarFile(FileContext files, Path p, int len, Random r, LocalResourceVisibility vis) throws IOException, URISyntaxException {
byte[] bytes = new byte[len];
r.nextBytes(bytes);
File archiveFile = new File(p.toUri().getPath() + ".tar");
archiveFile.createNewFile();
TarArchiveOutputStream out = new TarArchiveOutputStream(new FileOutputStream(archiveFile));
TarArchiveEntry entry = new TarArchiveEntry(p.getName());
entry.setSize(bytes.length);
out.putArchiveEntry(entry);
out.write(bytes);
out.closeArchiveEntry();
out.close();
LocalResource ret = recordFactory.newRecordInstance(LocalResource.class);
ret.setResource(ConverterUtils.getYarnUrlFromPath(new Path(p.toString() + ".tar")));
ret.setSize(len);
ret.setType(LocalResourceType.ARCHIVE);
ret.setVisibility(vis);
ret.setTimestamp(files.getFileStatus(new Path(p.toString() + ".tar")).getModificationTime());
return ret;
}
use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project hadoop by apache.
the class TestFSDownload method createTgzFile.
static LocalResource createTgzFile(FileContext files, Path p, int len, Random r, LocalResourceVisibility vis) throws IOException, URISyntaxException {
byte[] bytes = new byte[len];
r.nextBytes(bytes);
File gzipFile = new File(p.toUri().getPath() + ".tar.gz");
gzipFile.createNewFile();
TarArchiveOutputStream out = new TarArchiveOutputStream(new GZIPOutputStream(new FileOutputStream(gzipFile)));
TarArchiveEntry entry = new TarArchiveEntry(p.getName());
entry.setSize(bytes.length);
out.putArchiveEntry(entry);
out.write(bytes);
out.closeArchiveEntry();
out.close();
LocalResource ret = recordFactory.newRecordInstance(LocalResource.class);
ret.setResource(ConverterUtils.getYarnUrlFromPath(new Path(p.toString() + ".tar.gz")));
ret.setSize(len);
ret.setType(LocalResourceType.ARCHIVE);
ret.setVisibility(vis);
ret.setTimestamp(files.getFileStatus(new Path(p.toString() + ".tar.gz")).getModificationTime());
return ret;
}
use of org.apache.commons.compress.archivers.tar.TarArchiveOutputStream in project jib by google.
the class TarStreamBuilder method writeAsTarArchiveTo.
/**
* Writes each entry in the filesystem to the tarball archive stream.
*
* @param out the stream to write to.
* @throws IOException if building the tarball fails.
*/
public void writeAsTarArchiveTo(OutputStream out) throws IOException {
try (TarArchiveOutputStream tarArchiveOutputStream = new TarArchiveOutputStream(out, StandardCharsets.UTF_8.name())) {
// Enables PAX extended headers to support long file names.
tarArchiveOutputStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
tarArchiveOutputStream.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);
for (Map.Entry<TarArchiveEntry, Blob> entry : archiveMap.entrySet()) {
tarArchiveOutputStream.putArchiveEntry(entry.getKey());
entry.getValue().writeTo(tarArchiveOutputStream);
tarArchiveOutputStream.closeArchiveEntry();
}
}
}
Aggregations