本文整理了Java中org.apache.flink.util.FileUtils.compressDirectory()
方法的一些代码示例,展示了FileUtils.compressDirectory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.compressDirectory()
方法的具体详情如下:
包路径:org.apache.flink.util.FileUtils
类名称:FileUtils
方法名:compressDirectory
暂无
代码示例来源:origin: apache/flink
Files.copy(new ByteArrayInputStream(testFileContent.getBytes(StandardCharsets.UTF_8)), compressDir.resolve(file3));
final Path zip = FileUtils.compressDirectory(
new Path(compressDir.resolve(originalDir).toString()),
new Path(compressDir.resolve(originalDir) + ".zip"));
代码示例来源:origin: apache/flink
public static void addUserArtifactEntries(Collection<Tuple2<String, DistributedCache.DistributedCacheEntry>> userArtifacts, JobGraph jobGraph) {
if (!userArtifacts.isEmpty()) {
try {
java.nio.file.Path tmpDir = Files.createTempDirectory("flink-distributed-cache-" + jobGraph.getJobID());
for (Tuple2<String, DistributedCache.DistributedCacheEntry> originalEntry : userArtifacts) {
Path filePath = new Path(originalEntry.f1.filePath);
boolean isLocalDir = false;
try {
FileSystem sourceFs = filePath.getFileSystem();
isLocalDir = !sourceFs.isDistributedFS() && sourceFs.getFileStatus(filePath).isDir();
} catch (IOException ioe) {
LOG.warn("Could not determine whether {} denotes a local path.", filePath, ioe);
}
// zip local directories because we only support file uploads
DistributedCache.DistributedCacheEntry entry;
if (isLocalDir) {
Path zip = FileUtils.compressDirectory(filePath, new Path(tmpDir.toString(), filePath.getName() + ".zip"));
entry = new DistributedCache.DistributedCacheEntry(zip.toString(), originalEntry.f1.isExecutable, true);
} else {
entry = new DistributedCache.DistributedCacheEntry(filePath.toString(), originalEntry.f1.isExecutable, false);
}
jobGraph.addUserArtifact(originalEntry.f0, entry);
}
} catch (IOException ioe) {
throw new FlinkRuntimeException("Could not compress distributed-cache artifacts.", ioe);
}
}
}
代码示例来源:origin: org.apache.flink/flink-optimizer_2.11
public static void addUserArtifactEntries(Collection<Tuple2<String, DistributedCache.DistributedCacheEntry>> userArtifacts, JobGraph jobGraph) {
if (!userArtifacts.isEmpty()) {
try {
java.nio.file.Path tmpDir = Files.createTempDirectory("flink-distributed-cache-" + jobGraph.getJobID());
for (Tuple2<String, DistributedCache.DistributedCacheEntry> originalEntry : userArtifacts) {
Path filePath = new Path(originalEntry.f1.filePath);
boolean isLocalDir = false;
try {
FileSystem sourceFs = filePath.getFileSystem();
isLocalDir = !sourceFs.isDistributedFS() && sourceFs.getFileStatus(filePath).isDir();
} catch (IOException ioe) {
LOG.warn("Could not determine whether {} denotes a local path.", filePath, ioe);
}
// zip local directories because we only support file uploads
DistributedCache.DistributedCacheEntry entry;
if (isLocalDir) {
Path zip = FileUtils.compressDirectory(filePath, new Path(tmpDir.toString(), filePath.getName() + ".zip"));
entry = new DistributedCache.DistributedCacheEntry(zip.toString(), originalEntry.f1.isExecutable, true);
} else {
entry = new DistributedCache.DistributedCacheEntry(filePath.toString(), originalEntry.f1.isExecutable, false);
}
jobGraph.addUserArtifact(originalEntry.f0, entry);
}
} catch (IOException ioe) {
throw new FlinkRuntimeException("Could not compress distributed-cache artifacts.", ioe);
}
}
}
代码示例来源:origin: org.apache.flink/flink-optimizer
public static void addUserArtifactEntries(Collection<Tuple2<String, DistributedCache.DistributedCacheEntry>> userArtifacts, JobGraph jobGraph) {
if (!userArtifacts.isEmpty()) {
try {
java.nio.file.Path tmpDir = Files.createTempDirectory("flink-distributed-cache-" + jobGraph.getJobID());
for (Tuple2<String, DistributedCache.DistributedCacheEntry> originalEntry : userArtifacts) {
Path filePath = new Path(originalEntry.f1.filePath);
boolean isLocalDir = false;
try {
FileSystem sourceFs = filePath.getFileSystem();
isLocalDir = !sourceFs.isDistributedFS() && sourceFs.getFileStatus(filePath).isDir();
} catch (IOException ioe) {
LOG.warn("Could not determine whether {} denotes a local path.", filePath, ioe);
}
// zip local directories because we only support file uploads
DistributedCache.DistributedCacheEntry entry;
if (isLocalDir) {
Path zip = FileUtils.compressDirectory(filePath, new Path(tmpDir.toString(), filePath.getName() + ".zip"));
entry = new DistributedCache.DistributedCacheEntry(zip.toString(), originalEntry.f1.isExecutable, true);
} else {
entry = new DistributedCache.DistributedCacheEntry(filePath.toString(), originalEntry.f1.isExecutable, false);
}
jobGraph.addUserArtifact(originalEntry.f0, entry);
}
} catch (IOException ioe) {
throw new FlinkRuntimeException("Could not compress distributed-cache artifacts.", ioe);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!