@Override public void progress(long bytesRead) { getController().logDebug("%d bytes of %s update downloaded...", bytesRead, m_type); }
m_controller.logDebug("Ignoring %s update %s => %s because max retries (%d) reached!", type, fromVersion, toVersion, maxRetries); return false; m_controller.logDebug("Ignoring %s update %s => %s because it failed previously!", type, fromVersion, toVersion); return false; m_controller.logDebug("Need to install update: newer %s version available!", type); return true; m_controller.logDebug("No need to install update: no newer %s version available!", type); return false;
@Override protected void onInit() throws Exception { getEventsHandler().addListener(this); // The controller is started *after* all other components, causing it to miss the initial configuration-update // event, hence we need to get the configuration ourselves for the first time... ConfigurationHandler config = getConfigurationHandler(); m_updateStreaming.set(config.getBoolean(CONFIG_CONTROLLER_STREAMING, m_updateStreaming.get())); m_fixPackage.set(config.getBoolean(CONFIG_CONTROLLER_FIXPACKAGES, m_fixPackage.get())); m_interval.set(config.getLong(CONFIG_CONTROLLER_SYNCINTERVAL, m_interval.get())); m_syncDelay.set(config.getLong(CONFIG_CONTROLLER_SYNCDELAY, m_syncDelay.get())); m_maxRetries.set(config.getLong(CONFIG_CONTROLLER_RETRIES, m_maxRetries.get())); logDebug("Config initialized: update: %s, fixPkg: %s, syncDelay: %d, syncInterval: %d, maxRetries: %d", m_updateStreaming.get(), m_fixPackage.get(), m_syncDelay.get(), m_interval.get(), m_maxRetries.get()); }
logDebug("Config changed: update: %s, fixPkg: %s, syncDelay: %d, syncInterval: %d, maxRetries: %d", m_updateStreaming.get(), m_fixPackage.get(), m_syncDelay.get(), m_interval.get(), m_maxRetries.get());
@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 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); } }
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); } } } }