Update of /cvsroot/jrobin/src/org/jrobin/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6947/org/jrobin/core
Modified Files:
RrdDb.java
Log Message:
JRobin 1.4.0
- Bug fixes graphing
- Demo tweaks
Index: RrdDb.java
===================================================================
RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDb.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** RrdDb.java 22 Jul 2004 09:34:10 -0000 1.26
--- RrdDb.java 25 Jul 2004 12:28:14 -0000 1.27
***************
*** 515,564 ****
}
! public Archive findMatchingArchive(FetchRequest request) throws RrdException, IOException {
! String consolFun = request.getConsolFun();
! long fetchStart = request.getFetchStart();
! long fetchEnd = request.getFetchEnd();
! long resolution = request.getResolution();
Archive bestFullMatch = null, bestPartialMatch = null;
long bestStepDiff = 0, bestMatch = 0;
! for(int i = 0; i < archives.length; i++) {
! if(archives[i].getConsolFun().equals(consolFun)) {
! long arcStep = archives[i].getArcStep();
! long arcStart = archives[i].getStartTime() - arcStep;
! long arcEnd = archives[i].getEndTime();
! long fullMatch = fetchEnd - fetchStart;
! // best full match
! if(arcEnd >= fetchEnd && arcStart <= fetchStart) {
! long tmpStepDiff = Math.abs(archives[i].getArcStep() - resolution);
! if(bestFullMatch == null || tmpStepDiff < bestStepDiff) {
bestStepDiff = tmpStepDiff;
bestFullMatch = archives[i];
}
}
! // best partial match
! else {
long tmpMatch = fullMatch;
! if(arcStart > fetchStart) {
tmpMatch -= (arcStart - fetchStart);
! }
! if(arcEnd < fetchEnd) {
tmpMatch -= (fetchEnd - arcEnd);
! }
! if(bestPartialMatch == null || bestMatch < tmpMatch) {
! bestPartialMatch = archives[i];
! bestMatch = tmpMatch;
}
}
}
}
! if(bestFullMatch != null) {
return bestFullMatch;
! }
! else if(bestPartialMatch != null) {
return bestPartialMatch;
! }
! else {
throw new RrdException("RRD file does not contain RRA:" + consolFun + " archive");
- }
}
--- 515,573 ----
}
! public Archive findMatchingArchive(FetchRequest request) throws RrdException, IOException
! {
! String consolFun = request.getConsolFun();
! long fetchStart = request.getFetchStart();
! long fetchEnd = request.getFetchEnd();
! long resolution = request.getResolution();
!
Archive bestFullMatch = null, bestPartialMatch = null;
+
long bestStepDiff = 0, bestMatch = 0;
!
! for ( int i = 0; i < archives.length; i++ )
! {
! if ( archives[i].getConsolFun().equals(consolFun) )
! {
! long arcStep = archives[i].getArcStep();
! long arcStart = archives[i].getStartTime() - arcStep;
! long arcEnd = archives[i].getEndTime();
! long fullMatch = fetchEnd - fetchStart;
!
! if ( arcEnd >= fetchEnd && arcStart <= fetchStart ) // best full match
! {
! long tmpStepDiff = Math.abs( archives[i].getArcStep() - resolution );
!
! if ( tmpStepDiff < bestStepDiff || bestFullMatch == null )
! {
bestStepDiff = tmpStepDiff;
bestFullMatch = archives[i];
}
+
}
! else // best partial match
! {
long tmpMatch = fullMatch;
!
! if ( arcStart > fetchStart )
tmpMatch -= (arcStart - fetchStart);
! if( arcEnd < fetchEnd )
tmpMatch -= (fetchEnd - arcEnd);
!
! if ( bestPartialMatch == null || bestMatch < tmpMatch )
! {
! bestPartialMatch = archives[i];
! bestMatch = tmpMatch;
}
}
}
}
!
! if ( bestFullMatch != null )
return bestFullMatch;
! else if ( bestPartialMatch != null )
return bestPartialMatch;
! else
throw new RrdException("RRD file does not contain RRA:" + consolFun + " archive");
}
|