@Override protected void onInit() throws Exception { getEventsHandler().addListener(this); }
protected void sendDeploymentCompletedEvent(UpdateInfo updateInfo, boolean success, Throwable throwable) { Map<String, String> eventProps = new HashMap<>(); eventProps.put("type", updateInfo.m_type); eventProps.put("name", getIdentificationHandler().getAgentId()); eventProps.put("fromVersion", updateInfo.m_from.toString()); eventProps.put("toVersion", updateInfo.m_to.toString()); eventProps.put("fixPackage", Boolean.toString(updateInfo.m_fixPackage)); eventProps.put("successful", Boolean.toString(success)); if (throwable != null) { eventProps.put("exception", throwable.getMessage()); } getEventsHandler().postEvent(AGENT_INSTALLATION_COMPLETE, eventProps); }
@Override protected void onStop() throws Exception { getEventsHandler().removeListener(this); m_checkedURLs.clear(); }
private void fireConfigChangeEventSynchronously() { getEventsHandler().sendEvent(EVENT_AGENT_CONFIG_CHANGED, getConfigurationSnapshot()); }
@Override public void sendEvent(Event event) { getEventsHandler().sendEvent(event.getTopic(), getPayload(event)); invokeExternalEventAdmin("sendEvent", event); }
@Override protected void onInit() throws Exception { getEventsHandler().addListener(this); }
@Override protected void onStop() throws Exception { getEventsHandler().removeListener(this); }
protected void sendDeploymentInstallEvent(UpdateInfo updateInfo) { Map<String, String> eventProps = new HashMap<>(); eventProps.put("type", updateInfo.m_type); eventProps.put("name", getIdentificationHandler().getAgentId()); eventProps.put("fromVersion", updateInfo.m_from.toString()); eventProps.put("toVersion", updateInfo.m_to.toString()); eventProps.put("fixPackage", Boolean.toString(updateInfo.m_fixPackage)); getEventsHandler().postEvent(AGENT_INSTALLATION_START, eventProps); }
@Override protected void onInit() throws Exception { getEventsHandler().addListener(this); }
@Override protected void onStop() throws Exception { getEventsHandler().removeListener(this); }
private void fireConfigChangeEventAsynchronously() { getEventsHandler().postEvent(EVENT_AGENT_CONFIG_CHANGED, getConfigurationSnapshot()); }
@Override protected void onInit() throws Exception { getEventsHandler().addListener(this); }
@Override protected void onStop() throws Exception { if (m_isStarted.compareAndSet(true, false)) { getEventsHandler().removeListener(this); m_bundleContext.removeBundleListener(this); m_bundleContext.removeFrameworkListener(this); } }
@Override public void postEvent(Event event) { getEventsHandler().postEvent(event.getTopic(), getPayload(event)); invokeExternalEventAdmin("postEvent", event); }
@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()); }
@Override protected void onStop() throws Exception { EventsHandler eventsHandler = getEventsHandler(); if (eventsHandler != null) { eventsHandler.removeListener(this); } if (m_updateInstaller != null) { m_updateInstaller.reset(); m_updateInstaller = null; } }
@Override protected void onInit() throws Exception { String urls = getConfigurationHandler().get(CONFIG_DISCOVERY_SERVERURLS, mergeUrls(m_defaultServerURLs)); boolean checkServerURLs = getConfigurationHandler().getBoolean(CONFIG_DISCOVERY_CHECKING, DEFAULT_CHECK_SERVER_URLS); m_defaultServerURLs = m_serverURLs = splitUrls(urls); // ACE-520 - checking URLs only makes sense if there is more than one URL available... m_defaultCheckURLs = m_checkURLs = checkServerURLs && m_defaultServerURLs.size() > 1; getEventsHandler().addListener(this); }
@Override protected void onStop() throws Exception { getEventsHandler().removeListener(this); for (String channelName : getChannelNames()) { try { unregisterFeedbackChannel(channelName); } catch (IOException exception) { logWarning("Failed to close feedback channel '%s'", exception, channelName); } } }
@BeforeMethod(alwaysRun = true) public void reset() throws Exception { // create a new eventlogger for every test m_eventLogger = new EventLoggerImpl(mockBundleContext()); m_eventLogger.init(m_agentContext); m_eventsHandler.addListener(m_eventLogger); m_eventLogger.start(m_agentContext); // reset the previously logged data in our mock feedbackchannel. No need to create a new one here FeedbackHandler feedbackHandler = m_agentContext.getHandler(FeedbackHandler.class); TestFeedbackChannel channel = (TestFeedbackChannel) feedbackHandler.getChannel("auditlog"); channel.reset(); }