private static TimeRange convertDiffRangeToRange(TimeRangeDiff diff) throws DatatypeConfigurationException { if (f == null) { f = DatatypeFactory.newInstance(); } GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gcal.add(Calendar.MILLISECOND, (int) ((-1) * Utility.durationToTimeInMS(diff.getStart()))); TimeRange r = new TimeRange(); r.setStart((gcal)); gcal = new GregorianCalendar(); gcal.setTimeInMillis(System.currentTimeMillis()); gcal.add(Calendar.MILLISECOND, (int) ((-1) * Utility.durationToTimeInMS(diff.getEnd()))); r.setEnd((gcal)); return r; }
/** * * @param records a non empty list * @param range * @return */ private double getUptimePercentage(List<StatusRecordsExt> records, TimeRange range) { long totaluptime = 0; long totaltime = range.getEnd().getTimeInMillis() - range.getStart().getTimeInMillis(); if (records.size() == 1) { if (records.get(0).status) { return 100; } else { return 0; } } for (int i = 0; i < records.size() - 1; i++) { if (records.get(i).status) { totaluptime += records.get(i + 1).gcal.getTimeInMillis() - records.get(i).gcal.getTimeInMillis(); } } if (records.get(records.size() - 1).status) { totaluptime += range.getEnd().getTimeInMillis() - records.get(records.size() - 1).gcal.getTimeInMillis(); } if (totaltime > 0) { return (double) ((double) totaluptime / (double) totaltime * 100D); } return -1; }
/** * Create an instance of {@link TimeRange } * */ public TimeRange createTimeRange() { return new TimeRange(); }
com = con.prepareStatement("select status from availability where uri=? and utcdatetime < ? order by utcdatetime desc limit 1;"); com.setString(1, url); com.setLong(2, range.getStart().getTimeInMillis()); rs = com.executeQuery(); if (rs.next()) { x.gcal.setTimeInMillis(range.getStart().getTimeInMillis()); x.status = rs.getBoolean("status"); ret.add(x); com.setLong(2, range.getStart().getTimeInMillis()); com.setLong(3, range.getEnd().getTimeInMillis()); rs = com.executeQuery(); boolean lastStatus = true; x.gcal.setTimeInMillis(range.getEnd().getTimeInMillis()); x.status = lastStatus; ret.add(x);
com = con.prepareStatement("select * from rawdatamachineprocess where uri=? and utcdatetime > ? and utcdatetime < ? order by utcdatetime desc limit ? offset ?;"); com.setString(1, processURI); com.setLong(2, range.getStart().getTimeInMillis()); com.setLong(3, range.getEnd().getTimeInMillis()); com.setLong(4, records); com.setLong(5, offset);
+ time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getStart(); t = t.replaceAll("%DATETIME_FROM%", time.get(Calendar.YEAR) + "/" + time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getEnd(); t = t.replaceAll("%DATETIME_TO%", time.get(Calendar.YEAR) + "/" + "where uri=? and utcdatetime > ? and utcdatetime < ? order by utcdatetime desc ;"); com.setString(1, url); com.setLong(2, request.getRange().getStart().getTimeInMillis()); com.setLong(3, request.getRange().getEnd().getTimeInMillis());
new Date().toString()); time = request.getRange().getStart(); t = t.replaceAll("%DATETIME_FROM%", time.getTime().toString()); time = request.getRange().getEnd(); t = t.replaceAll("%DATETIME_TO%", time.getTime().toString()); + "where uri=? and utcdatetime > ? and utcdatetime < ? order by utcdatetime desc ;"); com.setString(1, url); com.setLong(2, request.getRange().getStart().getTimeInMillis()); com.setLong(3, request.getRange().getEnd().getTimeInMillis());
+ time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getStart(); t = t.replaceAll("%DATETIME_FROM%", time.get(Calendar.YEAR) + "/" + time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getEnd(); t = t.replaceAll("%DATETIME_TO%", time.get(Calendar.YEAR) + "/" + "where utcdatetime > ? and utcdatetime < ? order by utcdatetime desc ;"); com.setLong(1, request.getRange().getStart().getTimeInMillis()); com.setLong(2, request.getRange().getEnd().getTimeInMillis());
+ time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getStart(); t = t.replaceAll("%DATETIME_FROM%", time.get(Calendar.YEAR) + "/" + time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getEnd(); t = t.replaceAll("%DATETIME_TO%", time.get(Calendar.YEAR) + "/" + "where host=? and utcdatetime > ? and utcdatetime < ? order by utcdatetime desc ;"); com.setString(1, url); com.setLong(2, request.getRange().getStart().getTimeInMillis()); com.setLong(3, request.getRange().getEnd().getTimeInMillis());
+ time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getStart(); t = t.replaceAll("%DATETIME_FROM%", time.get(Calendar.YEAR) + "/" + time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getEnd(); t = t.replaceAll("%DATETIME_TO%", time.get(Calendar.YEAR) + "/" + "where uri=? and utcdatetime > ? and utcdatetime < ? order by utcdatetime desc ;"); com.setString(1, url); com.setLong(2, request.getRange().getStart().getTimeInMillis()); com.setLong(3, request.getRange().getEnd().getTimeInMillis());
+ time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getStart(); t = t.replaceAll("%DATETIME_FROM%", time.get(Calendar.YEAR) + "/" + time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getEnd(); t = t.replaceAll("%DATETIME_TO%", time.get(Calendar.YEAR) + "/" + "where uri=? and utcdatetime > ? and utcdatetime < ? order by utcdatetime desc ;"); com.setString(1, url); com.setLong(2, request.getRange().getStart().getTimeInMillis()); com.setLong(3, request.getRange().getEnd().getTimeInMillis());
+ time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getStart(); t = t.replaceAll("%DATETIME_FROM%", time.get(Calendar.YEAR) + "/" + time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getEnd(); t = t.replaceAll("%DATETIME_TO%", time.get(Calendar.YEAR) + "/" + "where uri=? and utcdatetime > ? and utcdatetime < ? order by utcdatetime desc ;"); com.setString(1, url); com.setLong(2, request.getRange().getStart().getTimeInMillis()); com.setLong(3, request.getRange().getEnd().getTimeInMillis());
+ time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getStart(); t = t.replaceAll("%DATETIME_FROM%", time.get(Calendar.YEAR) + "/" + time.get(Calendar.SECOND) + " " + ampm[time.get(Calendar.AM_PM)]); time = request.getRange().getEnd(); t = t.replaceAll("%DATETIME_TO%", time.get(Calendar.YEAR) + "/" + "where uri=? and utcdatetime > ? and utcdatetime < ? order by utcdatetime desc ;"); com.setString(1, url); com.setLong(2, request.getRange().getStart().getTimeInMillis()); com.setLong(3, request.getRange().getEnd().getTimeInMillis());
@WebParam(name = "range", targetNamespace = "urn:org:miloss:fgsms:services:interfaces:dataAccessService") TimeRange range) throws AccessDeniedException, ServiceUnavailableException { if (range == null || range.getEnd() == null || range.getStart() == null) { throw new IllegalArgumentException("Missing input parameters");
return; double d = range.getEnd().getTimeInMillis() - range.getStart().getTimeInMillis(); double day = d / 86400000; double hours = d / 3600000; try { cmd = con.prepareStatement("select hostingsource from rawdata where (UTCdatetime > ?) and (UTCdatetime < ?) group by hostingsource ;"); cmd.setLong(1, range.getStart().getTimeInMillis()); cmd.setLong(2, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); while (rs.next()) { + "(UTCdatetime > ?) and (UTCdatetime < ?) ;"); cmd.setString(1, hosts.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery();
+ "(UTCdatetime > ?) and (UTCdatetime < ?) ;"); cmd.setString(1, urls.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); double d = range.getEnd().getTimeInMillis() - range.getStart().getTimeInMillis(); double day = d / 86400000; double hours = d / 3600000;
cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); cmd = con.prepareStatement("select avg(writekbs) from rawdatadrives where uri=? and utcdatetime > ? and utcdatetime < ?;"); cmd.setString(1, urls.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); cmd = con.prepareStatement("select avg(readkbs) from rawdatadrives where uri=? and utcdatetime > ? and utcdatetime < ?;"); cmd.setString(1, urls.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); cmd = con.prepareStatement("select readkbs, writekbs,freespace, utcdatetime, driveidentifier from rawdatadrives where uri=? and utcdatetime > ? and utcdatetime < ?;"); cmd.setString(1, urls.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery();
cmd = con.prepareStatement("select avg(openfiles) from rawdatamachineprocess where uri=? and utcdatetime > ? and utcdatetime < ?;"); cmd.setString(1, urls.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis());
cmd = con.prepareStatement("select avg(sendkbs) from rawdatanic where uri=? and utcdatetime > ? and utcdatetime < ?;"); cmd.setString(1, urls.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); cmd = con.prepareStatement("select avg(receivekbs) from rawdatanic where uri=? and utcdatetime > ? and utcdatetime < ?;"); cmd.setString(1, urls.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery(); cmd = con.prepareStatement("select receivekbs, sendkbs, utcdatetime, nicid from rawdatanic where uri=? and utcdatetime > ? and utcdatetime < ?;"); cmd.setString(1, urls.get(i)); cmd.setLong(2, range.getStart().getTimeInMillis()); cmd.setLong(3, range.getEnd().getTimeInMillis()); rs = cmd.executeQuery();