/** * {@inheritDoc} */ @Override public String toString() { return getId() + " :: class: " + getClassName(); }
/** * {@inheritDoc} */ @Override public void update(ICoreService coreService) { long sensorTypeIdent = sensorTypeConfig.getId(); long currentTime = System.currentTimeMillis(); // Check if the collectData method should be invoked if (MapUtils.isNotEmpty(activeServerMap) && ((currentTime - lastDataCollectionTimestamp) > DATA_COLLECT_INTERVAL)) { // store the invocation timestamp lastDataCollectionTimestamp = System.currentTimeMillis(); for (MBeanServerHolder holder : activeServerMap.values()) { collectData(holder, coreService, sensorTypeIdent); } } }
ObjectName objectName = new ObjectName(testObjectName); when(sensorTypeConfig.getId()).thenReturn(sensorType); when(mBeanServer.queryNames(Matchers.<ObjectName> any(), (QueryExp) eq(null))).thenReturn(Collections.singleton(objectName)); when(mBeanServer.getMBeanInfo(Matchers.<ObjectName> any())).thenReturn(mBeanInfo);
ObjectName objectName = new ObjectName(testObjectName); when(sensorTypeConfig.getId()).thenReturn(sensorType); when(mBeanServer.queryNames(Matchers.<ObjectName> any(), (QueryExp) eq(null))).thenReturn(Collections.singleton(objectName)); when(mBeanServer.getMBeanInfo(Matchers.<ObjectName> any())).thenReturn(mBeanInfo);
ObjectName objectName = new ObjectName(testObjectName); when(sensorTypeConfig.getId()).thenReturn(sensorType); when(mBeanServer.queryNames(Matchers.<ObjectName> any(), (QueryExp) eq(null))).thenReturn(Collections.singleton(objectName)); when(mBeanServer.getMBeanInfo(Matchers.<ObjectName> any())).thenReturn(mBeanInfo);
ObjectName objectName = new ObjectName(testObjectName); when(sensorTypeConfig.getId()).thenReturn(sensorType); when(mBeanServer.queryNames(Matchers.<ObjectName> any(), (QueryExp) eq(null))).thenReturn(Collections.singleton(objectName)); when(mBeanServer.getMBeanInfo(Matchers.<ObjectName> any())).thenReturn(mBeanInfo);
ObjectName objectName = new ObjectName(testObjectName); when(sensorTypeConfig.getId()).thenReturn(sensorType); when(mBeanServer.queryNames(Matchers.<ObjectName> any(), (QueryExp) eq(null))).thenReturn(Collections.singleton(objectName)); when(mBeanServer.getMBeanInfo(Matchers.<ObjectName> any())).thenReturn(mBeanInfo);
ObjectName objectName = new ObjectName(testObjectName); when(sensorTypeConfig.getId()).thenReturn(sensorType); when(mBeanServer.queryNames(Matchers.<ObjectName> any(), (QueryExp) eq(null))).thenReturn(Collections.singleton(objectName)); when(mBeanServer.getMBeanInfo(Matchers.<ObjectName> any())).thenReturn(mBeanInfo);
@SuppressWarnings("unchecked") @Test public void configureJmxSensor() throws Exception { long agentId = 13L; long sensorId = 17L; String className = "className"; Map<String, Object> parameters = Collections.<String, Object> singletonMap("key", "value"); JmxSensorConfig jmxSensorConfig = mock(JmxSensorConfig.class); when(jmxSensorConfig.getClassName()).thenReturn(className); when(jmxSensorConfig.getParameters()).thenReturn(parameters); when(jmxSensorConfig.isActive()).thenReturn(true); when(environment.getJmxSensorConfig()).thenReturn(jmxSensorConfig); when(registrationService.registerJmxSensorTypeIdent(agentId, className)).thenReturn(sensorId); AgentConfig agentConfiguration = creator.environmentToConfiguration(environment, agentId); JmxSensorTypeConfig sensorTypeConfig = agentConfiguration.getJmxSensorTypeConfig(); assertThat(sensorTypeConfig.getId(), is(sensorId)); assertThat(sensorTypeConfig.getClassName(), is(className)); assertThat(sensorTypeConfig.getParameters(), is(parameters)); verify(registrationService).registerJmxSensorTypeIdent(agentId, className); // needed because of the intercepting server sensor verify(registrationService, times(3)).registerMethodSensorTypeIdent(anyLong(), anyString(), anyMap()); verifyNoMoreInteractions(registrationService); }
ObjectName objectName = new ObjectName(testObjectName); when(sensorTypeConfig.getId()).thenReturn(sensorType); when(mBeanServer.queryNames(Matchers.<ObjectName> any(), (QueryExp) eq(null))).thenReturn(Collections.singleton(objectName)); when(mBeanServer.getMBeanInfo(Matchers.<ObjectName> any())).thenReturn(mBeanInfo);
ObjectName objectName = new ObjectName(testObjectName); when(sensorTypeConfig.getId()).thenReturn(sensorType); when(mBeanServer.queryNames(Matchers.<ObjectName> any(), (QueryExp) eq(null))).thenReturn(Collections.singleton(objectName)); when(mBeanServer.getMBeanInfo(Matchers.<ObjectName> any())).thenReturn(mBeanInfo);
verify(mBeanServer).addNotificationListener(Matchers.<ObjectName> any(), notificationListener.capture(), Matchers.<NotificationFilter> any(), eq(null)); when(sensorTypeConfig.getId()).thenReturn(sensorType); when(mBeanServer.queryNames(Matchers.<ObjectName> any(), (QueryExp) eq(null))).thenReturn(Collections.singleton(objectName)); when(mBeanServer.getMBeanInfo(Matchers.<ObjectName> any())).thenReturn(mBeanInfo);