use of org.apache.flink.shaded.guava30.com.google.common.io.Closer in project alluxio by Alluxio.
the class UfsJournalLogWriter method close.
@Override
public synchronized void close() throws IOException {
Closer closer = Closer.create();
if (mJournalOutputStream != null) {
closer.register(mJournalOutputStream);
}
closer.register(mGarbageCollector);
closer.close();
mClosed = true;
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Closer in project alluxio by Alluxio.
the class CachingInodeStore method close.
@Override
public void close() {
Closer closer = Closer.create();
// Close the backing store last so that cache eviction threads don't hit errors.
closer.register(mBackingStore);
closer.register(mInodeCache);
closer.register(mEdgeCache);
try {
closer.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Closer in project commons by twitter.
the class FileEchoer method echo.
@Override
public String echo() throws IOException {
Closer closer = Closer.create();
try {
FileReader fileReader = closer.register(new FileReader("/etc/hosts"));
BufferedReader bufferedReader = closer.register(new BufferedReader(fileReader));
return bufferedReader.readLine();
} finally {
closer.close();
}
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Closer in project atlas by alibaba.
the class AtlasDataBindingMergeArtifactsTransform method extractBinFilesFromJar.
private void extractBinFilesFromJar(File jarFile) throws IOException {
File jarOutFolder = getOutFolderForJarFile(jarFile);
FileUtils.deleteQuietly(jarOutFolder);
FileUtils.forceMkdir(jarOutFolder);
try (Closer localCloser = Closer.create()) {
FileInputStream fis = localCloser.register(new FileInputStream(jarFile));
ZipInputStream zis = localCloser.register(new ZipInputStream(fis));
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
if (entry.isDirectory()) {
continue;
}
String name = entry.getName();
if (!isResource(name)) {
continue;
}
// get rid of the path. We don't need it since the file name includes the domain
name = new File(name).getName();
File out = new File(jarOutFolder, name);
// noinspection ResultOfMethodCallIgnored
FileOutputStream fos = localCloser.register(new FileOutputStream(out));
ByteStreams.copy(zis, fos);
zis.closeEntry();
}
}
}
use of org.apache.flink.shaded.guava30.com.google.common.io.Closer in project atlas by alibaba.
the class AwbDataBindingMergeArtifactsTask method extractBinFilesFromJar.
private void extractBinFilesFromJar(File outFolder, File jarFile) throws IOException {
File jarOutFolder = getOutFolderForJarFile(outFolder, jarFile);
if (jarOutFolder.exists()) {
FileUtils.deleteDirectoryContents(jarOutFolder);
} else {
FileUtils.mkdirs(jarOutFolder);
}
try (Closer localCloser = Closer.create()) {
FileInputStream fis = localCloser.register(new FileInputStream(jarFile));
ZipInputStream zis = localCloser.register(new ZipInputStream(fis));
ZipEntry entry;
while ((entry = zis.getNextEntry()) != null) {
if (entry.isDirectory()) {
continue;
}
String name = entry.getName();
if (!isResource(name)) {
continue;
}
// get rid of the path. We don't need it since the file name includes the domain
name = new File(name).getName();
File out = new File(jarOutFolder, name);
// noinspection ResultOfMethodCallIgnored
FileOutputStream fos = localCloser.register(new FileOutputStream(out));
ByteStreams.copy(zis, fos);
zis.closeEntry();
}
}
}
Aggregations