/** * {@inheritDoc} */ @Override public String getReadableString(Object object) { if (object instanceof JmxSensorValueData) { JmxSensorValueData data = (JmxSensorValueData) object; StringBuilder sb = new StringBuilder(); JmxDefinitionDataIdent jmxDefinitionDataIdent = cachedDataService.getJmxDefinitionDataIdentForId(data.getJmxSensorDefinitionDataIdentId()); for (Column column : Column.values()) { sb.append(getStyledTextForColumn(jmxDefinitionDataIdent, data, column).toString()); sb.append('\t'); } return sb.toString(); } throw new RuntimeException("Could not create the human readable string!"); }
/** * {@inheritDoc} */ @Override public List<String> getColumnValues(Object object) { if (object instanceof JmxSensorValueData) { JmxSensorValueData data = (JmxSensorValueData) object; JmxDefinitionDataIdent jmxDefinitionDataIdent = cachedDataService.getJmxDefinitionDataIdentForId(data.getJmxSensorDefinitionDataIdentId()); List<String> values = new ArrayList<>(); for (Column column : Column.values()) { values.add(getStyledTextForColumn(jmxDefinitionDataIdent, data, column).toString()); } return values; } throw new RuntimeException("Could not create the column values!"); }
/** * {@inheritDoc} */ @Override protected void addTags(JmxSensorValueData data, Builder builder) { super.addTags(data, builder); JmxDefinitionDataIdent jmxDefinitionDataIdent = cachedDataService.getJmxDefinitionDataIdentForId(data.getJmxSensorDefinitionDataIdentId()); if (null != jmxDefinitionDataIdent) { builder.tag(Series.Jmx.TAG_JMX_ATTRIBUTE_FULL_NAME, jmxDefinitionDataIdent.getDerivedFullName()); } }
jmxIdent = cachedDataService.getJmxDefinitionDataIdentForId(jmxData.getJmxSensorDefinitionDataIdentId());
@Test public void noJmxIdent() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); when(cachedDataService.getJmxDefinitionDataIdentForId(JMX_IDENT)).thenReturn(null); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getJmxSensorDefinitionDataIdentId()).thenReturn(JMX_IDENT); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Jmx.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), not(hasKey(Series.Jmx.TAG_JMX_ATTRIBUTE_FULL_NAME))); assertThat(getFields(pointBuilder), hasEntry(Series.Jmx.FIELD_VALUE, (Object) data.getValueAsDouble())); }
@Test public void noPlatform() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(null); when(cachedDataService.getJmxDefinitionDataIdentForId(JMX_IDENT)).thenReturn(jmxDefinitionDataIdent); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getJmxSensorDefinitionDataIdentId()).thenReturn(JMX_IDENT); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Jmx.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), not(hasKey(Series.TAG_AGENT_NAME))); assertThat(getFields(pointBuilder), hasEntry(Series.Jmx.FIELD_VALUE, (Object) data.getValueAsDouble())); }
@Test public void happyPath() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); when(cachedDataService.getJmxDefinitionDataIdentForId(JMX_IDENT)).thenReturn(jmxDefinitionDataIdent); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getJmxSensorDefinitionDataIdentId()).thenReturn(JMX_IDENT); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getValueAsDouble()).thenReturn(RandomUtils.nextDouble()); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Jmx.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_ID, String.valueOf(PLATFORM_ID))); assertThat(getTags(pointBuilder), hasEntry(Series.TAG_AGENT_NAME, String.valueOf(AGENT_NAME))); assertThat(getTags(pointBuilder), hasEntry(Series.Jmx.TAG_JMX_ATTRIBUTE_FULL_NAME, String.valueOf(JMX_ATTR))); assertThat(getFields(pointBuilder), hasEntry(Series.Jmx.FIELD_VALUE, (Object) data.getValueAsDouble())); }
JmxDefinitionDataIdent jmxIdent1 = cachedDataService.getJmxDefinitionDataIdentForId(o1.getJmxSensorDefinitionDataIdentId()); JmxDefinitionDataIdent jmxIdent2 = cachedDataService.getJmxDefinitionDataIdentForId(o2.getJmxSensorDefinitionDataIdentId());
/** * {@inheritDoc} */ @Override public void setInputDefinition(InputDefinition inputDefinition) { super.setInputDefinition(inputDefinition); template = new JmxSensorValueData(); template.setPlatformIdent(inputDefinition.getIdDefinition().getPlatformId()); template.setSensorTypeIdent(inputDefinition.getIdDefinition().getSensorTypeId()); template.setJmxSensorDefinitionDataIdentId(inputDefinition.getIdDefinition().getJmxDefinitionId()); cachedDataService = inputDefinition.getRepositoryDefinition().getCachedDataService(); globalDataAccessService = inputDefinition.getRepositoryDefinition().getGlobalDataAccessService(); currentJmxIdent = cachedDataService.getJmxDefinitionDataIdentForId(inputDefinition.getIdDefinition().getJmxDefinitionId()); plotDataSolver = getCurrentDataSolver(); }
JmxDefinitionDataIdent jmxIdent = inputDefinition.getRepositoryDefinition().getCachedDataService().getJmxDefinitionDataIdentForId(inputDefinition.getIdDefinition().getJmxDefinitionId());
JmxDefinitionDataIdent jmxIdent = repositoryDefinition.getCachedDataService().getJmxDefinitionDataIdentForId(jmxValueData.getJmxSensorDefinitionDataIdentId());
/** * {@inheritDoc} */ @Override public DetailsTable generate(DefaultData defaultData, RepositoryDefinition repositoryDefinition, Composite parent, FormToolkit toolkit) { JmxSensorValueData jmxSensorData = (JmxSensorValueData) defaultData; JmxDefinitionDataIdent jmxData = repositoryDefinition.getCachedDataService().getJmxDefinitionDataIdentForId(jmxSensorData.getJmxSensorDefinitionDataIdentId()); DetailsTable table = new DetailsTable(parent, toolkit, "MBean Details", 1); table.addContentRow("Domain:", InspectIT.getDefault().getImage(InspectITImages.IMG_PACKAGE), new DetailsCellContent[] { new DetailsCellContent(jmxData.getDerivedDomainName()) }); table.addContentRow("Type:", InspectIT.getDefault().getImage(InspectITImages.IMG_BOOK), new DetailsCellContent[] { new DetailsCellContent(jmxData.getDerivedTypeName()) }); table.addContentRow("Attribute:", InspectIT.getDefault().getImage(InspectITImages.IMG_BLUE_DOCUMENT_TABLE), new DetailsCellContent[] { new DetailsCellContent(jmxData.getmBeanAttributeName()) }); table.addContentRow("Description:", InspectIT.getDefault().getImage(InspectITImages.IMG_INFORMATION), new DetailsCellContent[] { new DetailsCellContent(jmxData.getmBeanAttributeDescription()) }); table.addContentRow("Type:", null, new DetailsCellContent[] { new DetailsCellContent(jmxData.getmBeanAttributeType()) }); table.addContentRow("Value:", null, new DetailsCellContent[] { new DetailsCellContent(jmxSensorData.getValue()) }); table.addContentRow("Readable:", null, new DetailsCellContent[] { new YesNoDetailsCellContent(jmxData.getmBeanAttributeIsReadable()) }); table.addContentRow("Writeable:", null, new DetailsCellContent[] { new YesNoDetailsCellContent(jmxData.getmBeanAttributeIsWritable()) }); table.addContentRow("Is-Getter:", null, new DetailsCellContent[] { new YesNoDetailsCellContent(jmxData.getmBeanAttributeIsIs()) }); return table; } }