// See if this resource is scheduled for an avail check
boolean checkAvail = false;
boolean deferToParent = false;
long availabilityScheduleTime = resourceContainer.getAvailabilityScheduleTime();
MeasurementScheduleRequest availScheduleRequest = resourceContainer.getAvailabilitySchedule();
// if no avail check is scheduled or we're forcing the check, schedule the next check. Note that a forcedCheck
// is "off-schedule" so we need to push out the next check.
if ((0 == availabilityScheduleTime) || isForced) {
// if there is no availability schedule (platform) then just perform the avail check
// (note, platforms always return UP anyway).
if (null == availScheduleRequest) {
if (traceEnabled) {
LOG.trace("No availScheduleRequest for " + resource + ". checkAvail set to true");
}
checkAvail = true;
} else {
// if the schedule is enabled then schedule the next avail check, else just defer to the parent type
if (availScheduleRequest.isEnabled()) {
// Schedule the avail check at some time between now and (now + collectionInterval). By
// doing this random assignment for the first scheduled collection, we'll spread out the actual
// check times going forward. Do not check it on this pass (unless we're forced)
int interval = (int) availScheduleRequest.getInterval(); // intervals are short enough for safe cast
availabilityScheduleTime = scan.startTime + RANDOM.nextInt(interval + 1);
resourceContainer.setAvailabilityScheduleTime(availabilityScheduleTime);
if (traceEnabled) {
LOG.trace("Forced availabilityScheduleTime to " + new Date(availabilityScheduleTime) + " for "
+ resource);
}
++scan.numScheduledRandomly;
} else {
if (traceEnabled) {
LOG.trace("Deferred availability to parent for " + resource);
}
deferToParent = true;
}
}
} else {
// check avail if this resource scheduled time has been reached
checkAvail = scan.startTime >= availabilityScheduleTime;
if (checkAvail) {
if (traceEnabled) {
LOG.trace("Scheduled time has been reached for " + resource);
}
long interval = availScheduleRequest.getInterval(); // intervals are short enough for safe cast
resourceContainer.setAvailabilityScheduleTime(scan.startTime + interval);
++scan.numPushedByInterval;
} else {
if (traceEnabled) {
LOG.trace("Scheduled time has not been reached for " + resource);