Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,28 @@ protected void runInContext() {
}
}

private static final class PostConnectTask extends ManagedContextTimerTask {
private final DownloadListener dl;
private final Host agent;
private final StartupCommand cmd;

private PostConnectTask(DownloadListener dl, Host agent, StartupCommand cmd) {
this.dl = dl;
this.agent = agent;
this.cmd = cmd;
}

@Override
protected void runInContext() {
try {
dl.postConnect(agent, cmd);
} catch (ConnectionException ex) {
s_logger.warn("There is an error in the postConnect process for " +
agent.getId() + " due to " + ex.getMessage());
}
}
}

public static final Logger s_logger = Logger.getLogger(DownloadListener.class.getName());
public static final int SMALL_DELAY = 100;
public static final long STATUS_POLL_INTERVAL = 10000L;
Expand All @@ -121,6 +143,7 @@ protected void runInContext() {

private StatusTask _statusTask;
private TimeoutTask _timeoutTask;
private PostConnectTask _postConnectTask;
private Date _lastUpdated = new Date();
private String jobId;

Expand Down Expand Up @@ -210,6 +233,7 @@ public void log(String message, Level level) {

public DownloadListener(DownloadMonitorImpl monitor) {
_downloadMonitor = monitor;
_timer = new Timer();
}

@Override
Expand Down Expand Up @@ -284,18 +308,22 @@ public void processConnect(Host agent, StartupCommand cmd, boolean forRebalance)
_imageSrv.handleSysTemplateDownload(hostHyper, agent.getDataCenterId());
// update template_zone_ref for cross-zone templates
_imageSrv.associateCrosszoneTemplatesToZone(agent.getDataCenterId());
} else if (cmd instanceof StartupSecondaryStorageCommand) {
s_logger.debug("Scheduling postConnect task at " + STATUS_POLL_INTERVAL + " ms");
schedulePostConnectTask(agent, cmd, STATUS_POLL_INTERVAL);
}
/* This can be removed
else if ( cmd instanceof StartupStorageCommand) {
StartupStorageCommand storage = (StartupStorageCommand)cmd;
if( storage.getResourceType() == Storage.StorageResourceType.SECONDARY_STORAGE ||
storage.getResourceType() == Storage.StorageResourceType.LOCAL_SECONDARY_STORAGE ) {
downloadMonitor.addSystemVMTemplatesToHost(agent, storage.getTemplateInfo());
downloadMonitor.handleTemplateSync(agent);
downloadMonitor.handleVolumeSync(agent);
}
}*/
else if (cmd instanceof StartupSecondaryStorageCommand) {
}

private void schedulePostConnectTask(Host agent, StartupCommand cmd, long delay) {
if (_postConnectTask != null)
_postConnectTask.cancel();
Comment on lines +318 to +319
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this only ever working on one dowload job? it seems we are canceling the download check for someone else here.


_postConnectTask = new PostConnectTask(this, agent, cmd);
_timer.schedule(_postConnectTask, delay);
}

private void postConnect(Host agent, StartupCommand cmd) throws ConnectionException {
if (cmd instanceof StartupSecondaryStorageCommand) {
Comment on lines +325 to +326
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is only ever called with a StartupSecondaryStorageCommand so can we change the parameter type and skip the class check?

try{
List<DataStore> imageStores = _storeMgr.getImageStoresByScopeExcludingReadOnly(new ZoneScope(agent.getDataCenterId()));
for (DataStore store : imageStores) {
Expand Down