[
https://issues.apache.org/jira/browse/STORM-901?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14976796#comment-14976796
]
ASF GitHub Bot commented on STORM-901:
--------------------------------------
Github user revans2 commented on a diff in the pull request:
https://github.com/apache/storm/pull/822#discussion_r43155803
--- Diff: storm-core/src/jvm/backtype/storm/utils/Utils.java ---
@@ -692,5 +696,65 @@ public static void handleUncaughtException(Throwable
t) {
}
}
}
+
+ /**
+ * Given a File input it will unzip the file in a the unzip directory
+ * passed as the second parameter
+ * @param inFile The zip file as input
+ * @param unzipDir The unzip directory where to unzip the zip file.
+ * @throws IOException
+ */
+ public static void unZip(File inFile, File unzipDir) throws
IOException {
+ Enumeration<? extends ZipEntry> entries;
+ ZipFile zipFile = new ZipFile(inFile);
+
+ try {
+ entries = zipFile.entries();
+ while (entries.hasMoreElements()) {
+ ZipEntry entry = entries.nextElement();
+ if (!entry.isDirectory()) {
+ InputStream in = zipFile.getInputStream(entry);
+ try {
+ File file = new File(unzipDir, entry.getName());
+ if (!file.getParentFile().mkdirs()) {
+ if (!file.getParentFile().isDirectory()) {
+ throw new IOException("Mkdirs failed to
create " +
+ file.getParentFile().toString());
+ }
+ }
+ OutputStream out = new FileOutputStream(file);
+ try {
+ byte[] buffer = new byte[8192];
+ int i;
+ while ((i = in.read(buffer)) != -1) {
+ out.write(buffer, 0, i);
+ }
+ } finally {
+ out.close();
+ }
+ } finally {
+ in.close();
+ }
+ }
+ }
+ } finally {
+ zipFile.close();
+ }
+ }
+
+ //Note: Only works for zip files whose uncompressed size is less than
4 GB
+ //Otherwise returns the size module 2^32, per gzip specifications
+ //Returns a long, since that's what file lengths in Java/Clojure
usually are.
--- End diff --
Can we turn this into a javadoc comment?
> Worker Artifacts Directory
> --------------------------
>
> Key: STORM-901
> URL: https://issues.apache.org/jira/browse/STORM-901
> Project: Apache Storm
> Issue Type: New Feature
> Components: storm-core
> Reporter: Robert Joseph Evans
> Assignee: Zhuo Liu
>
> At Yahoo we have added in a separate directory that stores a workers log
> files, but also provides a place where the worker can place other files that
> it might help with debugging. It is a new directory in the current working
> directory of the worker process. The files in there are cleaned up if they
> get too large, but provides a place for heap dumps GC logs, etc.
> This work is already done, but needs to be put back into open source.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)