@Override public void onRecordReceived(final IMonitoringRecord record) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Received new record: {}", record.getClass().getName()); } if (!(record instanceof IRemoteControlEvent)) { LOGGER.info("Received an event for the TCP monitoring controller, which is no remote control event"); } final String pattern = ((IRemoteControlEvent) record).getPattern(); if (record instanceof DeactivationEvent) { this.monitoringController.deactivateProbe(pattern); this.monitoringController.deleteParameterEntry(pattern); } else if (record instanceof ActivationParameterEvent) { final Map<String, List<String>> parameterMap = this.extractParameters((IRemoteParameterControlEvent) record); this.monitoringController.addCompletePatternParameters(pattern, parameterMap); this.monitoringController.activateProbe(pattern); } else if (record instanceof ActivationEvent) { this.monitoringController.deleteParameterEntry(pattern); this.monitoringController.activateProbe(pattern); } else if (record instanceof UpdateParameterEvent) { final Map<String, List<String>> parameterMap = this.extractParameters((IRemoteParameterControlEvent) record); this.monitoringController.addCompletePatternParameters(pattern, parameterMap); } else { LOGGER.info("Received unknown remote control event: {}", record.getClass().getName()); } }
Assert.assertThat(monCtrl.activateProbe("*"), CoreMatchers.is(true)); this.client.searchBook("any"); // only the server side monitoring is active NamedListWriter.awaitListSize(this.recordListFilledByListWriter, 4, TIMEOUT_IN_MS); Assert.assertThat(monCtrl.activateProbe(clientPattern), CoreMatchers.is(true)); this.client.searchBook("any"); // both the server side and the client side monitoring is active NamedListWriter.awaitListSize(this.recordListFilledByListWriter, 6, TIMEOUT_IN_MS);
Assert.assertEquals("Unexpected number of triggering events while probe being disabled", 0, numEventsWhileProbeDisabled); this.monitoringController.activateProbe(this.jvmSignature); // REACTIVATION (probe)
@Test(timeout = 30000) public void testParameterSettingUpdateAndDelete() throws IOException { final MonitoringController controller = MonitoringController.createInstance(TCPControllerTest.configuration); final String pattern = "void test.pattern()"; final String[] parameterNames = new String[] { "Pos1", "Pos2", "Pos3" }; // TODO currently there is a bug in the generated code which makes it unable to handle different dimension sizes // final String[][] parameters = new String[][] { { "Pos1Parameter1", "Pos1Parameter2" }, // { "Pos2Parameter1", "Pos2Parameter2", "Pos2Parameter3", "Pos2Parameter4" }, { "Pos3Parameter1" } }; final String[][] parameters = new String[][] { { "Pos1Parameter1", "Pos1Parameter2", "Pos1Parameter3", "Pos1Parameter4" }, { "Pos2Parameter1", "Pos2Parameter2", "Pos2Parameter3", "Pos2Parameter4" }, { "Pos3Parameter1", "Pos3Parameter2", "Pos3Parameter3", "Pos3Parameter4" } }; this.tcpWriter = new SingleSocketTcpWriter(configuration); this.tcpWriter.onStarting(); Assert.assertTrue(controller.activateProbe(pattern)); Assert.assertNull(controller.getParameters(pattern)); this.sendTCPEvent(new UpdateParameterEvent(pattern, parameterNames, parameters)); while ((controller.getParameters(pattern) == null)) { Thread.yield(); } Assert.assertTrue(controller.getParameters(pattern).size() == 3); Assert.assertTrue(controller.getParameters(pattern).get(parameterNames[0]).get(1).equals(parameters[0][1])); Assert.assertTrue(controller.getParameters(pattern).get(parameterNames[1]).get(2).equals(parameters[1][2])); Assert.assertTrue(controller.getParameters(pattern).get(parameterNames[2]).get(0).equals(parameters[2][0])); this.sendTCPEvent(new DeactivationEvent(pattern)); while (controller.getParameters(pattern) != null) { Thread.yield(); } Assert.assertNull(controller.getParameters(pattern)); }
@Test(timeout = 30000) public void testActivationAndDeactivation() throws IOException, InterruptedException { final MonitoringController controller = MonitoringController.createInstance(TCPControllerTest.configuration); final String pattern = "void test.pattern()"; this.tcpWriter = new SingleSocketTcpWriter(configuration); this.tcpWriter.onStarting(); Assert.assertTrue(controller.activateProbe(pattern)); controller.deactivateProbe(pattern); Assert.assertFalse(controller.isProbeActivated(pattern)); this.sendTCPEvent(new ActivationEvent(pattern)); while (!controller.isProbeActivated(pattern)) { Thread.yield(); } Assert.assertTrue(controller.isProbeActivated(pattern)); this.sendTCPEvent(new DeactivationEvent(pattern)); while (controller.isProbeActivated(pattern)) { Thread.yield(); } Assert.assertFalse(controller.isProbeActivated(pattern)); controller.cleanup(); this.tcpWriter.onTerminating(); }