| | |
| | | package cn.flightfeather.supervision.common.executor |
| | | |
| | | import org.springframework.scheduling.annotation.Async |
| | | import java.time.LocalDateTime |
| | | import java.util.concurrent.Future |
| | | |
| | |
| | | } |
| | | |
| | | fun execute() { |
| | | val res = task() |
| | | if (res) success() else fail() |
| | | try { |
| | | val res = task() |
| | | if (res) success() else fail() |
| | | } catch (e: Exception) { |
| | | fail() |
| | | taskStatus.extra = e.message |
| | | } |
| | | } |
| | | |
| | | fun success() { |
| | |
| | | fun shutdown() { |
| | | if (future?.isCancelled == false && !future!!.isDone) { |
| | | future!!.cancel(true) |
| | | taskStatus.status = TaskStatus.SHUTDOWN |
| | | complete() |
| | | } |
| | | taskStatus.status = TaskStatus.SHUTDOWN |
| | | complete() |
| | | } |
| | | |
| | | fun complete() { |