Skip to content

Commit

Permalink
[#10944] Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
emeroad committed Apr 24, 2024
1 parent 3de57c1 commit 0ee497a
Show file tree
Hide file tree
Showing 21 changed files with 29 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void collect() {
return;
}

Range range = Range.reverse(timeSlotEndTime - slotInterval, timeSlotEndTime);
Range range = Range.between(timeSlotEndTime - slotInterval, timeSlotEndTime);

for (String agentId : agentIds) {
List<AgentEventBo> agentEventBoList = agentEventDao.getAgentEvents(agentId, range, Collections.emptySet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void collect() {
return;
}

Range range = Range.reverse(timeSlotEndTime - slotInterval, timeSlotEndTime);
Range range = Range.between(timeSlotEndTime - slotInterval, timeSlotEndTime);

for(String agentId : agentIds) {
List<JvmGcBo> jvmGcBos = jvmGcDao.getAgentStatList(agentId, range);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void collect() {
return;
}

Range range = Range.reverse(timeSlotEndTime - slotInterval, timeSlotEndTime);
Range range = Range.between(timeSlotEndTime - slotInterval, timeSlotEndTime);

for (String agentId : agentIds) {
List<DataSourceListBo> dataSourceListBos = dataSourceDao.getAgentStatList(agentId, range);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void collect() {
return;
}

Range range = Range.reverse(timeSlotEndTime - slotInterval, timeSlotEndTime);
Range range = Range.between(timeSlotEndTime - slotInterval, timeSlotEndTime);

for(String agentId : agentIds) {
List<FileDescriptorBo> fileDescriptorBoList = fileDescriptorDao.getAgentStatList(agentId, range);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void collect() {
return;
}

Range range = Range.reverse(timeSlotEndTime - slotInterval, timeSlotEndTime);
Range range = Range.between(timeSlotEndTime - slotInterval, timeSlotEndTime);
List<ResponseTime> responseTimes = responseDao.selectResponseTime(application, range);

for (ResponseTime responseTime : responseTimes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public DataSourceDataCollector(DataCollectorCategory dataCollectorCategory, Alar

@Override
public void collect() {
Range range = Range.reverse(timeSlotEndTime - slotInterval, timeSlotEndTime);
Range range = Range.between(timeSlotEndTime - slotInterval, timeSlotEndTime);
try {
Map<String, List<TagInformation>> agentTagInformation = getAgentTagInformation(range);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public FileDescriptorDataCollector(DataCollectorCategory dataCollectorCategory,

@Override
public void collect() {
Range range = Range.reverse(timeSlotEndTime - slotInterval, timeSlotEndTime);
Range range = Range.between(timeSlotEndTime - slotInterval, timeSlotEndTime);
List<AgentUsage> agentUsageList = alarmDao.selectAvg(application.getName(), METRIC_NAME, FIELD_NAME, range);

for (AgentUsage agentUsage : agentUsageList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public HeapDataCollector(DataCollectorCategory dataCollectorCategory, AlarmDao a

@Override
public void collect() {
Range range = Range.reverse(timeSlotEndTime - slotInterval, timeSlotEndTime);
Range range = Range.between(timeSlotEndTime - slotInterval, timeSlotEndTime);
List<AgentFieldUsage> agentFieldUsageList = alarmDao.selectSumGroupByField(application.getName(), METRIC_NAME, fieldList, range);
Map<String, AgentHeapUsage> agentHeapUsageMap = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public JvmCpuDataCollector(DataCollectorCategory dataCollectorCategory, AlarmDao

@Override
public void collect() {
Range range = Range.reverse(timeSlotEndTime - slotInterval, timeSlotEndTime);
Range range = Range.between(timeSlotEndTime - slotInterval, timeSlotEndTime);
List<AgentUsageCount> agentUsageCountList = alarmDao.selectSumCount(application.getName(), METRIC_NAME, FIELD_NAME, range);

for (AgentUsageCount agentUsageCount : agentUsageCountList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public SystemCpuDataCollector(DataCollectorCategory dataCollectorCategory, Alarm

@Override
public void collect() {
Range range = Range.reverse(timeSlotEndTime - slotInterval, timeSlotEndTime);
Range range = Range.between(timeSlotEndTime - slotInterval, timeSlotEndTime);
List<AgentUsageCount> agentUsageCountList = alarmDao.selectSumCount(application.getName(), METRIC_NAME, FIELD_NAME, range);

for (AgentUsageCount agentUsageCount : agentUsageCountList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class DataSourceConnectionUsageRateCheckerTest {

@BeforeEach
public void before() {
Range range = Range.reverse(START_TIME_MILLIS, CURRENT_TIME_MILLIS);
Range range = Range.between(START_TIME_MILLIS, CURRENT_TIME_MILLIS);

List<DataSourceListBo> dataSourceListBoList = List.of(
createDataSourceListBo(1, 30, 40, 3),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private long createEventTimestamp() {
public void checkTest1() {
Rule rule = new Rule(APPLICATION_NAME, SERVICE_TYPE, CheckerCategory.ERROR_COUNT.getName(), 50, "testGroup", false, false, false, "");

Range range = Range.reverse(START_TIME_MILLIS, CURRENT_TIME_MILLIS);
Range range = Range.between(START_TIME_MILLIS, CURRENT_TIME_MILLIS);
when(mockAgentEventDao.getAgentEvents(AGENT_ID_1, range, Set.of())).thenReturn(List.of(createAgentEvent(AGENT_ID_1, createEventTimestamp(), AgentEventType.AGENT_CLOSED_BY_SERVER)));
when(mockAgentEventDao.getAgentEvents(AGENT_ID_2, range, Set.of())).thenReturn(List.of(createAgentEvent(AGENT_ID_2, createEventTimestamp(), AgentEventType.AGENT_DEADLOCK_DETECTED)));
when(mockAgentEventDao.getAgentEvents(AGENT_ID_3, range, Set.of())).thenReturn(List.of(createAgentEvent(AGENT_ID_3, createEventTimestamp(), AgentEventType.AGENT_PING)));
Expand All @@ -88,7 +88,7 @@ public void checkTest1() {
public void checkTest2() {
Rule rule = new Rule(APPLICATION_NAME, SERVICE_TYPE, CheckerCategory.ERROR_COUNT.getName(), 50, "testGroup", false, false, false, "");

Range range = Range.reverse(START_TIME_MILLIS, CURRENT_TIME_MILLIS);
Range range = Range.between(START_TIME_MILLIS, CURRENT_TIME_MILLIS);
when(mockAgentEventDao.getAgentEvents(AGENT_ID_1, range, Set.of())).thenReturn(List.of(createAgentEvent(AGENT_ID_1, createEventTimestamp(), AgentEventType.AGENT_CLOSED_BY_SERVER)));
when(mockAgentEventDao.getAgentEvents(AGENT_ID_2, range, Set.of())).thenReturn(List.of(createAgentEvent(AGENT_ID_2, createEventTimestamp(), AgentEventType.AGENT_SHUTDOWN)));
when(mockAgentEventDao.getAgentEvents(AGENT_ID_3, range, Set.of())).thenReturn(List.of(createAgentEvent(AGENT_ID_3, createEventTimestamp(), AgentEventType.AGENT_PING)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void collect() {
@SuppressWarnings("unchecked")
AgentStatDao<FileDescriptorBo> fileDescriptorDao = (AgentStatDao<FileDescriptorBo>) mock(AgentStatDao.class);
long timeStamp = 1558936971494L;
Range range = Range.reverse(timeStamp - DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN, timeStamp);
Range range = Range.between(timeStamp - DataCollectorFactory.SLOT_INTERVAL_FIVE_MIN, timeStamp);

FileDescriptorBo fileDescriptorBo1_1 = new FileDescriptorBo();
fileDescriptorBo1_1.setOpenFileDescriptorCount(200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ public static Range newRange(TimeUnit timeUnit, long duration, long toTimestamp)
return Range.between(toTimestamp - durationMillis, toTimestamp);
}

public static Range reverse(long from, long to) {
return reverse(toInstant(from), toInstant(to));
public static Range unchecked(long from, long to) {
return unchecked(toInstant(from), toInstant(to));
}

public static Range reverse(Instant from, Instant to) {
public static Range unchecked(Instant from, Instant to) {
return new Range(from, to);
}

/**
* @deprecated Since 3.0.0 Use {@link #reverse(long, long)}
* @deprecated Since 3.0.0 Use {@link #unchecked(long, long)}
*/
@Deprecated
public static Range newUncheckedRange(long from, long to) {
return reverse(from, to);
return unchecked(from, to);
}

public long getFrom() {
Expand Down Expand Up @@ -120,6 +120,7 @@ public void validate() {
}
}


@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void testRange_String() {
Range range2 = Range.between(0, 1);
assertThat(range2.toString()).contains(" < ");

Range range3 = Range.reverse(1, 0);
Range range3 = Range.unchecked(1, 0);
assertThat(range3.toString()).contains(" > ");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void check() {

rangeValidator.validate(ofDays(2), Instant.EPOCH);

rangeValidator.validate(Range.reverse(ofDays(2).toEpochMilli(), Instant.EPOCH.toEpochMilli()));
rangeValidator.validate(Range.unchecked(ofDays(2).toEpochMilli(), Instant.EPOCH.toEpochMilli()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public String getUnit() {
}

public boolean[] check(long timeSlotEndTime) {
Range range = Range.reverse(timeSlotEndTime - SLOT_INTERVAL_FIVE_MIN, timeSlotEndTime);
Range range = Range.between(timeSlotEndTime - SLOT_INTERVAL_FIVE_MIN, timeSlotEndTime);
collectedValue = dataCollector.collect(serviceName, applicationName, target, range);

for (int i = 0; i < rules.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ResultView dragScatterArea(
final DragArea dragArea = DragArea.normalize(x1, x2, y1, y2);

// TODO range check verification exception occurs. "from" is bigger than "to"
final Range range = Range.reverse(x1, x2);
final Range range = Range.unchecked(x1, x2);
logger.debug("drag scatter data. RANGE={}, LIMIT={}", range, limit);
final Dot.Status dotStatus = toDotStatus(boolDotStatus);
final DragAreaQuery query = new DragAreaQuery(dragArea, agentId, dotStatus);
Expand Down Expand Up @@ -134,7 +134,7 @@ public HeatMapController.HeatMapViewModel getHeatMapData(
@RequestParam("to") @PositiveOrZero long to) {

// TODO range check verification exception occurs. "from" is bigger than "to"
final Range range = Range.reverse(from, to);
final Range range = Range.unchecked(from, to);
logger.debug("fetch getHeatMapData. RANGE={}, ", range);

final LimitedScanResult<HeatMap> scanResult =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public ScatterView.ResultView getScatterData(
final int limit = LimitUtils.checkRange(limitParam);

// TODO: range check verification exception occurs. "from" is bigger than "to"
final Range range = Range.reverse(from, to);
final Range range = Range.unchecked(from, to);
logger.debug(
"fetch scatter data. RANGE: {}, X-Group-Unit: {}, Y-Group-Unit: {}, LIMIT: {}, " +
"BACKWARD_DIRECTION: {}, FILTER: {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public LimitedScanResult<List<TransactionId>> scanTraceIndex(String applicationN

LastRowAccessor lastRowAccessor = new LastRowAccessor();

final Range range = Range.reverse(dragArea.getXLow(), dragArea.getXHigh());
final Range range = Range.unchecked(dragArea.getXLow(), dragArea.getXHigh());
logger.debug("scanTraceIndex range:{}", range);
final Scan scan = newFuzzyScanner(applicationName, dragArea, range);

Expand Down Expand Up @@ -323,7 +323,7 @@ private <R> LimitedScanResult<List<R>> scanScatterData0(String applicationName,
Objects.requireNonNull(dragAreaQuery, "dragAreaQuery");

DragArea dragArea = dragAreaQuery.getDragArea();
Range range = Range.reverse(dragArea.getXLow(), dragArea.getXHigh());
Range range = Range.unchecked(dragArea.getXLow(), dragArea.getXHigh());
logger.debug("scanTraceScatterData-range:{}", range);

LastRowAccessor lastRowAccessor = new LastRowAccessor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public Range createStatisticsRange(Range range) {
// In this case, the Range is reversed, so we instead subtract 1 from the startTime.
final long startTime = timeSlot.getTimeSlot(range.getFrom()) - 1;
final long endTime = timeSlot.getTimeSlot(range.getTo());
return Range.reverse(startTime, endTime);
return Range.unchecked(startTime, endTime);
}

}

0 comments on commit 0ee497a

Please sign in to comment.