@Override protected void doInTransactionWithoutResult(TransactionStatus status) { TimerData oldest = queue.poll(); while (oldest != null) { map.remove(getCacheHash(oldest.getPlatformIdent(), oldest.getMethodIdent(), oldest.getTimeStamp().getTime())); TimerDataAggregator.super.create(oldest); elementCount.decrementAndGet(); oldest = queue.poll(); } } });
int cacheHash = getCacheHash(timerData.getPlatformIdent(), timerData.getMethodIdent(), aggregationTimestamp); aggTimerData = new DatabaseAggregatedTimerData(new Timestamp(aggregationTimestamp), timerData.getPlatformIdent(), timerData.getSensorTypeIdent(), timerData.getMethodIdent()); map.put(cacheHash, aggTimerData); queue.add(aggTimerData); TimerData oldest = queue.poll(); if (null != oldest) { map.remove(getCacheHash(oldest.getPlatformIdent(), oldest.getMethodIdent(), oldest.getTimeStamp().getTime())); persistList.add(oldest); count = elementCount.decrementAndGet();
query.setPlatformIdent(timerData.getPlatformIdent()); query.setMethodIdent(timerData.getMethodIdent()); ArrayList<Class<?>> searchedClasses = new ArrayList<>();
/** * Tests that persist list saving includes correct elements being saved. */ @Test public void saveAllInPersistList() { aggregator.maxElements = 1; TimerData timerData1 = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); TimerData timerData2 = new TimerData(new Timestamp(System.currentTimeMillis()), 100L, 200L, 300L); aggregator.processTimerData(timerData1); aggregator.processTimerData(timerData2); aggregator.saveAllInPersistList(); ArgumentCaptor<DatabaseAggregatedTimerData> argument = ArgumentCaptor.forClass(DatabaseAggregatedTimerData.class); verify(entityManager, times(1)).persist(argument.capture()); assertThat(argument.getValue(), is(instanceOf(DatabaseAggregatedTimerData.class))); assertThat(argument.getValue().getPlatformIdent(), is(timerData1.getPlatformIdent())); assertThat(argument.getValue().getSensorTypeIdent(), is(timerData1.getSensorTypeIdent())); assertThat(argument.getValue().getMethodIdent(), is(timerData1.getMethodIdent())); }
@Test public void noMethodIdent() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(platformIdent); when(cachedDataService.getMethodIdentForId(METHOD_ID)).thenReturn(null); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getMethodIdent()).thenReturn(METHOD_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getDuration()).thenReturn(RandomUtils.nextDouble()); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Methods.NAME)); assertThat(getTime(pointBuilder), is(time)); assertThat(getPrecision(pointBuilder), is(TimeUnit.MILLISECONDS)); assertThat(getTags(pointBuilder), not(hasKey(Series.Methods.TAG_CLASS_FQN))); assertThat(getTags(pointBuilder), not(hasKey(Series.Methods.TAG_METHOD_NAME))); assertThat(getTags(pointBuilder), not(hasKey(Series.Methods.TAG_METHOD_SIGNATURE))); }
@Test public void noPlatform() throws Exception { when(cachedDataService.getPlatformIdentForId(PLATFORM_ID)).thenReturn(null); when(cachedDataService.getMethodIdentForId(METHOD_ID)).thenReturn(methodIdent); long time = RandomUtils.nextLong(); when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getMethodIdent()).thenReturn(METHOD_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time)); when(data.getDuration()).thenReturn(RandomUtils.nextDouble()); Collection<Builder> pointBuilderCol = builder.createBuilders(data); assertThat(pointBuilderCol.size(), is(1)); Builder pointBuilder = pointBuilderCol.iterator().next(); assertThat(getMeasurement(pointBuilder), is(Series.Methods.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(getTags(pointBuilder), hasEntry(Series.Methods.TAG_CLASS_FQN, String.valueOf(FQN))); assertThat(getTags(pointBuilder), hasEntry(Series.Methods.TAG_METHOD_NAME, String.valueOf(METHOD))); assertThat(getTags(pointBuilder), hasEntry(Series.Methods.TAG_METHOD_SIGNATURE, String.valueOf(METHOD_SIG))); }
/** * {@inheritDoc} */ @Override public IAggregatedData<TimerData> getClone(TimerData timerData) { AggregatedTimerData clone = new AggregatedTimerData(); clone.setPlatformIdent(timerData.getPlatformIdent()); clone.setSensorTypeIdent(timerData.getSensorTypeIdent()); clone.setMethodIdent(timerData.getMethodIdent()); clone.setCharting(timerData.isCharting()); return clone; }
assertThat(timerData.getPlatformIdent(), is(platformId)); assertThat(timerData.getMethodIdent(), is(methodId)); assertThat(timerData.getSensorTypeIdent(), is(sensorTypeId));
assertThat(timerData.getPlatformIdent(), is(platformId)); assertThat(timerData.getMethodIdent(), is(methodIdTwo)); assertThat(timerData.getSensorTypeIdent(), is(sensorTypeId)); assertThat(timerData.getPlatformIdent(), is(platformId)); assertThat(timerData.getMethodIdent(), is(methodIdOne)); assertThat(timerData.getSensorTypeIdent(), is(sensorTypeId));
assertThat(timerData.getPlatformIdent(), is(platformId)); assertThat(timerData.getMethodIdent(), is(methodId)); assertThat(timerData.getSensorTypeIdent(), is(sensorTypeId)); assertThat(timerData.getPlatformIdent(), is(platformId)); assertThat(timerData.getMethodIdent(), is(methodId)); assertThat(timerData.getSensorTypeIdent(), is(sensorTypeId));
when(defaultData1.getPlatformIdent()).thenReturn(10L); when(defaultData1.getSensorTypeIdent()).thenReturn(10L); when(defaultData1.isQueryComplied(indexQuery)).thenReturn(true);
TimerData timerData = mock(TimerData.class); when(timerData.getTimeStamp()).thenReturn(new Timestamp(new Date().getTime())); when(timerData.getPlatformIdent()).thenReturn(10L); when(timerData.getMethodIdent()).thenReturn(20L);
when(defaultData1.getPlatformIdent()).thenReturn(10L); when(defaultData1.getSensorTypeIdent()).thenReturn(10L); when(defaultData1.isQueryComplied(indexQuery)).thenReturn(true);
when(defaultData1.getPlatformIdent()).thenReturn(10L); when(defaultData1.getSensorTypeIdent()).thenReturn(10L); IStorageDescriptor storageDescriptor1 = rootBranch.put(defaultData1);
when(defaultData1.getPlatformIdent()).thenReturn(10L); when(defaultData1.getSensorTypeIdent()).thenReturn(10L); IStorageDescriptor storageDescriptor1 = rootBranch.put(defaultData1);
when(data.getPlatformIdent()).thenReturn(PLATFORM_ID); when(data.getMethodIdent()).thenReturn(METHOD_ID); when(data.getTimeStamp()).thenReturn(new Timestamp(time));
TimerData template = new TimerData(null, timerData.getPlatformIdent(), timerData.getSensorTypeIdent(), timerData.getMethodIdent()); templates.add(template); idDefinition.setPlatformId(templates.get(0).getPlatformIdent()); inputDefinition.setIdDefinition(idDefinition); idDefinition.setPlatformId(timerData.getPlatformIdent()); idDefinition.setSensorTypeId(timerData.getSensorTypeIdent()); idDefinition.setMethodId(timerData.getMethodIdent());
idDefinition.setPlatformId(dataToNavigateTo.getPlatformIdent()); idDefinition.setMethodId(dataToNavigateTo.getMethodIdent()); inputDefinition.setIdDefinition(idDefinition);