-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Speed up SSVM startup time by postponing checks #4641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -121,6 +143,7 @@ protected void runInContext() { | |
|
|
||
| private StatusTask _statusTask; | ||
| private TimeoutTask _timeoutTask; | ||
| private PostConnectTask _postConnectTask; | ||
| private Date _lastUpdated = new Date(); | ||
| private String jobId; | ||
|
|
||
|
|
@@ -210,6 +233,7 @@ public void log(String message, Level level) { | |
|
|
||
| public DownloadListener(DownloadMonitorImpl monitor) { | ||
| _downloadMonitor = monitor; | ||
| _timer = new Timer(); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -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(); | ||
|
|
||
| _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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is only ever called with a |
||
| try{ | ||
| List<DataStore> imageStores = _storeMgr.getImageStoresByScopeExcludingReadOnly(new ZoneScope(agent.getDataCenterId())); | ||
| for (DataStore store : imageStores) { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.