korlov42 commented on code in PR #4699:
URL: https://github.com/apache/ignite-3/pull/4699#discussion_r1840101218


##########
modules/sql-engine/src/integrationTest/java/org/apache/ignite/internal/sql/engine/ItComputeSystemViewTest.java:
##########
@@ -0,0 +1,311 @@
+/*
+ * 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.sql.engine;
+
+import static java.util.concurrent.CompletableFuture.completedFuture;
+import static org.apache.ignite.compute.JobStatus.CANCELED;
+import static org.apache.ignite.compute.JobStatus.EXECUTING;
+import static org.apache.ignite.internal.TestWrappers.unwrapIgniteImpl;
+import static org.apache.ignite.internal.sql.engine.util.Commons.closeQuiet;
+import static 
org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willBe;
+import static 
org.apache.ignite.internal.testframework.matchers.JobStateMatcher.jobStateWithStatus;
+import static 
org.apache.ignite.internal.testframework.matchers.TaskStateMatcher.taskStateWithStatus;
+import static org.awaitility.Awaitility.await;
+import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.greaterThanOrEqualTo;
+import static org.hamcrest.Matchers.hasLength;
+import static org.hamcrest.Matchers.lessThanOrEqualTo;
+
+import java.time.Instant;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.compute.ComputeJob;
+import org.apache.ignite.compute.JobDescriptor;
+import org.apache.ignite.compute.JobExecution;
+import org.apache.ignite.compute.JobExecutionContext;
+import org.apache.ignite.compute.JobTarget;
+import org.apache.ignite.compute.TaskDescriptor;
+import org.apache.ignite.compute.TaskStatus;
+import org.apache.ignite.compute.task.MapReduceJob;
+import org.apache.ignite.compute.task.MapReduceTask;
+import org.apache.ignite.compute.task.TaskExecution;
+import org.apache.ignite.compute.task.TaskExecutionContext;
+import org.apache.ignite.internal.hlc.ClockService;
+import org.apache.ignite.internal.sql.BaseSqlIntegrationTest;
+import org.apache.ignite.internal.sql.engine.util.MetadataMatcher;
+import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.apache.ignite.network.ClusterNode;
+import org.apache.ignite.sql.ColumnType;
+import org.hamcrest.Matchers;
+import org.jetbrains.annotations.Nullable;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+/**
+ * End-to-end tests to verify {@code COMPUTE_TASKS} system view.
+ */
+public class ItComputeSystemViewTest extends BaseSqlIntegrationTest {
+    @Override
+    protected int initialNodes() {
+        return 2;
+    }
+
+    @ParameterizedTest
+    @ValueSource(booleans = {true, false})
+    public void checkMeta(boolean isClient) {
+        String query = "SELECT * FROM COMPUTE_TASKS";
+
+        Ignite entryNode = isClient ? 
IgniteClient.builder().addresses("localhost").build() : CLUSTER.node(0);
+        Ignite targetNode = CLUSTER.node(0);
+
+        JobDescriptor<Void, Void> job = 
JobDescriptor.builder(InfiniteJob.class).units(List.of()).build();
+        JobExecution<Void> execution = 
entryNode.compute().submit(JobTarget.node(clusterNode(targetNode)), job, null);
+
+        await().until(execution::stateAsync, 
willBe(jobStateWithStatus(EXECUTING)));

Review Comment:
   I think we don't need to execute job just to check meta returned from 
cursor. I propose to simplify this test



##########
modules/compute/src/main/java/org/apache/ignite/internal/compute/ComputeViewProvider.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.compute;
+
+import static org.apache.ignite.internal.type.NativeTypes.stringOf;
+
+import java.util.List;
+import java.util.concurrent.Flow.Publisher;
+import java.util.concurrent.Flow.Subscriber;
+import org.apache.ignite.compute.JobState;
+import org.apache.ignite.internal.systemview.api.SystemView;
+import org.apache.ignite.internal.systemview.api.SystemViews;
+import org.apache.ignite.internal.type.NativeType;
+import org.apache.ignite.internal.type.NativeTypes;
+import org.apache.ignite.internal.util.SubscriptionUtils;
+import org.jetbrains.annotations.Nullable;
+
+/** Provider that creates system view exposes information about currently 
running compute tasks hosted by a node. */
+public class ComputeViewProvider {
+    private final DelegatingPublisher publisher = new DelegatingPublisher();
+
+    /** Initializes with compute aware manager. */
+    public void init(ExecutionManager executionManager) {
+        publisher.executionManager = executionManager;
+    }
+
+    public void stop() {
+        publisher.executionManager = null;
+    }
+
+    /** Returns system view exposes information about currently running tasks. 
*/
+    public SystemView<?> get() {
+        NativeType idType = stringOf(36);
+
+        NativeType timestampType = 
NativeTypes.timestamp(NativeTypes.MAX_TIME_PRECISION);
+
+        return SystemViews.<JobState>nodeViewBuilder()
+                .name("COMPUTE_TASKS")
+                .nodeNameColumnAlias("COORDINATOR_NODE_ID")
+                .addColumn("ID", idType, info -> info.id().toString())
+                .addColumn("STATUS", stringOf(10), info -> 
info.status().name())
+                .addColumn("CREATE_TIME", timestampType, JobState::createTime)
+                .addColumn("START_TIME", timestampType, JobState::startTime)
+                .addColumn("FINISH_TIME", timestampType, JobState::finishTime)

Review Comment:
   out guidelines (see `modules/system-view-api/README.md`) suggests to 
explicitly specify generic type of the column:
   
   ```
   Please note that we explicitly specify the generic type of the column. It is 
a good practice to detect the column type mismatch at compile time.
   ```



-- 
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-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to