/** * {@inheritDoc} */ @Override public Object getAggregationKey(ThreadInformationData object) { return object.getPlatformIdent(); }
/** * {@inheritDoc} */ @Override public ThreadInformationData getClone(ThreadInformationData threadInformationData) { ThreadInformationData clone = new ThreadInformationData(); clone.setPlatformIdent(threadInformationData.getPlatformIdent()); clone.setSensorTypeIdent(threadInformationData.getSensorTypeIdent()); return clone; }
@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.ThreadInformation.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))); }
@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.getTotalThreadCount()).thenReturn(RandomUtils.nextInt()); when(data.getTotalDaemonThreadCount()).thenReturn(RandomUtils.nextInt()); when(data.getTotalTotalStartedThreadCount()).thenReturn(RandomUtils.nextLong()); when(data.getTotalPeakThreadCount()).thenReturn(RandomUtils.nextInt()); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.ThreadInformation.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.ThreadInformation.FIELD_DEAMON_THREAD_COUNT, (Object) Long.valueOf(data.getTotalDaemonThreadCount() / data.getCount()))); assertThat(getFields(pointBuilder), hasEntry(Series.ThreadInformation.FIELD_LIVE_THREAD_COUNT, (Object) Long.valueOf(data.getTotalThreadCount() / data.getCount()))); assertThat(getFields(pointBuilder), hasEntry(Series.ThreadInformation.FIELD_PEAK_THREAD_COUNT, (Object) Long.valueOf(data.getTotalPeakThreadCount() / data.getCount()))); assertThat(getFields(pointBuilder), hasEntry(Series.ThreadInformation.FIELD_TOTAL_STARTED_THREAD_COUNT, (Object) (data.getTotalTotalStartedThreadCount() / data.getCount()))); }
assertThat(threadInformationData.getPlatformIdent(), is(1L)); assertThat(threadInformationData.getSensorTypeIdent(), is(2L)); assertThat(threadInformationData.getCount(), is(3));
ThreadInformationData threadInformationData = (ThreadInformationData) this.cut.get(); assertThat(threadInformationData.getPlatformIdent(), is(1L)); assertThat(threadInformationData.getSensorTypeIdent(), is(2L)); assertThat(threadInformationData.getCount(), is(0));
/** * {@inheritDoc} */ @Override public SystemSensorData get() { ThreadInformationData newThreadInformationData = new ThreadInformationData(); newThreadInformationData.setPlatformIdent(this.threadInformationData.getPlatformIdent()); newThreadInformationData.setSensorTypeIdent(this.threadInformationData.getSensorTypeIdent()); newThreadInformationData.setCount(this.threadInformationData.getCount()); newThreadInformationData.setTotalDaemonThreadCount(this.threadInformationData.getTotalDaemonThreadCount()); newThreadInformationData.setMinDaemonThreadCount(this.threadInformationData.getMinDaemonThreadCount()); newThreadInformationData.setMaxDaemonThreadCount(this.threadInformationData.getMaxDaemonThreadCount()); newThreadInformationData.setTotalPeakThreadCount(this.threadInformationData.getTotalPeakThreadCount()); newThreadInformationData.setMinPeakThreadCount(this.threadInformationData.getMinPeakThreadCount()); newThreadInformationData.setMaxPeakThreadCount(this.threadInformationData.getMaxPeakThreadCount()); newThreadInformationData.setTotalThreadCount(this.threadInformationData.getTotalThreadCount()); newThreadInformationData.setMinThreadCount(this.threadInformationData.getMinThreadCount()); newThreadInformationData.setMaxThreadCount(this.threadInformationData.getMaxThreadCount()); newThreadInformationData.setTotalTotalStartedThreadCount(this.threadInformationData.getTotalTotalStartedThreadCount()); newThreadInformationData.setMinTotalStartedThreadCount(this.threadInformationData.getMinTotalStartedThreadCount()); newThreadInformationData.setMaxTotalStartedThreadCount(this.threadInformationData.getMaxTotalStartedThreadCount()); newThreadInformationData.setTimeStamp(this.threadInformationData.getTimeStamp()); return newThreadInformationData; }