private String getTargetID() { IdentificationHandler idHandler = m_agentContext.getHandler(IdentificationHandler.class); return idHandler.getAgentId(); }
private void logError(String msg, Exception cause, Object... args) { m_agentContext.getHandler(LoggingHandler.class).logError("feedbackChannel(" + m_name + ")", msg, cause, args); }
private URL getServerURL() { return m_agentContext.getHandler(DiscoveryHandler.class).getServerUrl(); }
@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); }
@Test public void testSuccessful_noresume_result() throws Exception { DownloadHandler downloadHandler = m_agentContext.getHandler(DownloadHandler.class); DownloadHandle handle = downloadHandler.getHandle(m_200url); handle.discard(); Future<DownloadResult> result = handle.start(null); assertSuccessful(result, m_200digest); }
@Test public void testFailed503_noresume_result() throws Exception { DownloadHandler downloadHandler = m_agentContext.getHandler(DownloadHandler.class); DownloadHandle handle = downloadHandler.getHandle(m_503url); assertRetryException(handle.start(null)); assertRetryException(handle.start(null)); }
@Test public void testFailed404_noresume_result() throws Exception { DownloadHandler downloadHandler = m_agentContext.getHandler(DownloadHandler.class); DownloadHandle handle = downloadHandler.getHandle(m_404url); Future<DownloadResult> future = handle.start(null); assertIOException(future); }
protected URL getServerURL() throws RetryAfterException { // FIXME not sure if this is the proper place URL serverURL = getDiscoveryHandler().getServerUrl(); if (serverURL == null) { throw new RetryAfterException(10); } return serverURL; }
@Override public FeedbackHandler getFeedbackHandler() { return m_agentContext.getHandler(FeedbackHandler.class); } }
protected void stopHandler(Object handler) throws Exception { if (handler instanceof AgentContextAware) { ((AgentContextAware) handler).stop(); } }
protected void startHandler(Object handler, AgentContext agentContext) throws Exception { if (handler instanceof AgentContextAware) { ((AgentContextAware) handler).start(agentContext); } }
@Override public void progress(long bytesRead) { handle.stop(); } });
@Test public void testSuccessful_resume_result() throws Exception { DownloadHandler downloadHandler = m_agentContext.getHandler(DownloadHandler.class); final DownloadHandle handle = downloadHandler.getHandle(m_200url); handle.discard(); Future<DownloadResult> future = handle.start(new DownloadProgressListener() { @Override public void progress(long read) { Thread.currentThread().interrupt(); } }); assertStopped(future); assertSuccessful(handle.start(null), m_200digest); }
@Override public String getAgentId() { return m_agentContext.getHandler(IdentificationHandler.class).getAgentId(); }
@Override public ConfigurationHandler getConfigurationHandler() { return m_agentContext.getHandler(ConfigurationHandler.class); }
private String getIdentification() { return m_agentContext.getHandler(IdentificationHandler.class).getAgentId(); }
@Override public DeploymentHandler getDeploymentHandler() { return m_agentContext.getHandler(DeploymentHandler.class); }
@Override public AgentUpdateHandler getAgentUpdateHandler() { return m_agentContext.getHandler(AgentUpdateHandler.class); }
private ConnectionHandler getConnectionHandler() { return m_agentContext.getHandler(ConnectionHandler.class); }
private LoggingHandler getLoggingHandler() { return m_agentContext.getHandler(LoggingHandler.class); }