diff --git a/server/src/com/cloud/storage/download/DownloadActiveState.java b/server/src/com/cloud/storage/download/DownloadActiveState.java index b5ddde5a267..79ba5d4c52a 100644 --- a/server/src/com/cloud/storage/download/DownloadActiveState.java +++ b/server/src/com/cloud/storage/download/DownloadActiveState.java @@ -41,7 +41,6 @@ public abstract class DownloadActiveState extends DownloadState { getDownloadListener().scheduleStatusCheck(RequestType.GET_STATUS); return Status.DOWNLOAD_IN_PROGRESS.toString(); case DOWNLOADED: - getDownloadListener().scheduleImmediateStatusCheck(RequestType.PURGE); getDownloadListener().cancelTimeoutTask(); return Status.DOWNLOADED.toString(); case NOT_DOWNLOADED: diff --git a/server/src/com/cloud/storage/download/DownloadCompleteState.java b/server/src/com/cloud/storage/download/DownloadCompleteState.java index 1c46a082535..b9068483588 100644 --- a/server/src/com/cloud/storage/download/DownloadCompleteState.java +++ b/server/src/com/cloud/storage/download/DownloadCompleteState.java @@ -35,16 +35,17 @@ public class DownloadCompleteState extends DownloadInactiveState { @Override - public void onEntry(String prevState, DownloadEvent event, Object evtObj) { - super.onEntry(prevState, event, evtObj); - if (! prevState.equals(getName())) { - if (event == DownloadEvent.DOWNLOAD_ANSWER){ - getDownloadListener().scheduleImmediateStatusCheck(RequestType.PURGE); - } - getDownloadListener().setDownloadInactive(Status.DOWNLOADED); - } - - } + public void onEntry(String prevState, DownloadEvent event, Object evtObj) { + super.onEntry(prevState, event, evtObj); + if (!prevState.equals(getName())) { + if (event == DownloadEvent.DOWNLOAD_ANSWER) { + getDownloadListener().scheduleImmediateStatusCheck(RequestType.PURGE); + } + } else { + getDownloadListener().setDownloadInactive(Status.DOWNLOADED); + + } + } } diff --git a/server/src/com/cloud/storage/download/DownloadListener.java b/server/src/com/cloud/storage/download/DownloadListener.java index bc2efbd4413..f03ddd5ec2d 100644 --- a/server/src/com/cloud/storage/download/DownloadListener.java +++ b/server/src/com/cloud/storage/download/DownloadListener.java @@ -39,8 +39,6 @@ import com.cloud.agent.api.storage.DownloadAnswer; import com.cloud.agent.api.storage.DownloadCommand; import com.cloud.agent.api.storage.DownloadProgressCommand; import com.cloud.agent.api.storage.DownloadProgressCommand.RequestType; -import com.cloud.event.EventTypes; -import com.cloud.event.EventVO; import com.cloud.exception.ConnectionException; import com.cloud.host.HostVO; import com.cloud.storage.Storage; @@ -49,7 +47,6 @@ import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; import com.cloud.storage.VMTemplateVO; import com.cloud.storage.dao.VMTemplateHostDao; import com.cloud.storage.download.DownloadState.DownloadEvent; -import com.cloud.storage.template.TemplateInfo; import com.cloud.utils.exception.CloudRuntimeException; /** @@ -102,6 +99,7 @@ public class DownloadListener implements Listener { private HostVO sserver; + private HostVO ssAgent; private VMTemplateVO template; private boolean downloadActive = true; @@ -124,8 +122,9 @@ public class DownloadListener implements Listener { private final Map stateMap = new HashMap(); private Long templateHostId; - public DownloadListener(HostVO host, VMTemplateVO template, Timer _timer, VMTemplateHostDao dao, Long templHostId, DownloadMonitorImpl downloadMonitor, DownloadCommand cmd) { - this.sserver = host; + public DownloadListener(HostVO ssAgent, HostVO host, VMTemplateVO template, Timer _timer, VMTemplateHostDao dao, Long templHostId, DownloadMonitorImpl downloadMonitor, DownloadCommand cmd) { + this.ssAgent = ssAgent; + this.sserver = host; this.template = template; this.vmTemplateHostDao = dao; this.downloadMonitor = downloadMonitor; @@ -160,7 +159,7 @@ public class DownloadListener implements Listener { if (s_logger.isTraceEnabled()) { log("Sending progress command ", Level.TRACE); } - long sent = downloadMonitor.send(sserver.getId(), new DownloadProgressCommand(getCommand(), getJobId(), reqType), this); + long sent = downloadMonitor.send(ssAgent.getId(), new DownloadProgressCommand(getCommand(), getJobId(), reqType), this); if (sent == -1) { setDisconnected(); } diff --git a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java index 07fbbb844ce..f1f6434729d 100755 --- a/server/src/com/cloud/storage/download/DownloadMonitorImpl.java +++ b/server/src/com/cloud/storage/download/DownloadMonitorImpl.java @@ -244,7 +244,7 @@ public class DownloadMonitorImpl implements DownloadMonitor { s_logger.warn("There is no secondary storage VM for secondary storage host " + destServer.getName()); return false; } - DownloadListener dl = new DownloadListener(ssAhost, template, _timer, _vmTemplateHostDao, destTmpltHost.getId(), this, dcmd); + DownloadListener dl = new DownloadListener(ssAhost, destServer, template, _timer, _vmTemplateHostDao, destTmpltHost.getId(), this, dcmd); if (downloadJobExists) { dl.setCurrState(destTmpltHost.getDownloadState()); } @@ -328,7 +328,7 @@ public class DownloadMonitorImpl implements DownloadMonitor { s_logger.warn("There is no secondary storage VM for secondary storage host " + sserver.getName()); return; } - DownloadListener dl = new DownloadListener(ssAhost, template, _timer, _vmTemplateHostDao, vmTemplateHost.getId(), this, dcmd); + DownloadListener dl = new DownloadListener(ssAhost, sserver, template, _timer, _vmTemplateHostDao, vmTemplateHost.getId(), this, dcmd); if (downloadJobExists) { dl.setCurrState(vmTemplateHost.getDownloadState()); }