/** * {@inheritDoc} */ @Override public Object getAggregationKey(JmxSensorValueData object) { return object.getJmxSensorDefinitionDataIdentId(); }
/** * Copy constructor. Copies all values (except the aggregation values) of the given * {@link JmxSensorValueData} object into the newly created. * * @param origin * object to clone */ public JmxSensorValueData(JmxSensorValueData origin) { setId(origin.getId()); setPlatformIdent(origin.getPlatformIdent()); setTimeStamp(new Timestamp(origin.getTimeStamp().getTime())); setSensorTypeIdent(origin.getSensorTypeIdent()); setJmxSensorDefinitionDataIdentId(origin.jmxSensorDefinitionDataIdentId); setValue(origin.value); }
/** * {@inheritDoc} */ @Override public JmxSensorValueData getClone(JmxSensorValueData object) { return new JmxSensorValueData(object); }
/** * {@inheritDoc} */ @Override public String toString() { return "JmxSensorValueData [jmxSensorDefinitionDataIdent=" + jmxSensorDefinitionDataIdentId + ", value=" + value + ", getId()=" + getId() + ", getPlatformIdent()=" + getPlatformIdent() + ", getSensorTypeIdent()=" + getSensorTypeIdent() + ", getTimeStamp()=" + getTimeStamp() + "]"; }
/** * Sets the {@link #value}. * * @param value * New value for {@link #value}. */ public void setValue(String value) { this.value = value; if ((aggregationCount <= 0) && isBooleanOrNumeric()) { double currentValue = getValueAsDouble(); aggregationCount = 1; minValue = currentValue; maxValue = currentValue; totalValue = currentValue; } }
verify(coreService).addDefaultData(valueCaptor.capture()); assertThat(valueCaptor.getValue().getPlatformIdent(), is(equalTo(platformIdent))); assertThat(valueCaptor.getValue().getSensorTypeIdent(), is(equalTo(sensorType))); assertThat(valueCaptor.getValue().getJmxSensorDefinitionDataIdentId(), is(equalTo(definitionDataIdentId))); assertThat(valueCaptor.getValue().getValue(), is("[1, 2, 3]"));
@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())); }
if (template.getPlatformIdent() > 0) { query.setPlatformIdent(template.getPlatformIdent()); if (template.getSensorTypeIdent() > 0) { query.setSensorTypeIdent(template.getSensorTypeIdent()); if (template.getJmxSensorDefinitionDataIdentId() > 0) { query.addIndexingRestriction(IndexQueryRestrictionFactory.equal("jmxSensorDefinitionDataIdentId", template.getJmxSensorDefinitionDataIdentId())); if (map.containsKey(jmxData.getJmxSensorDefinitionDataIdentId())) { if (map.get(jmxData.getJmxSensorDefinitionDataIdentId()).getTimeStamp().getTime() < data.getTimeStamp().getTime()) { map.put(jmxData.getJmxSensorDefinitionDataIdentId(), (JmxSensorValueData) data); map.put(jmxData.getJmxSensorDefinitionDataIdentId(), (JmxSensorValueData) data);
@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(); }
Root<JmxSensorValueData> sqRoot = sq.from(JmxSensorValueData.class); Predicate platformIdentPredicate = cb.equal(sqRoot.get("platformIdent"), template.getPlatformIdent()); Predicate sensorTypeIdentPredicate = cb.equal(sqRoot.get("sensorTypeIdent"), template.getSensorTypeIdent()); Predicate predicate = cb.and(platformIdentPredicate, sensorTypeIdentPredicate); if (template.getJmxSensorDefinitionDataIdentId() > 0) { predicate = cb.and(predicate, cb.equal(sqRoot.get("jmxSensorDefinitionDataIdentId"), template.getJmxSensorDefinitionDataIdentId()));
switch (this) { case VALUE: return o1.getValue().compareTo(o2.getValue()); case CHARTING: return BooleanUtils.toBooleanObject(o1.isBooleanOrNumeric()).compareTo(o2.isBooleanOrNumeric()); default: break; JmxDefinitionDataIdent jmxIdent1 = cachedDataService.getJmxDefinitionDataIdentForId(o1.getJmxSensorDefinitionDataIdentId()); JmxDefinitionDataIdent jmxIdent2 = cachedDataService.getJmxDefinitionDataIdentForId(o2.getJmxSensorDefinitionDataIdentId());
JmxDefinitionDataIdent jmxIdent = repositoryDefinition.getCachedDataService().getJmxDefinitionDataIdentForId(jmxValueData.getJmxSensorDefinitionDataIdentId()); idDefinition.setSensorTypeId(jmxValueData.getSensorTypeIdent()); idDefinition.setJmxDefinitionId(jmxIdent.getId());
@Test public void jmxNotNumeric() { JmxSensorValueData data = new JmxSensorValueData(); data.setValue("string value"); when(influxDBDao.isConnected()).thenReturn(true); doReturn(Collections.singleton(JmxSensorValueData.class)).when(pointBuilder).getDataClasses(); processor = new InfluxProcessor(influxDBDao, Collections.<IPointBuilder<DefaultData>> singletonList(pointBuilder)); processor.process(data, entityManager); verify(influxDBDao).isConnected(); verify(pointBuilder).getDataClasses(); verifyNoMoreInteractions(influxDBDao, pointBuilder); verifyZeroInteractions(entityManager); }
/** * {@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; } }
/** * Returns the styled text for a specific column. * * @param jmxDefinitionDataIdent * The object to extract the information from. * @param data * The object to extract the value information from. * @param enumId * The enumeration ID. * @return The styled string containing the information from the data object. */ private StyledString getStyledTextForColumn(JmxDefinitionDataIdent jmxDefinitionDataIdent, JmxSensorValueData data, Column enumId) { switch (enumId) { case DOMAINNAME: return new StyledString(jmxDefinitionDataIdent.getDerivedDomainName()); case TYPENAME: return new StyledString(jmxDefinitionDataIdent.getDerivedTypeName()); case ATTRIBUTE: return new StyledString(jmxDefinitionDataIdent.getmBeanAttributeName()); case TIMESTAMP: return new StyledString(NumberFormatter.formatTime(data.getTimeStamp())); case VALUE: return new StyledString(data.getValue()); case CHARTING: return emptyStyledString; default: return new StyledString("error"); } }
/** * Gets {@link #minValue}. * * @return {@link #minValue} */ public double getMinValue() { if (aggregationCount <= 0) { return getValueAsDouble(); } return minValue; }
@Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (receiver instanceof JmxSensorValueData) { JmxSensorValueData jmxData = (JmxSensorValueData) receiver; if ("canChart".equals(property)) { return jmxData.isBooleanOrNumeric(); } } return false; }
/** * Constructor. * * @param jmxDefinitionDataIdentId * the id of the related {@link JmxDefinitionDataIdent} of this * {@link JmxSensorValueData} * @param value * the value * @param timestamp * the timestamp when this value was captured * @param platformIdent * the id of the related {@link PlatformIdent} * @param sensorTypeIdent * the id of the related {@link SensorTypeIdent} */ public JmxSensorValueData(long jmxDefinitionDataIdentId, String value, Timestamp timestamp, long platformIdent, long sensorTypeIdent) { setJmxSensorDefinitionDataIdentId(jmxDefinitionDataIdentId); setValue(value); super.setTimeStamp(timestamp); super.setPlatformIdent(platformIdent); super.setSensorTypeIdent(sensorTypeIdent); super.setId(jmxDefinitionDataIdentId); }
/** * Returns the date of the latest element in the {@link #loadedData} list. * * @return Date of the latest loaded {@link JmxSensorValueData} */ private Date getLatestLoadedElementDate() { if (CollectionUtils.isEmpty(loadedData)) { return null; } long max = Long.MIN_VALUE; for (JmxSensorValueData data : loadedData) { if (data.getTimeStamp().getTime() > max) { max = data.getTimeStamp().getTime(); } } return new Date(max); }
verify(coreService).addDefaultData(valueCaptor.capture()); assertThat(valueCaptor.getValue().getPlatformIdent(), is(equalTo(platformIdent))); assertThat(valueCaptor.getValue().getSensorTypeIdent(), is(equalTo(sensorType))); assertThat(valueCaptor.getValue().getJmxSensorDefinitionDataIdentId(), is(equalTo(definitionDataIdentId))); assertThat(valueCaptor.getValue().getValue(), is("null"));