resource.getId(), resource.getResourceType(), resource.getExpectedTerminationTime()));
resource.setState(CleanupState.MARKED);
resource.setMarkTime(now);
if (!leashed) {
if (recorder != null) {
Event evt = recorder.newEvent(Type.JANITOR, EventTypes.MARK_RESOURCE, region, resource.getId());
recorder.recordEvent(evt);
}
resourceTracker.addOrUpdate(resource);
postMark(resource);
} else {
LOGGER.info(String.format(
"The janitor is leashed, no data change is made for marking the resource %s.",
resource.getId()));
}
markedResources.add(resource);
} else if (trackedResource != null) {
// The resource was marked and now the rule engine does not consider it as a cleanup candidate.
// So the janitor needs to unmark the resource.
LOGGER.info(String.format("Unmarking resource %s", resource.getId()));
resource.setState(CleanupState.UNMARKED);
if (!leashed) {
if (recorder != null) {
Event evt = recorder.newEvent(
Type.JANITOR, EventTypes.UNMARK_RESOURCE, region, resource.getId());
recorder.recordEvent(evt);
}
resourceTracker.addOrUpdate(resource);
} else {