-
Notifications
You must be signed in to change notification settings - Fork 590
Added query for composed-task-runner status. #5792
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
Merged
corneil
merged 4 commits into
spring-cloud:main
from
corneil:corneil/gh-5782-thin-execution-task-status
May 6, 2024
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
import org.springframework.cloud.dataflow.aggregate.task.AggregateTaskExplorer; | ||
import org.springframework.cloud.dataflow.rest.resource.TaskExecutionThinResource; | ||
import org.springframework.cloud.dataflow.schema.AggregateTaskExecution; | ||
import org.springframework.cloud.dataflow.server.service.TaskJobService; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.web.PagedResourcesAssembler; | ||
import org.springframework.hateoas.PagedModel; | ||
|
@@ -26,6 +28,8 @@ | |
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
|
@@ -44,15 +48,29 @@ public class TaskExecutionThinController { | |
private final AggregateTaskExplorer explorer; | ||
private final TaskExecutionThinResourceAssembler resourceAssembler; | ||
|
||
public TaskExecutionThinController(AggregateTaskExplorer explorer) { | ||
private final TaskJobService taskJobService; | ||
|
||
public TaskExecutionThinController(AggregateTaskExplorer explorer, TaskJobService taskJobService) { | ||
this.explorer = explorer; | ||
this.taskJobService = taskJobService; | ||
this.resourceAssembler = new TaskExecutionThinResourceAssembler(); | ||
} | ||
|
||
@GetMapping(produces = "application/json") | ||
@ResponseStatus(HttpStatus.OK) | ||
public PagedModel<TaskExecutionThinResource> listTasks(Pageable pageable, PagedResourcesAssembler<AggregateTaskExecution> pagedAssembler) { | ||
return pagedAssembler.toModel(explorer.findAll(pageable, true), resourceAssembler); | ||
Page<AggregateTaskExecution> page = explorer.findAll(pageable, true); | ||
taskJobService.populateComposeTaskRunnerStatus(page.getContent()); | ||
return pagedAssembler.toModel(page, resourceAssembler); | ||
} | ||
|
||
@RequestMapping(value = "", method = RequestMethod.GET, params = "name") | ||
@ResponseStatus(HttpStatus.OK) | ||
public PagedModel<TaskExecutionThinResource> retrieveTasksByName(@RequestParam("name") String taskName, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have a test to verify the population of the status? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adding |
||
Pageable pageable, PagedResourcesAssembler<AggregateTaskExecution> pagedAssembler) { | ||
Page<AggregateTaskExecution> page = this.explorer.findTaskExecutionsByName(taskName, pageable); | ||
taskJobService.populateComposeTaskRunnerStatus(page.getContent()); | ||
return pagedAssembler.toModel(page, resourceAssembler); | ||
} | ||
|
||
static class TaskExecutionThinResourceAssembler extends RepresentationModelAssemblerSupport<AggregateTaskExecution, TaskExecutionThinResource> { | ||
|
45 changes: 45 additions & 0 deletions
45
...gframework/cloud/dataflow/server/db/migration/AbstractCreateTaskParentIndexMigration.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.cloud.dataflow.server.db.migration; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.springframework.cloud.dataflow.common.flyway.AbstractMigration; | ||
import org.springframework.cloud.dataflow.common.flyway.SqlCommand; | ||
|
||
/** | ||
* Provide indexes to improve performance of finding child tasks. | ||
* @author Corneil du Plessis | ||
*/ | ||
public abstract class AbstractCreateTaskParentIndexMigration extends AbstractMigration { | ||
protected static final String CREATE_TASK_PARENT_INDEX = | ||
"create index TASK_EXECUTION_PARENT_IX on TASK_EXECUTION(PARENT_EXECUTION_ID)"; | ||
protected static final String CREATE_BOOT3_TASK_PARENT_INDEX = | ||
"create index BOOT3_TASK_EXECUTION_PARENT_IX on BOOT3_TASK_EXECUTION(PARENT_EXECUTION_ID)"; | ||
|
||
public AbstractCreateTaskParentIndexMigration() { | ||
super(null); | ||
} | ||
|
||
@Override | ||
public List<SqlCommand> getCommands() { | ||
return Arrays.asList( | ||
SqlCommand.from(CREATE_TASK_PARENT_INDEX), | ||
SqlCommand.from(CREATE_BOOT3_TASK_PARENT_INDEX) | ||
); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...rg/springframework/cloud/dataflow/server/db/migration/db2/V11__CreateTaskParentIndex.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.springframework.cloud.dataflow.server.db.migration.db2; | ||
|
||
import org.springframework.cloud.dataflow.server.db.migration.AbstractCreateTaskParentIndexMigration; | ||
|
||
public class V11__CreateTaskParentIndex extends AbstractCreateTaskParentIndexMigration { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...pringframework/cloud/dataflow/server/db/migration/mariadb/V12__CreateTaskParentIndex.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.springframework.cloud.dataflow.server.db.migration.mariadb; | ||
|
||
import org.springframework.cloud.dataflow.server.db.migration.AbstractCreateTaskParentIndexMigration; | ||
|
||
public class V12__CreateTaskParentIndex extends AbstractCreateTaskParentIndexMigration { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
.../springframework/cloud/dataflow/server/db/migration/mysql/V12__CreateTaskParentIndex.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.springframework.cloud.dataflow.server.db.migration.mysql; | ||
|
||
import org.springframework.cloud.dataflow.server.db.migration.AbstractCreateTaskParentIndexMigration; | ||
|
||
public class V12__CreateTaskParentIndex extends AbstractCreateTaskParentIndexMigration { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...springframework/cloud/dataflow/server/db/migration/oracle/V12__CreateTaskParentIndex.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.springframework.cloud.dataflow.server.db.migration.oracle; | ||
|
||
import org.springframework.cloud.dataflow.server.db.migration.AbstractCreateTaskParentIndexMigration; | ||
|
||
public class V12__CreateTaskParentIndex extends AbstractCreateTaskParentIndexMigration { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...ngframework/cloud/dataflow/server/db/migration/postgresql/V13__CreateTaskParentIndex.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.springframework.cloud.dataflow.server.db.migration.postgresql; | ||
|
||
import org.springframework.cloud.dataflow.server.db.migration.AbstractCreateTaskParentIndexMigration; | ||
|
||
public class V13__CreateTaskParentIndex extends AbstractCreateTaskParentIndexMigration { | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
...ingframework/cloud/dataflow/server/db/migration/sqlserver/V11__CreateTaskParentIndex.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.springframework.cloud.dataflow.server.db.migration.sqlserver; | ||
|
||
import org.springframework.cloud.dataflow.server.db.migration.AbstractCreateTaskParentIndexMigration; | ||
|
||
public class V11__CreateTaskParentIndex extends AbstractCreateTaskParentIndexMigration { | ||
|
||
} |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we determined the cost of running the retrieval of the CTR status for the results set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I compared before and after timings from
org.springframework.cloud.dataflow.integration.test.tasks.TaskExecutionQueryIT
I added index in parent_execution_id and now the difference is hardly noticeable.