use of com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResource.StatusUpdateException in project ma-modules-public by infiniteautomation.
the class MangoTaskTemporaryResourceManager method scheduleTimeout.
private void scheduleTimeout(TemporaryResource<T, AbstractRestException> resource) {
if (resource.getTimeout() <= 0)
return;
TaskData tasks = (TaskData) resource.getData();
Date timeoutDate = new Date(resource.getStartTime().getTime() + resource.getTimeout());
// TimeoutTask schedules itself to be executed
tasks.timeoutTask = new TimeoutTask(timeoutDate, new TimeoutClient() {
@Override
public void scheduleTimeout(long fireTime) {
try {
resource.timeOut();
} catch (StatusUpdateException e) {
if (log.isDebugEnabled()) {
log.debug("Tried to time out resource but it was already complete", e);
}
}
}
@Override
public String getThreadName() {
return "Temporary resource timeout " + resource.getResourceType() + " " + resource.getId();
}
@Override
public void rejected(RejectedTaskReason reason) {
super.rejected(reason);
try {
resource.timeOut();
} catch (StatusUpdateException e) {
if (log.isDebugEnabled()) {
log.debug("Tried to time out resource but it was already complete", e);
}
}
}
});
}
use of com.infiniteautomation.mango.rest.latest.temporaryResource.TemporaryResource.StatusUpdateException in project ma-modules-public by infiniteautomation.
the class MangoTaskTemporaryResourceManager method scheduleRemoval.
private void scheduleRemoval(TemporaryResource<T, AbstractRestException> resource) {
if (resource.getExpiration() <= 0) {
resource.remove();
return;
}
TaskData tasks = (TaskData) resource.getData();
Date expirationDate = new Date(resource.getCompletionTime().getTime() + resource.getExpiration());
// TimeoutTask schedules itself to be executed
tasks.expirationTask = new TimeoutTask(expirationDate, new TimeoutClient() {
@Override
public void scheduleTimeout(long fireTime) {
try {
resource.remove();
} catch (StatusUpdateException e) {
if (log.isDebugEnabled()) {
log.debug("Tried to remove resource but it was already complete", e);
}
}
}
@Override
public String getThreadName() {
return "Temporary resource expiration " + resource.getResourceType() + " " + resource.getId();
}
@Override
public void rejected(RejectedTaskReason reason) {
super.rejected(reason);
try {
resource.remove();
} catch (StatusUpdateException e) {
if (log.isDebugEnabled()) {
log.debug("Tried to remove resource but it was already complete", e);
}
}
}
});
}
Aggregations