You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "Flaugh24 (via GitHub)" <gi...@apache.org> on 2024/01/17 15:49:50 UTC
[PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Flaugh24 opened a new pull request, #3062:
URL: https://github.com/apache/ignite-3/pull/3062
https://issues.apache.org/jira/browse/IGNITE-20848
Thank you for submitting the pull request.
To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:
### The Review Checklist
- [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:
\- There is a single JIRA ticket related to the pull request.
\- The web-link to the pull request is attached to the JIRA ticket.
\- The JIRA ticket has the Patch Available state.
\- The description of the JIRA ticket explains WHAT was made, WHY and HOW.
\- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
- [ ] **Design:** new code conforms with the design principles of the components it is added to.
- [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
- [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
- [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
### Notes
- [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Posted by "Flaugh24 (via GitHub)" <gi...@apache.org>.
Flaugh24 commented on code in PR #3062:
URL: https://github.com/apache/ignite-3/pull/3062#discussion_r1465075336
##########
modules/rest-api/openapi/openapi.yaml:
##########
@@ -118,6 +118,106 @@ paths:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
+ /management/v1/compute/jobs:
+ get:
+ tags:
+ - compute
+ summary: Retrieve all job statuses
+ description: Fetches the current statuses of all compute jobs.
+ operationId: jobStatuses
+ responses:
+ "200":
+ description: Successful retrieval of job statuses.
+ content:
+ application/json: {}
+ /management/v1/compute/jobs/{jobId}:
+ get:
+ tags:
+ - compute
+ summary: Retrieve a job status
+ description: Fetches the current status of a specific compute job identified
+ by jobId.
+ operationId: jobStatus
+ parameters:
+ - name: jobId
+ in: path
+ description: The unique identifier of the compute job.
+ required: true
+ schema:
+ type: string
+ description: The unique identifier of the compute job.
+ format: uuid
+ responses:
+ "200":
+ description: Successful retrieval of the job status.
+ content:
+ application/json: {}
+ "404":
+ description: Compute job not found.
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Problem'
+ delete:
+ tags:
+ - compute
+ summary: Cancel a job
+ description: Cancels a specific compute job identified by jobId.
+ operationId: cancelJob
+ parameters:
+ - name: jobId
+ in: path
+ description: The unique identifier of the compute job.
+ required: true
+ schema:
+ type: string
+ description: The unique identifier of the compute job.
+ format: uuid
+ responses:
+ "200":
+ description: Successful cancellation of the job.
+ content:
+ application/json: {}
+ "404":
+ description: Compute job not found.
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Problem'
+ /management/v1/compute/jobs/{jobId}/priority:
+ put:
+ tags:
+ - compute
+ summary: Update a job's priority
+ description: Updates the priority of a specific compute job identified by jobId.
+ operationId: updatePriority
+ parameters:
+ - name: jobId
+ in: path
+ description: The unique identifier of the compute job.
+ required: true
+ schema:
+ type: string
+ description: The unique identifier of the compute job.
+ format: uuid
+ requestBody:
+ description: The new priority data for the job.
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/UpdateJobPriorityBody'
Review Comment:
I think it's weird to give responses in different formats - plaintext/json
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander commented on code in PR #3062:
URL: https://github.com/apache/ignite-3/pull/3062#discussion_r1464965170
##########
modules/rest-api/openapi/openapi.yaml:
##########
@@ -118,6 +118,106 @@ paths:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
+ /management/v1/compute/jobs:
+ get:
+ tags:
+ - compute
+ summary: Retrieve all job statuses
+ description: Fetches the current statuses of all compute jobs.
+ operationId: jobStatuses
+ responses:
+ "200":
+ description: Successful retrieval of job statuses.
+ content:
+ application/json: {}
+ /management/v1/compute/jobs/{jobId}:
+ get:
+ tags:
+ - compute
+ summary: Retrieve a job status
+ description: Fetches the current status of a specific compute job identified
+ by jobId.
+ operationId: jobStatus
+ parameters:
+ - name: jobId
+ in: path
+ description: The unique identifier of the compute job.
+ required: true
+ schema:
+ type: string
+ description: The unique identifier of the compute job.
+ format: uuid
+ responses:
+ "200":
+ description: Successful retrieval of the job status.
+ content:
+ application/json: {}
+ "404":
+ description: Compute job not found.
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Problem'
+ delete:
+ tags:
+ - compute
+ summary: Cancel a job
+ description: Cancels a specific compute job identified by jobId.
+ operationId: cancelJob
+ parameters:
+ - name: jobId
+ in: path
+ description: The unique identifier of the compute job.
+ required: true
+ schema:
+ type: string
+ description: The unique identifier of the compute job.
+ format: uuid
+ responses:
+ "200":
+ description: Successful cancellation of the job.
+ content:
+ application/json: {}
Review Comment:
We should define the scheme for JobStatus and JobStatuses
##########
modules/rest/src/testFixtures/java/org/apache/ignite/internal/rest/matcher/ProblemMatcher.java:
##########
@@ -0,0 +1,211 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://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.apache.ignite.internal.rest.matcher;
+
+import static org.hamcrest.Matchers.equalTo;
+
+import java.util.Collection;
+import java.util.UUID;
+import org.apache.ignite.internal.rest.api.InvalidParam;
+import org.apache.ignite.internal.rest.api.Problem;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+
+/**
+ * Matcher for {@link Problem}.
+ */
+public class ProblemMatcher extends TypeSafeMatcher<Problem> {
+ private Matcher<String> titleMatcher;
+
+ private Matcher<Integer> statusMatcher;
+
+ private Matcher<String> codeMatcher;
+
+ private Matcher<String> typeMatcher;
+
+ private Matcher<String> detailMatcher;
+
+ private Matcher<String> nodeMatcher;
+
+ private Matcher<UUID> traceIdMatcher;
+
+ private Matcher<Collection<InvalidParam>> invalidParamsMatcher;
+
+ /**
+ * Creates a matcher for {@link Problem}.
+ *
+ * @return Matcher.
+ */
+ public static ProblemMatcher isProblem() {
Review Comment:
JobStatus matcher uses builder-like style but here you prefer another one. Can you use the same style for all matchers?
##########
modules/rest-api/openapi/openapi.yaml:
##########
@@ -118,6 +118,106 @@ paths:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
+ /management/v1/compute/jobs:
+ get:
+ tags:
+ - compute
+ summary: Retrieve all job statuses
+ description: Fetches the current statuses of all compute jobs.
+ operationId: jobStatuses
+ responses:
+ "200":
+ description: Successful retrieval of job statuses.
+ content:
+ application/json: {}
+ /management/v1/compute/jobs/{jobId}:
+ get:
+ tags:
+ - compute
+ summary: Retrieve a job status
+ description: Fetches the current status of a specific compute job identified
+ by jobId.
+ operationId: jobStatus
+ parameters:
+ - name: jobId
+ in: path
+ description: The unique identifier of the compute job.
+ required: true
+ schema:
+ type: string
+ description: The unique identifier of the compute job.
+ format: uuid
+ responses:
+ "200":
+ description: Successful retrieval of the job status.
+ content:
+ application/json: {}
+ "404":
+ description: Compute job not found.
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Problem'
+ delete:
+ tags:
+ - compute
+ summary: Cancel a job
+ description: Cancels a specific compute job identified by jobId.
+ operationId: cancelJob
+ parameters:
+ - name: jobId
+ in: path
+ description: The unique identifier of the compute job.
+ required: true
+ schema:
+ type: string
+ description: The unique identifier of the compute job.
+ format: uuid
+ responses:
+ "200":
+ description: Successful cancellation of the job.
+ content:
+ application/json: {}
+ "404":
+ description: Compute job not found.
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Problem'
+ /management/v1/compute/jobs/{jobId}/priority:
+ put:
+ tags:
+ - compute
+ summary: Update a job's priority
+ description: Updates the priority of a specific compute job identified by jobId.
+ operationId: updatePriority
+ parameters:
+ - name: jobId
+ in: path
+ description: The unique identifier of the compute job.
+ required: true
+ schema:
+ type: string
+ description: The unique identifier of the compute job.
+ format: uuid
+ requestBody:
+ description: The new priority data for the job.
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/UpdateJobPriorityBody'
Review Comment:
I think that if the priority is an int, why don't we just put number in body?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Posted by "Flaugh24 (via GitHub)" <gi...@apache.org>.
Flaugh24 commented on code in PR #3062:
URL: https://github.com/apache/ignite-3/pull/3062#discussion_r1465075336
##########
modules/rest-api/openapi/openapi.yaml:
##########
@@ -118,6 +118,106 @@ paths:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
+ /management/v1/compute/jobs:
+ get:
+ tags:
+ - compute
+ summary: Retrieve all job statuses
+ description: Fetches the current statuses of all compute jobs.
+ operationId: jobStatuses
+ responses:
+ "200":
+ description: Successful retrieval of job statuses.
+ content:
+ application/json: {}
+ /management/v1/compute/jobs/{jobId}:
+ get:
+ tags:
+ - compute
+ summary: Retrieve a job status
+ description: Fetches the current status of a specific compute job identified
+ by jobId.
+ operationId: jobStatus
+ parameters:
+ - name: jobId
+ in: path
+ description: The unique identifier of the compute job.
+ required: true
+ schema:
+ type: string
+ description: The unique identifier of the compute job.
+ format: uuid
+ responses:
+ "200":
+ description: Successful retrieval of the job status.
+ content:
+ application/json: {}
+ "404":
+ description: Compute job not found.
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Problem'
+ delete:
+ tags:
+ - compute
+ summary: Cancel a job
+ description: Cancels a specific compute job identified by jobId.
+ operationId: cancelJob
+ parameters:
+ - name: jobId
+ in: path
+ description: The unique identifier of the compute job.
+ required: true
+ schema:
+ type: string
+ description: The unique identifier of the compute job.
+ format: uuid
+ responses:
+ "200":
+ description: Successful cancellation of the job.
+ content:
+ application/json: {}
+ "404":
+ description: Compute job not found.
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Problem'
+ /management/v1/compute/jobs/{jobId}/priority:
+ put:
+ tags:
+ - compute
+ summary: Update a job's priority
+ description: Updates the priority of a specific compute job identified by jobId.
+ operationId: updatePriority
+ parameters:
+ - name: jobId
+ in: path
+ description: The unique identifier of the compute job.
+ required: true
+ schema:
+ type: string
+ description: The unique identifier of the compute job.
+ format: uuid
+ requestBody:
+ description: The new priority data for the job.
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/UpdateJobPriorityBody'
Review Comment:
I think it's weird to give responses in different formats - plaintext/json
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Posted by "valepakh (via GitHub)" <gi...@apache.org>.
valepakh commented on code in PR #3062:
URL: https://github.com/apache/ignite-3/pull/3062#discussion_r1464813021
##########
modules/compute/src/main/java/org/apache/ignite/internal/compute/messaging/ComputeMessaging.java:
##########
@@ -247,6 +257,35 @@ private void sendJobResultResponse(
messagingService.respond(senderConsistentId, jobResultResponse, correlationId);
}
+ CompletableFuture<Collection<JobStatus>> remoteStatusesAsync(ClusterNode remoteNode) {
+ JobStatusesRequest jobStatusRequest = messagesFactory.jobStatusesRequest()
+ .build();
+
+ return messagingService.invoke(remoteNode, jobStatusRequest, NETWORK_TIMEOUT_MILLIS)
+ .thenCompose(networkMessage -> statusesFromJobStatusesResponse((JobStatusesResponse) networkMessage));
+ }
+
+ private void processJobStatusesRequest(JobStatusesRequest message, String senderConsistentId, long correlationId) {
+ executionManager.localStatusesAsync()
+ .whenComplete((statuses, throwable) ->
+ this.sendJobStatusesResponse(statuses, throwable, senderConsistentId, correlationId)
Review Comment:
```suggestion
.whenComplete((statuses, throwable) -> sendJobStatusesResponse(statuses, throwable, senderConsistentId, correlationId)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Posted by "valepakh (via GitHub)" <gi...@apache.org>.
valepakh commented on code in PR #3062:
URL: https://github.com/apache/ignite-3/pull/3062#discussion_r1464812445
##########
modules/compute/src/main/java/org/apache/ignite/internal/compute/messaging/ComputeMessaging.java:
##########
@@ -247,6 +257,35 @@ private void sendJobResultResponse(
messagingService.respond(senderConsistentId, jobResultResponse, correlationId);
}
+ CompletableFuture<Collection<JobStatus>> remoteStatusesAsync(ClusterNode remoteNode) {
+ JobStatusesRequest jobStatusRequest = messagesFactory.jobStatusesRequest()
+ .build();
+
+ return messagingService.invoke(remoteNode, jobStatusRequest, NETWORK_TIMEOUT_MILLIS)
+ .thenCompose(networkMessage -> statusesFromJobStatusesResponse((JobStatusesResponse) networkMessage));
+ }
+
+ private void processJobStatusesRequest(JobStatusesRequest message, String senderConsistentId, long correlationId) {
+ executionManager.localStatusesAsync()
+ .whenComplete((statuses, throwable) ->
+ this.sendJobStatusesResponse(statuses, throwable, senderConsistentId, correlationId)
Review Comment:
```suggestion
sendJobStatusesResponse(statuses, throwable, senderConsistentId, correlationId)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Posted by "valepakh (via GitHub)" <gi...@apache.org>.
valepakh commented on code in PR #3062:
URL: https://github.com/apache/ignite-3/pull/3062#discussion_r1464812445
##########
modules/compute/src/main/java/org/apache/ignite/internal/compute/messaging/ComputeMessaging.java:
##########
@@ -247,6 +257,35 @@ private void sendJobResultResponse(
messagingService.respond(senderConsistentId, jobResultResponse, correlationId);
}
+ CompletableFuture<Collection<JobStatus>> remoteStatusesAsync(ClusterNode remoteNode) {
+ JobStatusesRequest jobStatusRequest = messagesFactory.jobStatusesRequest()
+ .build();
+
+ return messagingService.invoke(remoteNode, jobStatusRequest, NETWORK_TIMEOUT_MILLIS)
+ .thenCompose(networkMessage -> statusesFromJobStatusesResponse((JobStatusesResponse) networkMessage));
+ }
+
+ private void processJobStatusesRequest(JobStatusesRequest message, String senderConsistentId, long correlationId) {
+ executionManager.localStatusesAsync()
+ .whenComplete((statuses, throwable) ->
+ this.sendJobStatusesResponse(statuses, throwable, senderConsistentId, correlationId)
Review Comment:
```suggestion
sendJobStatusesResponse(statuses, throwable, senderConsistentId, correlationId)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Posted by "valepakh (via GitHub)" <gi...@apache.org>.
valepakh commented on code in PR #3062:
URL: https://github.com/apache/ignite-3/pull/3062#discussion_r1464817554
##########
modules/compute/src/main/java/org/apache/ignite/internal/compute/messaging/ComputeMessaging.java:
##########
@@ -360,6 +399,26 @@ private void sendJobChangePriorityResponse(
messagingService.respond(senderConsistentId, jobChangePriorityResponse, correlationId);
}
+ /**
+ * Broadcasts job statuses request to all nodes in the cluster.
+ *
+ * @return The future which will be completed with the collection of statuses from all nodes.
+ */
+ public CompletableFuture<Collection<JobStatus>> broadcastStatusesAsync() {
+ return broadcastAsyncAndCollect(
+ node -> remoteStatusesAsync(node),
+ throwable -> new ComputeException(
+ FAIL_TO_GET_JOB_STATUS_ERR,
+ "Failed to retrieve statuses",
+ throwable
+ )).thenApply(statuses -> {
+ return statuses.stream()
+ .flatMap(Collection::stream)
+ .filter(Objects::nonNull)
+ .collect(toList());
+ });
Review Comment:
```suggestion
));
```
I don't think this is needed, the collection from the `broadcastAsyncAndCollect` is already filtered.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Posted by "valepakh (via GitHub)" <gi...@apache.org>.
valepakh commented on code in PR #3062:
URL: https://github.com/apache/ignite-3/pull/3062#discussion_r1464817554
##########
modules/compute/src/main/java/org/apache/ignite/internal/compute/messaging/ComputeMessaging.java:
##########
@@ -360,6 +399,26 @@ private void sendJobChangePriorityResponse(
messagingService.respond(senderConsistentId, jobChangePriorityResponse, correlationId);
}
+ /**
+ * Broadcasts job statuses request to all nodes in the cluster.
+ *
+ * @return The future which will be completed with the collection of statuses from all nodes.
+ */
+ public CompletableFuture<Collection<JobStatus>> broadcastStatusesAsync() {
+ return broadcastAsyncAndCollect(
+ node -> remoteStatusesAsync(node),
+ throwable -> new ComputeException(
+ FAIL_TO_GET_JOB_STATUS_ERR,
+ "Failed to retrieve statuses",
+ throwable
+ )).thenApply(statuses -> {
+ return statuses.stream()
+ .flatMap(Collection::stream)
+ .filter(Objects::nonNull)
+ .collect(toList());
+ });
Review Comment:
```suggestion
));
```
I don't think this is needed, the collection from the `broadcastAsyncAndCollect` is already filtered.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Posted by "valepakh (via GitHub)" <gi...@apache.org>.
valepakh commented on code in PR #3062:
URL: https://github.com/apache/ignite-3/pull/3062#discussion_r1472646563
##########
modules/compute/src/main/java/org/apache/ignite/internal/compute/messaging/ComputeMessaging.java:
##########
@@ -247,6 +257,34 @@ private void sendJobResultResponse(
messagingService.respond(senderConsistentId, jobResultResponse, correlationId);
}
+ CompletableFuture<Collection<JobStatus>> remoteStatusesAsync(ClusterNode remoteNode) {
+ JobStatusesRequest jobStatusRequest = messagesFactory.jobStatusesRequest()
+ .build();
+
+ return messagingService.invoke(remoteNode, jobStatusRequest, NETWORK_TIMEOUT_MILLIS)
+ .thenCompose(networkMessage -> statusesFromJobStatusesResponse((JobStatusesResponse) networkMessage));
+ }
+
+ private void processJobStatusesRequest(JobStatusesRequest message, String senderConsistentId, long correlationId) {
+ executionManager.localStatusesAsync()
+ .whenComplete((statuses, throwable) -> sendJobStatusesResponse(statuses, throwable, senderConsistentId, correlationId)
+ );
Review Comment:
```suggestion
.whenComplete((statuses, throwable) -> sendJobStatusesResponse(statuses, throwable, senderConsistentId, correlationId));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander merged PR #3062:
URL: https://github.com/apache/ignite-3/pull/3062
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Posted by "valepakh (via GitHub)" <gi...@apache.org>.
valepakh commented on code in PR #3062:
URL: https://github.com/apache/ignite-3/pull/3062#discussion_r1463278445
##########
modules/compute/src/main/java/org/apache/ignite/internal/compute/messaging/ComputeMessaging.java:
##########
@@ -448,6 +496,32 @@ private void sendJobChangePriorityResponse(
result.completeExceptionally(error.apply(throwable));
}
});
+
+ return result;
+ }
+
+ private <R> CompletableFuture<Collection<R>> broadcastAsyncAndCollect(
+ Function<ClusterNode, CompletableFuture<@Nullable R>> request,
+ Function<Throwable, Throwable> error
+ ) {
+ CompletableFuture<Collection<R>> result = new CompletableFuture<>();
+
+ CompletableFuture<R>[] futures = topologyService.allMembers()
+ .stream()
+ .map(request::apply)
+ .toArray(CompletableFuture[]::new);
+
+ allOf(futures).thenApply(unused -> {
+ return Arrays.stream(futures)
+ .map(CompletableFuture::join)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList());
+ })
+ .thenAccept(result::complete)
+ .whenComplete((unused, throwable) -> {
+ result.completeExceptionally(error.apply(throwable));
Review Comment:
It took me a minute to understand that `completeExceptionally` is skipped in case there were no exceptions, let's make it explicit?
```suggestion
.whenComplete((statuses, throwable) -> {
if (throwable == null) {
result.complete(statuses);
} else {
result.completeExceptionally(error.apply(throwable));
}
```
##########
modules/compute/src/main/java/org/apache/ignite/internal/compute/messaging/ComputeMessaging.java:
##########
@@ -247,6 +256,25 @@ private void sendJobResultResponse(
messagingService.respond(senderConsistentId, jobResultResponse, correlationId);
}
+ CompletableFuture<Set<JobStatus>> remoteStatusesAsync(ClusterNode remoteNode) {
+ JobStatusesRequest jobStatusRequest = messagesFactory.jobStatusesRequest()
+ .build();
+
+ return messagingService.invoke(remoteNode, jobStatusRequest, NETWORK_TIMEOUT_MILLIS)
+ .thenCompose(networkMessage -> statusesFromJobStatusesResponse((JobStatusesResponse) networkMessage));
+ }
+
+ private void processJobStatusesRequest(JobStatusesRequest message, String senderConsistentId, long correlationId) {
+ executionManager.localStatusesAsync()
+ .thenCompose(statuses -> {
+ JobStatusesResponse jobStatusesResponse = messagesFactory.jobStatusesResponse()
+ .statuses(statuses)
+ .build();
+
+ return messagingService.respond(senderConsistentId, jobStatusesResponse, correlationId);
Review Comment:
You should extract this to a method and send the error response from `sendException` method as well.
##########
modules/compute/src/main/java/org/apache/ignite/internal/compute/ComputeComponent.java:
##########
@@ -103,6 +104,13 @@ default <R> JobExecution<R> executeRemotely(
return executeRemotely(ExecutionOptions.DEFAULT, remoteNode, units, jobClassName, args);
}
+ /**
+ * Retrieves the current status of all jobs on all nodes in the cluster.
+ *
+ * @return The set of all job statuses.
+ */
+ CompletableFuture<Set<JobStatus>> statusesAsync();
Review Comment:
Couldn't we use list here? What's the reason for a set?
##########
modules/rest/src/testFixtures/java/org/apache/ignite/internal/rest/matcher/MicronautHttpResponseMatcher.java:
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://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.apache.ignite.internal.rest.matcher;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
+
+import io.micronaut.http.HttpResponse;
+import io.micronaut.http.HttpStatus;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+
+/**
+ * Matcher for {@link HttpResponse}.
+ */
+public class MicronautHttpResponseMatcher<T> extends TypeSafeMatcher<HttpResponse<?>> {
+ private final Matcher<Integer> statusCodeMatcher;
+
+ private Matcher<T> bodyMatcher;
+
+ private Class<T> body;
+
+ private MicronautHttpResponseMatcher(Matcher<Integer> statusCodeMatcher) {
+ this.statusCodeMatcher = statusCodeMatcher;
+ }
+
+ /**
+ * Creates a matcher that matches when the examined {@link HttpResponse} has a status that matches the specified status.
+ *
+ * @param status Expected status.
+ * @return Matcher.
+ */
+ public static <T> MicronautHttpResponseMatcher<T> hasStatus(HttpStatus status) {
+ return new MicronautHttpResponseMatcher<>(is(status.getCode()));
+ }
+
+ /**
+ * Creates a matcher that matches when the examined {@link HttpResponse} has a status code that matches the specified status code.
+ *
+ * @param statusCode Expected status code.
+ * @return Matcher.
+ */
+ public static <T> MicronautHttpResponseMatcher<T> hasStatusCode(int statusCode) {
+ return new MicronautHttpResponseMatcher<>(is(statusCode));
+ }
+
+ /**
+ * Sets the expected body.
+ *
+ * @param body Body to match.
+ * @return Matcher.
+ */
+ public MicronautHttpResponseMatcher<T> withBody(T body) {
+ this.bodyMatcher = equalTo(body);
+ this.body = (Class<T>) body.getClass();
+ return this;
+ }
+
+ /**
+ * Sets the body matcher.
+ *
+ * @param bodyMatcher Body matcher.
+ * @param body Body class.
+ * @return Matcher.
+ */
+ public MicronautHttpResponseMatcher<T> withBody(Matcher<T> bodyMatcher, Class<T> body) {
+ this.bodyMatcher = bodyMatcher;
+ this.body = body;
+ return this;
+ }
+
+ @Override
+ protected boolean matchesSafely(HttpResponse<?> httpResponse) {
+ if (!statusCodeMatcher.matches(httpResponse.code())) {
+ return false;
+ }
+
+ if (bodyMatcher != null && !bodyMatcher.matches(httpResponse.getBody(body).get())) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ if (statusCodeMatcher != null) {
+ description.appendText("an HttpResponse with status code matching ").appendDescriptionOf(statusCodeMatcher);
+ }
+
+ if (bodyMatcher != null) {
+ description.appendText(" and body ").appendDescriptionOf(bodyMatcher);
+ }
+ }
+
+ @Override
+ protected void describeMismatchSafely(HttpResponse<?> item, Description mismatchDescription) {
+ mismatchDescription.appendText("status code was ")
+ .appendValue(item.code())
+ .appendText(" and ")
+ .appendText("body was ")
Review Comment:
```suggestion
.appendText(" and body was ")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander commented on code in PR #3062:
URL: https://github.com/apache/ignite-3/pull/3062#discussion_r1467019363
##########
modules/rest-api/openapi/openapi.yaml:
##########
@@ -912,6 +1064,15 @@ components:
- $ref: '#/components/schemas/State'
- description: Node status.
description: Node state.
+ OperationResult:
Review Comment:
I think it is enough to use HTTP codes to indicate if something is done or there is an error.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-20848 Introduce management REST API for Compute [ignite-3]
Posted by "PakhomovAlexander (via GitHub)" <gi...@apache.org>.
PakhomovAlexander commented on code in PR #3062:
URL: https://github.com/apache/ignite-3/pull/3062#discussion_r1472678907
##########
modules/rest/src/main/java/org/apache/ignite/internal/rest/compute/exception/handler/ComputeJobStateExceptionHandler.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://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.apache.ignite.internal.rest.compute.exception.handler;
+
+import io.micronaut.context.annotation.Requires;
+import io.micronaut.http.HttpRequest;
+import io.micronaut.http.HttpResponse;
+import io.micronaut.http.server.exceptions.ExceptionHandler;
+import jakarta.inject.Singleton;
+import org.apache.ignite.internal.rest.api.Problem;
+import org.apache.ignite.internal.rest.compute.exception.ComputeJobStateException;
+import org.apache.ignite.internal.rest.constants.HttpCode;
+import org.apache.ignite.internal.rest.problem.HttpProblemResponse;
+
+/**
+ * REST exception handler for {@link ComputeJobStateException}.
+ */
+@Singleton
+@Requires(classes = {ComputeJobStateException.class, ExceptionHandler.class})
+
Review Comment:
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org