Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): typo isTerminated #953

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public Optional<TaskRun> findLastNotTerminated() {

return Streams.findLast(this.taskRunList
.stream()
.filter(t -> !t.getState().isTerninated())
.filter(t -> !t.getState().isTerminated())
);
}

Expand Down Expand Up @@ -296,7 +296,7 @@ public Optional<TaskRun> findLastTerminated(List<ResolvedTask> resolvedTasks, Ta

return Streams.findLast(this.findTaskRunByTasks(resolvedTasks, taskRun)
.stream()
.filter(t -> t.getState().isTerninated())
.filter(t -> t.getState().isTerminated())
);
}

Expand All @@ -308,7 +308,7 @@ public boolean isTerminated(List<ResolvedTask> resolvedTasks, TaskRun parentTask
long terminatedCount = this
.findTaskRunByTasks(resolvedTasks, parentTaskRun)
.stream()
.filter(taskRun -> taskRun.getState().isTerninated())
.filter(taskRun -> taskRun.getState().isTerminated())
.count();

return terminatedCount == resolvedTasks.size();
Expand Down Expand Up @@ -428,7 +428,7 @@ public boolean hasTaskRunJoinable(TaskRun taskRun) {
// don't have changed to failed but taskRunList will contain a failed
// same for restart, the CREATED status is directly on execution taskrun
// so we don't changed if current execution is terminated
if (current.getState().isTerninated() && !taskRun.getState().isTerninated()) {
if (current.getState().isTerminated() && !taskRun.getState().isTerminated()) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public TaskRun onRunningResend() {
} else {
ArrayList<TaskRunAttempt> taskRunAttempts = new ArrayList<>(taskRunBuilder.attempts);
TaskRunAttempt lastAttempt = taskRunAttempts.get(taskRunBuilder.attempts.size() - 1);
if (!lastAttempt.getState().isTerninated()) {
if (!lastAttempt.getState().isTerminated()) {
taskRunAttempts.set(taskRunBuilder.attempts.size() - 1, lastAttempt.withState(State.Type.KILLED));
} else {
taskRunAttempts.add(TaskRunAttempt.builder()
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/java/io/kestra/core/models/flows/State.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public Instant getStartDate() {

@JsonProperty(access = JsonProperty.Access.READ_ONLY)
public Optional<Instant> getEndDate() {
if (!this.isTerninated()) {
if (!this.isTerminated()) {
return Optional.empty();
}

Expand All @@ -109,8 +109,8 @@ public Instant maxDate() {
}

@JsonIgnore
public boolean isTerninated() {
return this.current.isTerninated();
public boolean isTerminated() {
return this.current.isTerminated();
}

@JsonIgnore
Expand Down Expand Up @@ -153,7 +153,7 @@ public enum Type {
FAILED,
KILLED;

public boolean isTerninated() {
public boolean isTerminated() {
return this == Type.FAILED || this == Type.WARNING || this == Type.SUCCESS || this == Type.KILLED || this == Type.PAUSED;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private Optional<WorkerTaskResult> childWorkerTaskResult(Flow flow, Execution ex

List<TaskRun> taskRunByTasks = execution.findTaskRunByTasks(currentTasks, parentTaskRun);

if (taskRunByTasks.stream().filter(t -> t.getState().isTerninated()).count() == taskRunByTasks.size()) {
if (taskRunByTasks.stream().filter(t -> t.getState().isTerminated()).count() == taskRunByTasks.size()) {
return childWorkerTaskTypeToWorkerTask(
Optional.of(State.Type.KILLED),
parent,
Expand Down Expand Up @@ -434,7 +434,7 @@ private Executor handleChildWorkerCreatedKilling(Executor executor) throws Inter


private Executor handleListeners(Executor executor) {
if (!executor.getExecution().getState().isTerninated()) {
if (!executor.getExecution().getState().isTerminated()) {
return executor;
}

Expand All @@ -457,7 +457,7 @@ private Executor handleListeners(Executor executor) {
}

private Executor handleEnd(Executor executor) {
if (executor.getExecution().getState().isTerninated()) {
if (executor.getExecution().getState().isTerminated()) {
return executor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void run() {
QueueInterface<Trigger> triggerQueue = applicationContext.getBean(QueueInterface.class, Qualifiers.byName(QueueFactoryInterface.TRIGGER_NAMED));

executionQueue.receive(execution -> {
if (execution.getState().getCurrent().isTerninated() && this.watchingTrigger.containsKey(execution.getId())) {
if (execution.getState().getCurrent().isTerminated() && this.watchingTrigger.containsKey(execution.getId())) {
Trigger trigger = watchingTrigger.get(execution.getId());
triggerQueue.emit(trigger.resetExecution());
triggerState.save(trigger.resetExecution());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ boolean valid(Flow flow, List<Condition> list, ConditionContext conditionContext
}

public boolean isTerminatedWithListeners(Flow flow, Execution execution) {
if (!execution.getState().isTerninated()) {
if (!execution.getState().isTerminated()) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class ExecutionService {
private LogRepositoryInterface logRepository;

public Execution restart(final Execution execution, @Nullable Integer revision) throws Exception {
if (!execution.getState().isTerninated()) {
if (!execution.getState().isTerminated()) {
throw new IllegalStateException("Execution must be terminated to be restarted, " +
"current state is '" + execution.getState().getCurrent() + "' !"
);
Expand Down Expand Up @@ -116,7 +116,7 @@ private Set<String> taskRunToRestart(Execution execution, Flow flow, Predicate<T
}

public Execution replay(final Execution execution, String taskRunId, @Nullable Integer revision) throws Exception {
if (!execution.getState().isTerninated()) {
if (!execution.getState().isTerminated()) {
throw new IllegalStateException("Execution must be terminated to be restarted, " +
"current state is '" + execution.getState().getCurrent() + "' !"
);
Expand Down Expand Up @@ -174,7 +174,7 @@ public Execution replay(final Execution execution, String taskRunId, @Nullable I
}

public Execution markAs(final Execution execution, String taskRunId, State.Type newState) throws Exception {
if (!execution.getState().isTerninated()) {
if (!execution.getState().isTerminated()) {
throw new IllegalStateException("Execution must be terminated to be restarted, " +
"current state is '" + execution.getState().getCurrent() + "' !"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ListenersTestTask.Output run(RunContext runContext) throws Exception {
Execution execution = retryInstance.run(
NoSuchElementException.class,
() -> executionRepository.findById(executionRendererId)
.filter(e -> e.getState().getCurrent().isTerninated())
.filter(e -> e.getState().getCurrent().isTerminated())
.orElseThrow(() -> new NoSuchElementException("Unable to find execution '" + executionRendererId + "'"))
);

Expand Down
4 changes: 2 additions & 2 deletions core/src/test/java/io/kestra/core/runners/WorkerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void success() throws TimeoutException {
workerTaskQueue.emit(workerTask("1"));

Await.until(
() -> workerTaskResult.get() != null && workerTaskResult.get().getTaskRun().getState().isTerninated(),
() -> workerTaskResult.get() != null && workerTaskResult.get().getTaskRun().getState().isTerminated(),
Duration.ofMillis(100),
Duration.ofMinutes(1)
);
Expand Down Expand Up @@ -99,7 +99,7 @@ void killed() throws InterruptedException, TimeoutException {
executionKilledQueue.emit(ExecutionKilled.builder().executionId(workerTask.getTaskRun().getExecutionId()).build());

Await.until(
() -> workerTaskResult.stream().filter(r -> r.getTaskRun().getState().isTerninated()).count() == 5,
() -> workerTaskResult.stream().filter(r -> r.getTaskRun().getState().isTerminated()).count() == 5,
Duration.ofMillis(100),
Duration.ofMinutes(1)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void run(String input, State.Type fromState, State.Type triggerState, int count
AtomicReference<Execution> triggered = new AtomicReference<>();

executionQueue.receive(execution -> {
if (execution.getFlowId().equals("switch") && execution.getState().getCurrent().isTerninated()) {
if (execution.getFlowId().equals("switch") && execution.getState().getCurrent().isTerminated()) {
countDownLatch.countDown();
triggered.set(execution);
}
Expand Down
2 changes: 1 addition & 1 deletion jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private void workerTaskResultQueue(WorkerTaskResult message) {
}

// send metrics on terminated
if (message.getTaskRun().getState().isTerninated()) {
if (message.getTaskRun().getState().isTerminated()) {
metricRegistry
.counter(MetricRegistry.EXECUTOR_TASKRUN_ENDED_COUNT, metricRegistry.tags(message))
.increment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void run() {
if (
execution.getTrigger() != null && (
execution.isDeleted() ||
execution.getState().getCurrent().isTerninated()
execution.getState().getCurrent().isTerminated()
)
) {
triggerRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ private void toWorkerTaskResultSend(KStream<String, WorkerTaskResult> stream, St

private void purgeWorkerRunning(KStream<String, WorkerTaskResult> workerTaskResultKStream) {
workerTaskResultKStream
.filter((key, value) -> value.getTaskRun().getState().isTerninated(), Named.as("PurgeWorkerRunning.filterTerminated"))
.filter((key, value) -> value.getTaskRun().getState().isTerminated(), Named.as("PurgeWorkerRunning.filterTerminated"))
.mapValues((readOnlyKey, value) -> (WorkerTaskRunning)null, Named.as("PurgeWorkerRunning.toNull"))
.to(
kafkaAdminService.getTopicName(WorkerTaskRunning.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Executor transform(final String key, final Executor value) {
}

// send metrics on terminated
if (workerTaskResult.getTaskRun().getState().isTerninated()) {
if (workerTaskResult.getTaskRun().getState().isTerminated()) {
metricRegistry
.counter(
MetricRegistry.EXECUTOR_TASKRUN_ENDED_COUNT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Executor transform(final String key, final ExecutionKilled value) {
}

if (executor.getExecution().getState().getCurrent() != State.Type.KILLING &&
!executor.getExecution().getState().isTerninated()
!executor.getExecution().getState().isTerminated()
) {
Execution newExecution = executor.getExecution().withState(State.Type.KILLING);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ private void workerTaskResultQueue(WorkerTaskResult message) {
}

// send metrics on terminated
if (message.getTaskRun().getState().isTerninated()) {
if (message.getTaskRun().getState().isTerminated()) {
metricRegistry
.counter(MetricRegistry.EXECUTOR_TASKRUN_ENDED_COUNT, metricRegistry.tags(message))
.increment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ public HttpResponse<?> kill(
@Parameter(description = "The execution id") String executionId
) {
Optional<Execution> execution = executionRepository.findById(executionId);
if (execution.isPresent() && execution.get().getState().isTerninated()) {
if (execution.isPresent() && execution.get().getState().isTerminated()) {
throw new IllegalStateException("Execution is already finished, can't kill it");
}

Expand Down Expand Up @@ -789,7 +789,7 @@ public MutableHttpResponse<?> killByIds(

for (String executionId : executionsId) {
Optional<Execution> execution = executionRepository.findById(executionId);
if (execution.isPresent() && execution.get().getState().isTerninated()) {
if (execution.isPresent() && execution.get().getState().isTerminated()) {
invalids.add(ManualConstraintViolation.of(
"execution already finished",
executionId,
Expand Down