You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by bo...@apache.org on 2014/05/12 17:35:45 UTC
[3/8] git commit: added src,
target file and totalBytes to progress bar listener
added src, target file and totalBytes to progress bar listener
Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/4e031323
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/4e031323
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/4e031323
Branch: refs/heads/master
Commit: 4e0313236ddf4d5d09a1b01f811f923923d52639
Parents: 2d2e842
Author: darthbear <fr...@gmail.com>
Authored: Tue May 6 11:03:03 2014 -0400
Committer: darthbear <fr...@gmail.com>
Committed: Tue May 6 11:03:03 2014 -0400
----------------------------------------------------------------------
.../src/jvm/backtype/storm/StormSubmitter.java | 25 ++++++++++----------
1 file changed, 12 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/4e031323/storm-core/src/jvm/backtype/storm/StormSubmitter.java
----------------------------------------------------------------------
diff --git a/storm-core/src/jvm/backtype/storm/StormSubmitter.java b/storm-core/src/jvm/backtype/storm/StormSubmitter.java
index ff299ff..5c644fa 100644
--- a/storm-core/src/jvm/backtype/storm/StormSubmitter.java
+++ b/storm-core/src/jvm/backtype/storm/StormSubmitter.java
@@ -158,20 +158,13 @@ public class StormSubmitter {
public static void submitTopologyWithProgressBar(String name, Map stormConf, StormTopology topology, SubmitOptions opts) throws AlreadyAliveException, InvalidTopologyException {
// show a progress bar so we know we're not stuck (especially on slow connections)
submitTopology(name, stormConf, topology, opts, new StormSubmitter.ProgressListener() {
- private long totalBytes;
- private String srcFile;
- private String targetFile;
-
@Override
public void onStart(String srcFile, String targetFile, long totalBytes) {
- this.srcFile = srcFile;
- this.targetFile = targetFile;
- this.totalBytes = totalBytes;
System.out.printf("Start uploading file '%s' to '%s' (%d bytes)\n", srcFile, targetFile, totalBytes);
}
@Override
- public void onProgress(long bytesUploaded) {
+ public void onProgress(String srcFile, String targetFile, long bytesUploaded, long totalBytes) {
int length = 50;
int p = (int)((length * bytesUploaded) / totalBytes);
String progress = StringUtils.repeat("=", p);
@@ -181,7 +174,7 @@ public class StormSubmitter {
}
@Override
- public void onCompleted() {
+ public void onCompleted(String srcFile, String targetFile, long totalBytes) {
System.out.printf("\nFile '%s' uploaded to '%s' (%d bytes)\n", srcFile, targetFile, totalBytes);
}
});
@@ -241,7 +234,7 @@ public class StormSubmitter {
byte[] toSubmit = is.read();
bytesUploaded += toSubmit.length;
if (listener != null) {
- listener.onProgress(bytesUploaded);
+ listener.onProgress(localJar, uploadLocation, bytesUploaded, totalSize);
}
if(toSubmit.length==0) break;
@@ -250,7 +243,7 @@ public class StormSubmitter {
client.getClient().finishFileUpload(uploadLocation);
if (listener != null) {
- listener.onCompleted();
+ listener.onCompleted(localJar, uploadLocation, totalSize);
}
LOG.info("Successfully uploaded topology jar to assigned location: " + uploadLocation);
@@ -277,13 +270,19 @@ public class StormSubmitter {
/**
* called whenever a chunk of bytes is uploaded
+ * @param srcFile - jar file to be uploaded
+ * @param targetFile - destination file
* @param bytesUploaded - number of bytes transferred so far
+ * @param totalBytes - total number of bytes of the file
*/
- public void onProgress(long bytesUploaded);
+ public void onProgress(String srcFile, String targetFile, long bytesUploaded, long totalBytes);
/**
* called when the file is uploaded
+ * @param srcFile - jar file to be uploaded
+ * @param targetFile - destination file
+ * @param totalBytes - total number of bytes of the file
*/
- public void onCompleted();
+ public void onCompleted(String srcFile, String targetFile, long totalBytes);
}
}