mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
bug 9958:
1. send purge command only once. 2. in downloadlistener, there are two hosts, one is secondary storage host, the other is secondary storage VM host for this secondary storage. status 9958: resolved fixed
This commit is contained in:
parent
24932a9fec
commit
9d758866af
@ -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:
|
||||
|
||||
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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<String, DownloadState> stateMap = new HashMap<String, DownloadState>();
|
||||
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();
|
||||
}
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user