private void runAgentUpdate() throws RetryAfterException, InterruptedException { if (isInterrupted()) { throw new InterruptedException("Controller was interrupted, not running agent updates check..."); } logDebug("Checking for agent updates..."); long maxRetries = m_maxRetries.get(); boolean fixPackage = m_fixPackage.get(); UpdateInstaller updateInstaller = getUpdateInstaller(); try { updateInstaller.installUpdate(getAgentUpdateHandler(), fixPackage, maxRetries); } catch (IOException e) { logError("Agent update aborted due to Exception.", e); } }
private void runDeploymentUpdate() throws RetryAfterException, InterruptedException { if (isInterrupted()) { throw new InterruptedException("Controller was interrupted, not running deployment updates check..."); } logDebug("Checking for deployment updates..."); long maxRetries = m_maxRetries.get(); boolean fixPackage = m_fixPackage.get(); UpdateInstaller updateInstaller = getUpdateInstaller(); try { updateInstaller.installUpdate(getDeploymentHandler(), fixPackage, maxRetries); } catch (IOException e) { logError("Deployment update aborted due to Exception.", e); } }
@Override public void run() { long interval = m_syncDelay.get(); while (!isInterrupted()) { try { logDebug("Scheduling controller to run in %d seconds...", interval); TimeUnit.SECONDS.sleep(interval); logDebug("Controller syncing..."); runFeedback(); runAgentUpdate(); runDeploymentUpdate(); interval = m_interval.get(); logDebug("Sync completed..."); } catch (RetryAfterException e) { // any method may throw this causing the sync to abort. The server is busy so no sense in trying // anything else until the retry window has passed. interval = e.getBackoffTime(); logWarning("Sync received retry exception from server. Rescheduled in %d seconds...", interval); } catch (InterruptedException exception) { logDebug(exception.getMessage()); // Ok; break out of our main loop... Thread.currentThread().interrupt(); } } }
private void runFeedback() throws RetryAfterException, InterruptedException { if (isInterrupted()) { throw new InterruptedException("Controller was interrupted, not running feedback synchronization..."); } Set<String> names = getFeedbackChannelNames(); logDebug("Synchronizing feedback channels: %s", names); for (String name : names) { FeedbackChannel channel = getFeedbackChannel(name); if (channel != null) { try { channel.sendFeedback(); logDebug("Feedback send succesfully for channel: %s", name); } catch (IOException e) { // Hopefully temporary problem due to remote IO or configuration. No cause to abort the sync so we // just log it as a warning. logWarning("Exception while sending feedback for channel: %s", e, name); } } } }