You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2014/09/19 15:16:48 UTC
[1/5] git commit: updated refs/heads/master to 765d402
Repository: cloudstack
Updated Branches:
refs/heads/master 90df7cf88 -> 765d402d6
CID-1114601 to 1114604 Recommended practice is to test the result of
skip and read for EOF
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4ad27345
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4ad27345
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4ad27345
Branch: refs/heads/master
Commit: 4ad2734576481f09a3f5ded3d80e9e938dbac5f8
Parents: 90df7cf
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Fri Sep 19 14:29:01 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Sep 19 14:29:01 2014 +0200
----------------------------------------------------------------------
.../cloud/exception/InternalErrorException.java | 4 ++++
.../exception/ManagementServerException.java | 4 ++++
.../cloud/storage/template/VhdProcessor.java | 24 +++++++++++++++-----
3 files changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4ad27345/api/src/com/cloud/exception/InternalErrorException.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/exception/InternalErrorException.java b/api/src/com/cloud/exception/InternalErrorException.java
index 8404011..efb68d4 100644
--- a/api/src/com/cloud/exception/InternalErrorException.java
+++ b/api/src/com/cloud/exception/InternalErrorException.java
@@ -24,4 +24,8 @@ public class InternalErrorException extends ManagementServerException {
super(message);
}
+ public InternalErrorException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4ad27345/api/src/com/cloud/exception/ManagementServerException.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/exception/ManagementServerException.java b/api/src/com/cloud/exception/ManagementServerException.java
index c8a106a..86fd233 100644
--- a/api/src/com/cloud/exception/ManagementServerException.java
+++ b/api/src/com/cloud/exception/ManagementServerException.java
@@ -30,4 +30,8 @@ public class ManagementServerException extends CloudException {
super(message);
}
+ public ManagementServerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4ad27345/core/src/com/cloud/storage/template/VhdProcessor.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/VhdProcessor.java b/core/src/com/cloud/storage/template/VhdProcessor.java
index aff2942..875376f 100644
--- a/core/src/com/cloud/storage/template/VhdProcessor.java
+++ b/core/src/com/cloud/storage/template/VhdProcessor.java
@@ -79,13 +79,25 @@ public class VhdProcessor extends AdapterBase implements Processor {
byte[] creatorApp = new byte[4];
try {
strm = new FileInputStream(vhdFile);
- strm.skip(info.size - vhdFooterSize + vhdFooterCreatorAppOffset);
- strm.read(creatorApp);
- strm.skip(vhdFooterCurrentSizeOffset - vhdFooterCreatorVerOffset);
- strm.read(currentSize);
- } catch (Exception e) {
+ long skipped = strm.skip(info.size - vhdFooterSize + vhdFooterCreatorAppOffset);
+ if (skipped == -1) {
+ throw new InternalErrorException("Unexpected end-of-file");
+ }
+ long read = strm.read(creatorApp);
+ if (read == -1) {
+ throw new InternalErrorException("Unexpected end-of-file");
+ }
+ skipped = strm.skip(vhdFooterCurrentSizeOffset - vhdFooterCreatorVerOffset);
+ if (skipped == -1) {
+ throw new InternalErrorException("Unexpected end-of-file");
+ }
+ read = strm.read(currentSize);
+ if (read == -1) {
+ throw new InternalErrorException("Unexpected end-of-file");
+ }
+ } catch (IOException e) {
s_logger.warn("Unable to read vhd file " + vhdPath, e);
- throw new InternalErrorException("Unable to read vhd file " + vhdPath + ": " + e);
+ throw new InternalErrorException("Unable to read vhd file " + vhdPath + ": " + e, e);
} finally {
if (strm != null) {
try {
[5/5] git commit: updated refs/heads/master to 765d402
Posted by hu...@apache.org.
Merge branch 'bugfix/CID-1114591'
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/765d402d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/765d402d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/765d402d
Branch: refs/heads/master
Commit: 765d402d691fcdd93a1c825ca5732bedc9a082e7
Parents: e327716 2df41e8
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Fri Sep 19 15:16:37 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Sep 19 15:16:37 2014 +0200
----------------------------------------------------------------------
.../storage/download/DownloadActiveState.java | 46 +++++++++----------
.../cloud/storage/upload/UploadActiveState.java | 47 +++++++++-----------
2 files changed, 43 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
[4/5] git commit: updated refs/heads/master to 765d402
Posted by hu...@apache.org.
Merge branch 'bugfix/CID-1114601'
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e327716b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e327716b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e327716b
Branch: refs/heads/master
Commit: e327716b897eec17c892727e9f51f1139fc4f17d
Parents: 90df7cf 4ad2734
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Fri Sep 19 15:15:33 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Sep 19 15:15:33 2014 +0200
----------------------------------------------------------------------
.../cloud/exception/InternalErrorException.java | 4 ++++
.../exception/ManagementServerException.java | 4 ++++
.../cloud/storage/template/VhdProcessor.java | 24 +++++++++++++++-----
3 files changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
[2/5] git commit: updated refs/heads/master to 765d402
Posted by hu...@apache.org.
CID-1114591 Replace duplicated functionality with a call to super like the other state classes
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9cfab9b8
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9cfab9b8
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9cfab9b8
Branch: refs/heads/master
Commit: 9cfab9b8156087f275947a9a957f32fc6f5a2355
Parents: 90df7cf
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Fri Sep 19 14:42:20 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Sep 19 14:42:20 2014 +0200
----------------------------------------------------------------------
.../storage/download/DownloadActiveState.java | 46 +++++++++-----------
1 file changed, 21 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9cfab9b8/server/src/com/cloud/storage/download/DownloadActiveState.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/download/DownloadActiveState.java b/server/src/com/cloud/storage/download/DownloadActiveState.java
index 59709f2..9a22eb8 100644
--- a/server/src/com/cloud/storage/download/DownloadActiveState.java
+++ b/server/src/com/cloud/storage/download/DownloadActiveState.java
@@ -35,39 +35,35 @@ public abstract class DownloadActiveState extends DownloadState {
s_logger.trace("handleAnswer, answer status=" + answer.getDownloadStatus() + ", curr state=" + getName());
}
switch (answer.getDownloadStatus()) {
- case DOWNLOAD_IN_PROGRESS:
- getDownloadListener().scheduleStatusCheck(RequestType.GET_STATUS);
- return Status.DOWNLOAD_IN_PROGRESS.toString();
- case DOWNLOADED:
- getDownloadListener().cancelTimeoutTask();
- return Status.DOWNLOADED.toString();
- case NOT_DOWNLOADED:
- getDownloadListener().scheduleStatusCheck(RequestType.GET_STATUS);
- return Status.NOT_DOWNLOADED.toString();
- case DOWNLOAD_ERROR:
- getDownloadListener().cancelStatusTask();
- getDownloadListener().cancelTimeoutTask();
- return Status.DOWNLOAD_ERROR.toString();
- case UNKNOWN:
- getDownloadListener().cancelStatusTask();
- getDownloadListener().cancelTimeoutTask();
- return Status.DOWNLOAD_ERROR.toString();
- default:
- return null;
+ case DOWNLOAD_IN_PROGRESS:
+ getDownloadListener().scheduleStatusCheck(RequestType.GET_STATUS);
+ return Status.DOWNLOAD_IN_PROGRESS.toString();
+ case DOWNLOADED:
+ getDownloadListener().cancelTimeoutTask();
+ return Status.DOWNLOADED.toString();
+ case NOT_DOWNLOADED:
+ getDownloadListener().scheduleStatusCheck(RequestType.GET_STATUS);
+ return Status.NOT_DOWNLOADED.toString();
+ case DOWNLOAD_ERROR:
+ getDownloadListener().cancelStatusTask();
+ getDownloadListener().cancelTimeoutTask();
+ return Status.DOWNLOAD_ERROR.toString();
+ case UNKNOWN:
+ getDownloadListener().cancelStatusTask();
+ getDownloadListener().cancelTimeoutTask();
+ return Status.DOWNLOAD_ERROR.toString();
+ default:
+ return null;
}
}
@Override
public void onEntry(String prevState, DownloadEvent event, Object evtObj) {
- if (s_logger.isTraceEnabled()) {
- getDownloadListener().log("onEntry, prev state= " + prevState + ", curr state=" + getName() + ", event=" + event, Level.TRACE);
- }
+ super.onEntry(prevState, event, evtObj);
if (event == DownloadEvent.DOWNLOAD_ANSWER) {
- getDownloadListener().callback((DownloadAnswer)evtObj);
getDownloadListener().setLastUpdated();
}
-
}
@Override
@@ -79,7 +75,7 @@ public abstract class DownloadActiveState extends DownloadState {
if (s_logger.isTraceEnabled()) {
getDownloadListener().log("handleTimeout, updateMs=" + updateMs + ", curr state= " + getName(), Level.TRACE);
}
- String newState = this.getName();
+ String newState = getName();
if (updateMs > 5 * DownloadListener.STATUS_POLL_INTERVAL) {
newState = Status.DOWNLOAD_ERROR.toString();
getDownloadListener().log("timeout: transitioning to download error state, currstate=" + getName(), Level.DEBUG);
[3/5] git commit: updated refs/heads/master to 765d402
Posted by hu...@apache.org.
CID-1114592 Replaced duplicate code with a call to super
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/2df41e85
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2df41e85
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2df41e85
Branch: refs/heads/master
Commit: 2df41e857ec9d1398567c3dae3bd8a60f5a82759
Parents: 9cfab9b
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Fri Sep 19 14:45:13 2014 +0200
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Sep 19 14:47:13 2014 +0200
----------------------------------------------------------------------
.../cloud/storage/upload/UploadActiveState.java | 47 +++++++++-----------
1 file changed, 22 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2df41e85/server/src/com/cloud/storage/upload/UploadActiveState.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/upload/UploadActiveState.java b/server/src/com/cloud/storage/upload/UploadActiveState.java
index 53bbb75..c5dcc4e 100644
--- a/server/src/com/cloud/storage/upload/UploadActiveState.java
+++ b/server/src/com/cloud/storage/upload/UploadActiveState.java
@@ -45,26 +45,26 @@ public abstract class UploadActiveState extends UploadState {
s_logger.debug("handleAnswer, answer status=" + answer.getUploadStatus() + ", curr state=" + getName());
}
switch (answer.getUploadStatus()) {
- case UPLOAD_IN_PROGRESS:
- getUploadListener().scheduleStatusCheck(RequestType.GET_STATUS);
- return Status.UPLOAD_IN_PROGRESS.toString();
- case UPLOADED:
- getUploadListener().scheduleImmediateStatusCheck(RequestType.PURGE);
- getUploadListener().cancelTimeoutTask();
- return Status.UPLOADED.toString();
- case NOT_UPLOADED:
- getUploadListener().scheduleStatusCheck(RequestType.GET_STATUS);
- return Status.NOT_UPLOADED.toString();
- case UPLOAD_ERROR:
- getUploadListener().cancelStatusTask();
- getUploadListener().cancelTimeoutTask();
- return Status.UPLOAD_ERROR.toString();
- case UNKNOWN:
- getUploadListener().cancelStatusTask();
- getUploadListener().cancelTimeoutTask();
- return Status.UPLOAD_ERROR.toString();
- default:
- return null;
+ case UPLOAD_IN_PROGRESS:
+ getUploadListener().scheduleStatusCheck(RequestType.GET_STATUS);
+ return Status.UPLOAD_IN_PROGRESS.toString();
+ case UPLOADED:
+ getUploadListener().scheduleImmediateStatusCheck(RequestType.PURGE);
+ getUploadListener().cancelTimeoutTask();
+ return Status.UPLOADED.toString();
+ case NOT_UPLOADED:
+ getUploadListener().scheduleStatusCheck(RequestType.GET_STATUS);
+ return Status.NOT_UPLOADED.toString();
+ case UPLOAD_ERROR:
+ getUploadListener().cancelStatusTask();
+ getUploadListener().cancelTimeoutTask();
+ return Status.UPLOAD_ERROR.toString();
+ case UNKNOWN:
+ getUploadListener().cancelStatusTask();
+ getUploadListener().cancelTimeoutTask();
+ return Status.UPLOAD_ERROR.toString();
+ default:
+ return null;
}
}
@@ -73,7 +73,7 @@ public abstract class UploadActiveState extends UploadState {
if (s_logger.isTraceEnabled()) {
getUploadListener().log("handleTimeout, updateMs=" + updateMs + ", curr state= " + getName(), Level.TRACE);
}
- String newState = this.getName();
+ String newState = getName();
if (updateMs > 5 * UploadListener.STATUS_POLL_INTERVAL) {
newState = Status.UPLOAD_ERROR.toString();
getUploadListener().log("timeout: transitioning to upload error state, currstate=" + getName(), Level.DEBUG);
@@ -90,12 +90,9 @@ public abstract class UploadActiveState extends UploadState {
@Override
public void onEntry(String prevState, UploadEvent event, Object evtObj) {
- if (s_logger.isTraceEnabled()) {
- getUploadListener().log("onEntry, prev state= " + prevState + ", curr state=" + getName() + ", event=" + event, Level.TRACE);
- }
+ super.onEntry(prevState, event, evtObj);
if (event == UploadEvent.UPLOAD_ANSWER) {
- getUploadListener().updateDatabase((UploadAnswer)evtObj);
getUploadListener().setLastUpdated();
}