Skip to content

Commit

Permalink
https://github.com/uavorg/uavstack/issues/349
Browse files Browse the repository at this point in the history
1、The tmax and tmin reset cycles are shortened to the default 1 hour

#350

2、The initial time the mof gets tmax is empty, and NullPointerException
is thrown
  • Loading branch information
duandehua authored and duandehua committed Jul 24, 2018
1 parent 7f104bc commit e18c656
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
*/
public class CaptureConstants {

// 1 day ttl for tmax, tmin
public final static long MEI_INST_TTL = 24 * 3600 * 1000;
// 1 hour ttl for tmax, tmin
public final static long MEI_INST_TTL = 1 * 3600 * 1000;

// default monitor id
public final static String MONITOR_SERVER = "server";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ protected void recordCounters(CaptureContext context, MonitorElementInstance ins
/**
* NOTE: for no-http
*/
if (rtCode==-1) {
if (rtCode == -1) {
inst.increValue(CaptureConstants.MEI_ERROR);
respCode="Err";
respCode = "Err";
}
else if (rtCode==1) {
respCode="OK";
else if (rtCode == 1) {
respCode = "OK";
}

inst.increValue(CaptureConstants.MEI_RC + respCode);
}
}
Expand Down Expand Up @@ -103,14 +103,18 @@ protected void doCommonCounters(CaptureContext context, MonitorElementInstance i
MonitorElementInstance.CompareSetOperation.MAX);

/**
* NOTE: tmax, tmin, 每24小时会自动RESET,避免一个巨大的tmax或一个很小的tmin
* NOTE: tmax, tmin, 每1小时会自动RESET,避免一个巨大的tmax或一个很小的tmin
*/
if (isMax == true) {

inst.setValue(CaptureConstants.MEI_RESP_MAXTIME_ST, end);
}
else {
long tmax_st = (Long) inst.getValue(CaptureConstants.MEI_RESP_MAXTIME_ST);
Object tmaxSt = inst.getValue(CaptureConstants.MEI_RESP_MAXTIME_ST);
if (tmaxSt == null) {
return;
}
long tmax_st = (Long) tmaxSt;

if (end - tmax_st > CaptureConstants.MEI_INST_TTL) {
inst.setValue(CaptureConstants.MEI_RESP_MAXTIME, new AtomicLong(respTime));
Expand All @@ -126,9 +130,13 @@ protected void doCommonCounters(CaptureContext context, MonitorElementInstance i
inst.setValue(CaptureConstants.MEI_RESP_MINTIME_ST, end);
}
else {
long tmax_st = (Long) inst.getValue(CaptureConstants.MEI_RESP_MINTIME_ST);
Object tminSt = inst.getValue(CaptureConstants.MEI_RESP_MINTIME_ST);
if (tminSt == null) {
return;
}
long tmin_st = (Long) tminSt;

if (end - tmax_st > CaptureConstants.MEI_INST_TTL) {
if (end - tmin_st > CaptureConstants.MEI_INST_TTL) {
inst.setValue(CaptureConstants.MEI_RESP_MINTIME, new AtomicLong(respTime));
inst.setValue(CaptureConstants.MEI_RESP_MINTIME_ST, end);
}
Expand Down

0 comments on commit e18c656

Please sign in to comment.