private void registerFeedbackChannel(String channelName) throws IOException { FeedbackChannelImpl channel = new FeedbackChannelImpl(getAgentContext(), channelName); m_channels.putIfAbsent(channelName, channel); }
private void logWarning(String msg, Object... args) { getLoggingHandler().logWarning("feedbackChannel(" + m_name + ")", msg, null, args); }
private void unregisterFeedbackChannel(String oldChannelName) throws IOException { FeedbackChannelImpl channel = m_channels.remove(oldChannelName); if (channel != null) { channel.stop(); } } }
@Override public void sendFeedback() throws RetryAfterException, IOException { String identification = getIdentification(); URL serverURL = getServerURL(); logWarning("No identification or server URL present, cannot send feedback!"); return; ConnectionHandler connectionHandler = getConnectionHandler(); URLConnection sendConnection = null; Writer writer = null; URLConnection queryConnection = connectionHandler.getConnection(queryURL); try { synchronizeStore(storeID, queryConnection.getInputStream(), writer);
@Test public void testSendFeedback() throws Exception { TestSendFeedbackServlet sendServlet = new TestSendFeedbackServlet(); m_webServer.addServlet(sendServlet, "/test/send"); TestQueryFeedbackServlet queryServlet = new TestQueryFeedbackServlet(); m_webServer.addServlet(queryServlet, "/test/query"); m_feedbackChannelImpl.write(1, new HashMap<String, String>()); m_feedbackChannelImpl.sendFeedback(); assertEquals(sendServlet.m_events.size(), 1); } }
SortedRangeSet remoteRange = getQueryDescriptor(queryInput).getRangeSet(); SortedRangeSet delta = remoteRange.diffDest(localRange); RangeIterator rangeIterator = delta.iterator(); String identification = getIdentification(); for (Event current : events) { while ((current.getID() > lowest) && rangeIterator.hasNext()) {
@BeforeMethod public void setUpAgain(Method method) throws Exception { // this setup is needed because a real Feedbackstore is initialized in the constructor. m_agentContext = mockAgentContext(); URL serverURL = new URL("http://localhost:" + PORT + "/"); m_webServer = new TestWebServer(PORT, "/", "generated"); m_webServer.start(); DiscoveryHandler discoveryHandler = addTestMock(DiscoveryHandler.class); expect(discoveryHandler.getServerUrl()).andReturn(serverURL).anyTimes(); IdentificationHandler identificationHandler = addTestMock(IdentificationHandler.class); expect(identificationHandler.getAgentId()).andReturn("identification").anyTimes(); replayTestMocks(); m_agentContext.setHandler(DiscoveryHandler.class, discoveryHandler); m_agentContext.setHandler(IdentificationHandler.class, identificationHandler); m_agentContext.setHandler(ConnectionHandler.class, new ConnectionHandlerImpl()); m_feedbackChannelImpl = new FeedbackChannelImpl(m_agentContext, "test"); m_agentContext.start(); }