/** * {@inheritDoc} */ @Override public SystemSensorData get() { ClassLoadingInformationData newClassLoadingInformationData = new ClassLoadingInformationData(); newClassLoadingInformationData.setPlatformIdent(this.classLoadingInformationData.getPlatformIdent()); newClassLoadingInformationData.setSensorTypeIdent(this.classLoadingInformationData.getSensorTypeIdent()); newClassLoadingInformationData.setCount(this.classLoadingInformationData.getCount()); newClassLoadingInformationData.setTotalLoadedClassCount(this.classLoadingInformationData.getTotalLoadedClassCount()); newClassLoadingInformationData.setMinLoadedClassCount(this.classLoadingInformationData.getMinLoadedClassCount()); newClassLoadingInformationData.setMaxLoadedClassCount(this.classLoadingInformationData.getMaxLoadedClassCount()); newClassLoadingInformationData.setTotalTotalLoadedClassCount(this.classLoadingInformationData.getTotalTotalLoadedClassCount()); newClassLoadingInformationData.setMinTotalLoadedClassCount(this.classLoadingInformationData.getMinTotalLoadedClassCount()); newClassLoadingInformationData.setMaxTotalLoadedClassCount(this.classLoadingInformationData.getMaxTotalLoadedClassCount()); newClassLoadingInformationData.setTotalUnloadedClassCount(this.classLoadingInformationData.getTotalUnloadedClassCount()); newClassLoadingInformationData.setMinUnloadedClassCount(this.classLoadingInformationData.getMinUnloadedClassCount()); newClassLoadingInformationData.setMaxUnloadedClassCount(this.classLoadingInformationData.getMaxUnloadedClassCount()); newClassLoadingInformationData.setTimeStamp(this.classLoadingInformationData.getTimeStamp()); return newClassLoadingInformationData; }
/** * {@inheritDoc} */ @Override public ClassLoadingInformationData getClone(ClassLoadingInformationData classLoadingInformationData) { ClassLoadingInformationData clone = new ClassLoadingInformationData(); clone.setPlatformIdent(classLoadingInformationData.getPlatformIdent()); clone.setSensorTypeIdent(classLoadingInformationData.getSensorTypeIdent()); return clone; }
/** * Updates the upper plot with the given input data. * * @param classLoadingData * The input data. */ private void addUpperPlotData(List<ClassLoadingInformationData> classLoadingData) { for (ClassLoadingInformationData data : classLoadingData) { int loadedClassAverage = data.getTotalLoadedClassCount() / data.getCount(); long totalLoadedClassAverage = data.getTotalTotalLoadedClassCount() / data.getCount(); loadedClasses.add(data.getTimeStamp().getTime(), loadedClassAverage, data.getMinLoadedClassCount(), data.getMaxLoadedClassCount(), false); totalLoadedClasses.add(data.getTimeStamp().getTime(), totalLoadedClassAverage, data.getMinTotalLoadedClassCount(), data.getMaxTotalLoadedClassCount(), false); } loadedClasses.fireSeriesChanged(); totalLoadedClasses.fireSeriesChanged(); }
ClassLoadingInformationData data = new ClassLoadingInformationData(new Timestamp(currentTime), 1, 5); currentTime += 5000L; int count = 5; data.setCount(count); data.setId(-1L); data.setMinLoadedClassCount(2000 + i); data.setMaxLoadedClassCount(3000 + i); int totalLoadedClassCount = (((data.getMinLoadedClassCount() + data.getMaxLoadedClassCount())) / 2) / count; data.setTotalLoadedClassCount(totalLoadedClassCount); data.setMinUnloadedClassCount(20 + i); data.setMaxUnloadedClassCount(30 + i); long totalUnloadedClassCount = ((data.getMinUnloadedClassCount() + data.getMaxUnloadedClassCount()) / 2) / count; data.setTotalUnloadedClassCount(totalUnloadedClassCount); data.setMinTotalLoadedClassCount(10000); data.setMaxTotalLoadedClassCount(15000); long totalTotalLoadedClassCount = ((data.getMinTotalLoadedClassCount() + data.getMaxTotalLoadedClassCount()) / 2) / count; data.setTotalTotalLoadedClassCount(totalTotalLoadedClassCount);
long unloadedClassCount = this.getRuntimeBean().getUnloadedClassCount(); this.classLoadingInformationData.incrementCount(); this.classLoadingInformationData.addLoadedClassCount(loadedClassCount); this.classLoadingInformationData.addTotalLoadedClassCount(totalLoadedClassCount); this.classLoadingInformationData.addUnloadedClassCount(unloadedClassCount); if (loadedClassCount < this.classLoadingInformationData.getMinLoadedClassCount()) { this.classLoadingInformationData.setMinLoadedClassCount(loadedClassCount); } else if (loadedClassCount > this.classLoadingInformationData.getMaxLoadedClassCount()) { this.classLoadingInformationData.setMaxLoadedClassCount(loadedClassCount); if (totalLoadedClassCount < this.classLoadingInformationData.getMinTotalLoadedClassCount()) { this.classLoadingInformationData.setMinTotalLoadedClassCount(totalLoadedClassCount); } else if (totalLoadedClassCount > this.classLoadingInformationData.getMaxTotalLoadedClassCount()) { this.classLoadingInformationData.setMaxTotalLoadedClassCount(totalLoadedClassCount); if (unloadedClassCount < this.classLoadingInformationData.getMinUnloadedClassCount()) { this.classLoadingInformationData.setMinUnloadedClassCount(unloadedClassCount); } else if (unloadedClassCount > this.classLoadingInformationData.getMaxUnloadedClassCount()) { this.classLoadingInformationData.setMaxUnloadedClassCount(unloadedClassCount);
@Test public void happyPath() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getCount()).thenReturn(5); when(data.getTotalLoadedClassCount()).thenReturn(RandomUtils.nextInt()); when(data.getTotalTotalLoadedClassCount()).thenReturn(RandomUtils.nextLong()); when(data.getTotalUnloadedClassCount()).thenReturn(RandomUtils.nextLong()); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.ClassLoadingInfomation.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(getFields(pointBuilder), hasEntry(Series.ClassLoadingInfomation.FIELD_LOADED_CLASSES, (Object) ((long) data.getTotalLoadedClassCount() / data.getCount()))); assertThat(getFields(pointBuilder), hasEntry(Series.ClassLoadingInfomation.FIELD_TOTAL_LOADED_CLASSES, (Object) (data.getTotalTotalLoadedClassCount() / data.getCount()))); assertThat(getFields(pointBuilder), hasEntry(Series.ClassLoadingInfomation.FIELD_UNLOADED_CLASSES, (Object) (data.getTotalUnloadedClassCount() / data.getCount()))); }
/** * {@inheritDoc} */ @Override protected void addFields(ClassLoadingInformationData data, Builder builder) { long count = data.getCount(); long loadedClassCount = data.getTotalLoadedClassCount() / count; long totalLoadedClassCount = data.getTotalTotalLoadedClassCount() / count; long unloadedClassCount = data.getTotalUnloadedClassCount() / count; // fields builder.addField(Series.ClassLoadingInfomation.FIELD_LOADED_CLASSES, loadedClassCount); builder.addField(Series.ClassLoadingInfomation.FIELD_TOTAL_LOADED_CLASSES, totalLoadedClassCount); builder.addField(Series.ClassLoadingInfomation.FIELD_UNLOADED_CLASSES, unloadedClassCount); }
/** * {@inheritDoc} */ @Override public void setInputDefinition(InputDefinition inputDefinition) { super.setInputDefinition(inputDefinition); template = new ClassLoadingInformationData(); template.setPlatformIdent(inputDefinition.getIdDefinition().getPlatformId()); template.setSensorTypeIdent(inputDefinition.getIdDefinition().getSensorTypeId()); template.setId(-1L); dataAccessService = inputDefinition.getRepositoryDefinition().getGlobalDataAccessService(); aggregator = new ClassLoadingInformationDataAggregator(); }
@Test void loadedClassCountIsCalculated() { when(this.runtimeBean.getLoadedClassCount()).thenReturn(10).thenReturn(9).thenReturn(11).thenReturn(10); this.cut.gather(); this.cut.gather(); this.cut.gather(); this.cut.gather(); ClassLoadingInformationData collector = (ClassLoadingInformationData) this.cut.get(); assertThat(collector.getMinLoadedClassCount(), is(9)); assertThat(collector.getMaxLoadedClassCount(), is(11)); assertThat(collector.getTotalLoadedClassCount(), is(40)); }
@Test void totalLoadedClassCountIsCalculated() { when(this.runtimeBean.getTotalLoadedClassCount()).thenReturn(10L).thenReturn(9L).thenReturn(11L).thenReturn(10L); this.cut.gather(); this.cut.gather(); this.cut.gather(); this.cut.gather(); ClassLoadingInformationData collector = (ClassLoadingInformationData) this.cut.get(); assertThat(collector.getMinTotalLoadedClassCount(), is(9L)); assertThat(collector.getMaxTotalLoadedClassCount(), is(11L)); assertThat(collector.getTotalTotalLoadedClassCount(), is(40L)); }
@Test public void noPlatform() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(null); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getCount()).thenReturn(1); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.ClassLoadingInfomation.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))); }
/** * {@inheritDoc} */ @Override public void setInputDefinition(InputDefinition inputDefinition) { super.setInputDefinition(inputDefinition); classLoadingObj = new ClassLoadingInformationData(); classLoadingObj.setPlatformIdent(inputDefinition.getIdDefinition().getPlatformId()); dataAccessService = inputDefinition.getRepositoryDefinition().getGlobalDataAccessService(); }
/** * {@inheritDoc} */ @Override public Object getAggregationKey(ClassLoadingInformationData object) { return object.getPlatformIdent(); }
@Test void countIsIncremented() { this.cut.gather(); this.cut.gather(); ClassLoadingInformationData collector = (ClassLoadingInformationData) this.cut.get(); assertThat(collector.getCount(), is(2)); } }
Date dataNewestDate = new Date(0); if (!oldData.isEmpty()) { dataNewestDate = oldData.get(oldData.size() - 1).getTimeStamp(); if (newestDate.before(data.get(data.size() - 1).getTimeStamp())) { newestDate = new Date(data.get(data.size() - 1).getTimeStamp().getTime()); oldData.addAll(rightData); oldToDate = (Date) to.clone(); if (newestDate.before(rightData.get(rightData.size() - 1).getTimeStamp())) { newestDate = new Date(rightData.get(rightData.size() - 1).getTimeStamp().getTime()); oldData.addAll(timerData); oldToDate = (Date) to.clone(); if (newestDate.before(timerData.get(timerData.size() - 1).getTimeStamp())) { newestDate = new Date(timerData.get(timerData.size() - 1).getTimeStamp().getTime());
ClassLoadingInformationData data = new ClassLoadingInformationData(new Timestamp(fromDate.getTime() + 300000L), 1, 5); int count = 5; data.setCount(count); data.setId(-1L); data.setMinLoadedClassCount(2010); data.setMaxLoadedClassCount(3010); int totalLoadedClassCount = (((data.getMinLoadedClassCount() + data.getMaxLoadedClassCount())) / 2) / count; data.setTotalLoadedClassCount(totalLoadedClassCount); data.setMinUnloadedClassCount(30); data.setMaxUnloadedClassCount(40); long totalUnloadedClassCount = ((data.getMinUnloadedClassCount() + data.getMaxUnloadedClassCount()) / 2) / count; data.setTotalUnloadedClassCount(totalUnloadedClassCount); data.setMinTotalLoadedClassCount(10000); data.setMaxTotalLoadedClassCount(15000); long totalTotalLoadedClassCount = ((data.getMinTotalLoadedClassCount() + data.getMaxTotalLoadedClassCount()) / 2) / count; data.setTotalTotalLoadedClassCount(totalTotalLoadedClassCount);
/** * {@inheritDoc} */ @Override public void setInputDefinition(InputDefinition inputDefinition) { super.setInputDefinition(inputDefinition); long platformId = inputDefinition.getIdDefinition().getPlatformId(); systemObj = new SystemInformationData(); systemObj.setPlatformIdent(platformId); classLoadingObj = new ClassLoadingInformationData(); classLoadingObj.setPlatformIdent(platformId); cpuObj = new CpuInformationData(); cpuObj.setPlatformIdent(platformId); compilationObj = new CompilationInformationData(); compilationObj.setPlatformIdent(platformId); memoryObj = new MemoryInformationData(); memoryObj.setPlatformIdent(platformId); runtimeObj = new RuntimeInformationData(); runtimeObj.setPlatformIdent(platformId); threadObj = new ThreadInformationData(); threadObj.setPlatformIdent(platformId); dataAccessService = inputDefinition.getRepositoryDefinition().getGlobalDataAccessService(); }
collector.setPlatformIdent(1L); collector.setSensorTypeIdent(2L); collector.setCount(3); collector.setTotalLoadedClassCount(4); collector.setMinLoadedClassCount(5); collector.setMaxLoadedClassCount(6); collector.setTotalTotalLoadedClassCount(7L); collector.setMinTotalLoadedClassCount(8L); collector.setMaxTotalLoadedClassCount(9L); collector.setTotalUnloadedClassCount(10L); collector.setMinUnloadedClassCount(11L); collector.setMaxUnloadedClassCount(12L); collector.setTimeStamp(new Timestamp(13L)); assertThat(classLoadingInformationData.getPlatformIdent(), is(1L)); assertThat(classLoadingInformationData.getSensorTypeIdent(), is(2L)); assertThat(classLoadingInformationData.getCount(), is(3)); assertThat(classLoadingInformationData.getTotalLoadedClassCount(), is(4)); assertThat(classLoadingInformationData.getMinLoadedClassCount(), is(5)); assertThat(classLoadingInformationData.getMaxLoadedClassCount(), is(6)); assertThat(classLoadingInformationData.getTotalTotalLoadedClassCount(), is(7L)); assertThat(classLoadingInformationData.getMinTotalLoadedClassCount(), is(8L)); assertThat(classLoadingInformationData.getMaxTotalLoadedClassCount(), is(9L));
collector.setPlatformIdent(1L); collector.setSensorTypeIdent(2L); collector.setCount(3); collector.setTotalLoadedClassCount(4); collector.setMinLoadedClassCount(5); collector.setMaxLoadedClassCount(6); collector.setTotalTotalLoadedClassCount(7L); collector.setMinTotalLoadedClassCount(8L); collector.setMaxTotalLoadedClassCount(9L); collector.setTotalUnloadedClassCount(10L); collector.setMinUnloadedClassCount(11L); collector.setMaxUnloadedClassCount(12L); collector.setTimeStamp(new Timestamp(13L)); assertThat(classLoadingInformationData.getPlatformIdent(), is(1L)); assertThat(classLoadingInformationData.getSensorTypeIdent(), is(2L)); assertThat(classLoadingInformationData.getCount(), is(0)); assertThat(classLoadingInformationData.getTotalLoadedClassCount(), is(0)); assertThat(classLoadingInformationData.getMinLoadedClassCount(), is(Integer.MAX_VALUE)); assertThat(classLoadingInformationData.getMaxLoadedClassCount(), is(0)); assertThat(classLoadingInformationData.getTotalTotalLoadedClassCount(), is(0L)); assertThat(classLoadingInformationData.getMinTotalLoadedClassCount(), is(Long.MAX_VALUE)); assertThat(classLoadingInformationData.getMaxTotalLoadedClassCount(), is(0L));