Created
October 19, 2018 17:41
-
-
Save robzienert/620a8c35c8d74b59add9fcaeb018ab1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
class AbortStageHandler( | |
override val queue: Queue, | |
override val eventRepository: ExecutionEventRepository, | |
@Qualifier("queueEventPublisher") private val publisher: ApplicationEventPublisher, | |
private val clock: Clock | |
) : OrcaMessageHandler<AbortStage> { | |
override fun handle(message: AbortStage) { | |
message.withStage { stage -> | |
if (stage.status in setOf(RUNNING, NOT_STARTED)) { | |
stage.status = TERMINAL | |
stage.endTime = clock.millis() | |
eventReposotory.record(StageAborted(stage, message)) | |
queue.push(CancelStage(message)) | |
if (stage.parentStageId == null) { | |
queue.push(CompleteExecution(message)) | |
} else { | |
queue.push(CompleteStage(stage.parent())) | |
} | |
publisher.publishEvent(StageComplete(this, stage)) | |
} | |
} | |
} | |
override val messageType = AbortStage::class.java | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
class AbortStageHandler( | |
override val queue: Queue, | |
override val repository: ExecutionRepository, | |
@Qualifier("queueEventPublisher") private val publisher: ApplicationEventPublisher, | |
private val clock: Clock | |
) : OrcaMessageHandler<AbortStage> { | |
override fun handle(message: AbortStage) { | |
message.withStage { stage -> | |
if (stage.status in setOf(RUNNING, NOT_STARTED)) { | |
stage.status = TERMINAL | |
stage.endTime = clock.millis() | |
repository.storeStage(stage) | |
queue.push(CancelStage(message)) | |
if (stage.parentStageId == null) { | |
queue.push(CompleteExecution(message)) | |
} else { | |
queue.push(CompleteStage(stage.parent())) | |
} | |
publisher.publishEvent(StageComplete(this, stage)) | |
} | |
} | |
} | |
override val messageType = AbortStage::class.java | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment