You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2020/09/15 18:37:40 UTC

[GitHub] [ignite] ololo3000 opened a new pull request #8249: IGNITE-13426 Adds command to print system view content.

ololo3000 opened a new pull request #8249:
URL: https://github.com/apache/ignite/pull/8249


   Thank you for submitting the pull request to the Apache Ignite.
   
   In order to streamline the review of the contribution 
   we ask you to ensure the following steps have been taken:
   
   ### The Contribution Checklist
   - [ ] 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 pull request body describes changes that have been made. 
   The description explains _WHAT_ and _WHY_ was made instead of _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.
   - [ ] A reviewer has been mentioned through the JIRA comments 
   (see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers)) 
   - [ ] The pull request has been checked by the Teamcity Bot and 
   the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
   
   ### Notes
   - [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
   - [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
   - [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
   - [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
   
   If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
   


----------------------------------------------------------------
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.

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



[GitHub] [ignite] nizhikov commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r492599222



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTaskResult.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+
+/**
+ * Reperesents result of {@link VisorSystemViewTask}.
+ */
+public class VisorSystemViewTaskResult extends IgniteDataTransferObject {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Attribute values for each row of the system view. */
+    private List<List<?>> rows;
+
+    /** Names of the system view attributes. */
+    private List<String> attrs;
+
+    /** Types of the systen view attributes. */
+    List<SimpleAttributeType> types;
+
+    /**
+     * Default constructor.
+     */
+    public VisorSystemViewTaskResult() {
+        // No-op.
+    }
+
+    /**
+     * @param attrs Names of system view attributes.
+     * @param rows Attribute values for each row of the system view.
+     */
+    public VisorSystemViewTaskResult(List<String> attrs, List<SimpleAttributeType> types, List<List<?>> rows) {
+        this.attrs = attrs;
+        this.types = types;
+        this.rows = rows;
+    }
+
+    /**
+     * @return Names of the system view attributes.
+     */
+    public List<String> systemViewAttributes() {

Review comment:
       Let's make method naming consistent with the variables names.
   
   attrs -> attributes
   rows -> rows
   types -> types




----------------------------------------------------------------
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.

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



[GitHub] [ignite] xtern commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r490243355



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTask.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.managers.systemview.GridSystemViewManager;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.processors.task.GridVisorManagementTask;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker.AttributeWithValueVisitor;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.toSqlName;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Reperesents visor task for obtaining system view content.
+ */
+@GridInternal
+@GridVisorManagementTask
+public class VisorSystemViewTask extends VisorOneNodeTask<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> job(VisorSystemViewTaskArg arg) {
+        return new VisorSystemViewJob(arg, false);
+    }
+
+    /**
+     *
+     */
+    private static class VisorSystemViewJob extends VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * Create job with specified argument.
+         *
+         * @param arg Job argument.
+         * @param debug Flag indicating whether debug information should be printed into node log.
+         */
+        protected VisorSystemViewJob(@Nullable VisorSystemViewTaskArg arg, boolean debug) {
+            super(arg, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected VisorSystemViewTaskResult run(@Nullable VisorSystemViewTaskArg arg) throws IgniteException {
+            GridSystemViewManager sysViewMgr = ignite.context().systemView();
+
+            String targetSysViewName = arg.systemViewName();
+
+            SystemView<?> targetSysView = sysViewMgr.view(targetSysViewName);
+
+            if (targetSysView == null) { // In this case we assume that the requested system view name is in SQL format.
+                for (SystemView<?> sysView : sysViewMgr) {
+                    if (toSqlName(sysView.name()).equals(targetSysViewName)) {
+                        targetSysView = sysView;
+
+                        break;
+                    }
+                }
+            }
+
+            if (targetSysView == null)
+                return null;

Review comment:
       I advise you to separate the logic for finding a view into a separate method.
   In this case, code here will look something like 
   ```
   SystemView<?> targetSysView = findSysView(arg.systemViewName());
   
               if (targetSysView == null)
                   return null;
   ```
   
   `findSysView` may look something like
   
   ```
   private SystemView<?> findSysView(String name) {
               GridSystemViewManager sysViewMgr = ignite.context().systemView();
   
               SystemView<?> targetSysView = sysViewMgr.view(name);
   
               if (targetSysView != null)
                   return targetSysView;
   
               // comment about sql...
               for (SystemView<?> sysView : sysViewMgr) {
                   if (toSqlName(sysView.name()).equals(name))
                       return sysView;
               }
   
               return null;
           }
   ```




----------------------------------------------------------------
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.

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



[GitHub] [ignite] nizhikov commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r492601274



##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+        List<List<?>> sysViewRows = taskRes.systemViewContent();
+
+        List<Integer> colLenghts = colTitles.stream().map(String::length).collect(Collectors.toList());
+
+        List<List<String>> rows = new ArrayList<>(sysViewRows.size());
+
+        sysViewRows.forEach(sysViewRow -> {
+            ListIterator<Integer> colLenIter = colLenghts.listIterator();
+
+            rows.add(sysViewRow.stream().map(attr -> {
+                String colVal = String.valueOf(attr);

Review comment:
       Let's rename this to `val`




----------------------------------------------------------------
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.

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



[GitHub] [ignite] nizhikov commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r492600689



##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();

Review comment:
       Let's rename this to `titles`




----------------------------------------------------------------
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.

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



[GitHub] [ignite] xtern commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r490237214



##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,223 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+
+        List<? extends List<?>> sysViewRows = taskRes.systemViewContent();

Review comment:
       ? extends List<?> can be replaced with List<?>

##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,223 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+
+        List<? extends List<?>> sysViewRows = taskRes.systemViewContent();

Review comment:
       `? extends List<?>` can be replaced with List<?>

##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,223 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+
+        List<? extends List<?>> sysViewRows = taskRes.systemViewContent();

Review comment:
       `? extends List<?>` can be replaced with `List<?>`




----------------------------------------------------------------
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.

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



[GitHub] [ignite] nizhikov commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r492590310



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTaskResult.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+
+/**
+ * Reperesents result of {@link VisorSystemViewTask}.
+ */
+public class VisorSystemViewTaskResult extends IgniteDataTransferObject {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Attribute values for each row of the system view. */
+    private List<List<?>> rows;
+
+    /** Names of the system view attributes. */
+    private List<String> attrs;
+
+    /** Types of the systen view attributes. */
+    List<SimpleAttributeType> types;
+
+    /**
+     * Default constructor.
+     */
+    public VisorSystemViewTaskResult() {
+        // No-op.
+    }
+
+    /**
+     * @param attrs Names of system view attributes.
+     * @param rows Attribute values for each row of the system view.
+     */
+    public VisorSystemViewTaskResult(List<String> attrs, List<SimpleAttributeType> types, List<List<?>> rows) {
+        this.attrs = attrs;
+        this.types = types;
+        this.rows = rows;
+    }
+
+    /**
+     * @return Names of the system view attributes.

Review comment:
       Let's make this and similar comment one liner.

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTaskResult.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+
+/**
+ * Reperesents result of {@link VisorSystemViewTask}.
+ */
+public class VisorSystemViewTaskResult extends IgniteDataTransferObject {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Attribute values for each row of the system view. */
+    private List<List<?>> rows;
+
+    /** Names of the system view attributes. */
+    private List<String> attrs;
+
+    /** Types of the systen view attributes. */
+    List<SimpleAttributeType> types;
+
+    /**
+     * Default constructor.
+     */
+    public VisorSystemViewTaskResult() {
+        // No-op.
+    }
+
+    /**
+     * @param attrs Names of system view attributes.
+     * @param rows Attribute values for each row of the system view.
+     */
+    public VisorSystemViewTaskResult(List<String> attrs, List<SimpleAttributeType> types, List<List<?>> rows) {
+        this.attrs = attrs;
+        this.types = types;
+        this.rows = rows;
+    }
+
+    /**
+     * @return Names of the system view attributes.
+     */
+    public List<String> systemViewAttributes() {
+        return attrs;
+    }
+
+    /**
+     * @return Attribute values for each row of the system view.
+     */
+    public List<List<?>> systemViewContent() {
+        return rows;
+    }
+
+    /**
+     * @return Types of the system view attributes.
+     */
+    public List<SimpleAttributeType> systemViewAttributeTypes() {
+        return types;
+    }
+
+    /**
+     * {@inheritDoc}

Review comment:
       Please, make it one line comment.




----------------------------------------------------------------
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.

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



[GitHub] [ignite] nizhikov commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r492600805



##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+        List<List<?>> sysViewRows = taskRes.systemViewContent();

Review comment:
       Let's rename this to `rows`




----------------------------------------------------------------
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.

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



[GitHub] [ignite] xtern commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r490257712



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTaskResult.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+
+/**
+ * Reperesents result of {@link VisorSystemViewTask}.
+ */
+public class VisorSystemViewTaskResult extends IgniteDataTransferObject {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Attribute values for each row of the system view. */
+    private List<? extends List<?>> rows;

Review comment:
       `List<? extends List<?>>` can be replaced with `List<List<?>>`




----------------------------------------------------------------
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.

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



[GitHub] [ignite] xtern commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r490245829



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTask.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.managers.systemview.GridSystemViewManager;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.processors.task.GridVisorManagementTask;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker.AttributeWithValueVisitor;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.toSqlName;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Reperesents visor task for obtaining system view content.
+ */
+@GridInternal
+@GridVisorManagementTask
+public class VisorSystemViewTask extends VisorOneNodeTask<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> job(VisorSystemViewTaskArg arg) {
+        return new VisorSystemViewJob(arg, false);
+    }
+
+    /**
+     *
+     */
+    private static class VisorSystemViewJob extends VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * Create job with specified argument.
+         *
+         * @param arg Job argument.
+         * @param debug Flag indicating whether debug information should be printed into node log.
+         */
+        protected VisorSystemViewJob(@Nullable VisorSystemViewTaskArg arg, boolean debug) {
+            super(arg, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected VisorSystemViewTaskResult run(@Nullable VisorSystemViewTaskArg arg) throws IgniteException {
+            GridSystemViewManager sysViewMgr = ignite.context().systemView();
+
+            String targetSysViewName = arg.systemViewName();
+
+            SystemView<?> targetSysView = sysViewMgr.view(targetSysViewName);
+
+            if (targetSysView == null) { // In this case we assume that the requested system view name is in SQL format.
+                for (SystemView<?> sysView : sysViewMgr) {
+                    if (toSqlName(sysView.name()).equals(targetSysViewName)) {
+                        targetSysView = sysView;
+
+                        break;
+                    }
+                }
+            }
+
+            if (targetSysView == null)
+                return null;
+
+            List<String> attrNames = new ArrayList<>();
+

Review comment:
       I suggest removing this newline




----------------------------------------------------------------
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.

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



[GitHub] [ignite] xtern commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r490240771



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTask.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;

Review comment:
       Unused import




----------------------------------------------------------------
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.

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



[GitHub] [ignite] ololo3000 commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
ololo3000 commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r490272545



##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,223 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+

Review comment:
       Done.

##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,223 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+
+        List<? extends List<?>> sysViewRows = taskRes.systemViewContent();

Review comment:
       Done.

##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,223 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+
+        List<? extends List<?>> sysViewRows = taskRes.systemViewContent();
+
+        List<Integer> colLenghts = colTitles.stream().map(String::length).collect(Collectors.toList());
+
+        List<List<String>> rows = new ArrayList<>(sysViewRows.size());
+
+        sysViewRows.forEach(sysViewRow -> {
+            ListIterator<Integer> colLenIter = colLenghts.listIterator();
+
+            rows.add(sysViewRow.stream().map(attr -> {
+                String colVal = String.valueOf(attr);
+
+                colLenIter.set(Math.max(colLenIter.next(), colVal.length()));
+
+                return colVal;
+            }).collect(Collectors.toList()));
+        });
+
+        printRow(colTitles, nCopies(colTitles.size(), STRING), colLenghts, log);
+
+        rows.forEach(row -> printRow(row, taskRes.systemViewAttributeTypes(), colLenghts, log));
+    }
+
+    /**
+     * Prints row content with respect to column types and lengths.
+     *
+     * @param row Row which content should be printed.
+     * @param types Column types in sequential order for decent row formatting.
+     * @param lengths Column lengths in sequential order for decent row formatting.
+     * @param log Logger.
+     */
+    private void printRow(
+        Collection<String> row,
+        Collection<SimpleAttributeType> types,
+        Collection<Integer> lengths,
+        Logger log
+    ) {
+        Iterator<SimpleAttributeType> typeIter = types.iterator();
+

Review comment:
       Done.

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTask.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;

Review comment:
       Done.

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTask.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.managers.systemview.GridSystemViewManager;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.processors.task.GridVisorManagementTask;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker.AttributeWithValueVisitor;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.toSqlName;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Reperesents visor task for obtaining system view content.
+ */
+@GridInternal
+@GridVisorManagementTask
+public class VisorSystemViewTask extends VisorOneNodeTask<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> job(VisorSystemViewTaskArg arg) {
+        return new VisorSystemViewJob(arg, false);
+    }
+
+    /**
+     *
+     */
+    private static class VisorSystemViewJob extends VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * Create job with specified argument.
+         *
+         * @param arg Job argument.
+         * @param debug Flag indicating whether debug information should be printed into node log.
+         */
+        protected VisorSystemViewJob(@Nullable VisorSystemViewTaskArg arg, boolean debug) {
+            super(arg, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected VisorSystemViewTaskResult run(@Nullable VisorSystemViewTaskArg arg) throws IgniteException {
+            GridSystemViewManager sysViewMgr = ignite.context().systemView();
+
+            String targetSysViewName = arg.systemViewName();
+
+            SystemView<?> targetSysView = sysViewMgr.view(targetSysViewName);
+
+            if (targetSysView == null) { // In this case we assume that the requested system view name is in SQL format.
+                for (SystemView<?> sysView : sysViewMgr) {
+                    if (toSqlName(sysView.name()).equals(targetSysViewName)) {
+                        targetSysView = sysView;
+
+                        break;
+                    }
+                }
+            }
+
+            if (targetSysView == null)
+                return null;

Review comment:
       Done.

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTask.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.managers.systemview.GridSystemViewManager;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.processors.task.GridVisorManagementTask;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker.AttributeWithValueVisitor;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.toSqlName;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Reperesents visor task for obtaining system view content.
+ */
+@GridInternal
+@GridVisorManagementTask
+public class VisorSystemViewTask extends VisorOneNodeTask<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> job(VisorSystemViewTaskArg arg) {
+        return new VisorSystemViewJob(arg, false);
+    }
+
+    /**
+     *
+     */
+    private static class VisorSystemViewJob extends VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * Create job with specified argument.
+         *
+         * @param arg Job argument.
+         * @param debug Flag indicating whether debug information should be printed into node log.
+         */
+        protected VisorSystemViewJob(@Nullable VisorSystemViewTaskArg arg, boolean debug) {
+            super(arg, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected VisorSystemViewTaskResult run(@Nullable VisorSystemViewTaskArg arg) throws IgniteException {
+            GridSystemViewManager sysViewMgr = ignite.context().systemView();
+
+            String targetSysViewName = arg.systemViewName();
+
+            SystemView<?> targetSysView = sysViewMgr.view(targetSysViewName);
+
+            if (targetSysView == null) { // In this case we assume that the requested system view name is in SQL format.
+                for (SystemView<?> sysView : sysViewMgr) {
+                    if (toSqlName(sysView.name()).equals(targetSysViewName)) {
+                        targetSysView = sysView;
+
+                        break;
+                    }
+                }
+            }
+
+            if (targetSysView == null)
+                return null;
+
+            List<String> attrNames = new ArrayList<>();
+

Review comment:
       Done.

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTaskResult.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+
+/**
+ * Reperesents result of {@link VisorSystemViewTask}.
+ */
+public class VisorSystemViewTaskResult extends IgniteDataTransferObject {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Attribute values for each row of the system view. */
+    private List<? extends List<?>> rows;

Review comment:
       Done.




----------------------------------------------------------------
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.

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



[GitHub] [ignite] xtern commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r490243355



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTask.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.managers.systemview.GridSystemViewManager;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.processors.task.GridVisorManagementTask;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker.AttributeWithValueVisitor;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.toSqlName;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Reperesents visor task for obtaining system view content.
+ */
+@GridInternal
+@GridVisorManagementTask
+public class VisorSystemViewTask extends VisorOneNodeTask<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> job(VisorSystemViewTaskArg arg) {
+        return new VisorSystemViewJob(arg, false);
+    }
+
+    /**
+     *
+     */
+    private static class VisorSystemViewJob extends VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * Create job with specified argument.
+         *
+         * @param arg Job argument.
+         * @param debug Flag indicating whether debug information should be printed into node log.
+         */
+        protected VisorSystemViewJob(@Nullable VisorSystemViewTaskArg arg, boolean debug) {
+            super(arg, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected VisorSystemViewTaskResult run(@Nullable VisorSystemViewTaskArg arg) throws IgniteException {
+            GridSystemViewManager sysViewMgr = ignite.context().systemView();
+
+            String targetSysViewName = arg.systemViewName();
+
+            SystemView<?> targetSysView = sysViewMgr.view(targetSysViewName);
+
+            if (targetSysView == null) { // In this case we assume that the requested system view name is in SQL format.
+                for (SystemView<?> sysView : sysViewMgr) {
+                    if (toSqlName(sysView.name()).equals(targetSysViewName)) {
+                        targetSysView = sysView;
+
+                        break;
+                    }
+                }
+            }
+
+            if (targetSysView == null)
+                return null;

Review comment:
       I advise you to separate the logic for finding a view into a separate method.
   In this case, code here will look something like 
   ```
   SystemView<?> targetSysView = findSysView(arg.systemViewName());
   
               if (targetSysView == null)
                   return null;
   ```
   
   `findSysView` may look something like
   
   ```
   private SystemView<?> findSysView(String name) {
               GridSystemViewManager sysViewMgr = ignite.context().systemView();
   
               SystemView<?> targetSysView = sysViewMgr.view(name);
   
               if (targetSysView != null)
                   return targetSysView;
   
               // In this case we assume that the requested system view name is in SQL format.
               for (SystemView<?> sysView : sysViewMgr) {
                   if (toSqlName(sysView.name()).equals(name))
                       return sysView;
               }
   
               return null;
           }
   ```




----------------------------------------------------------------
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.

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



[GitHub] [ignite] nizhikov merged pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
nizhikov merged pull request #8249:
URL: https://github.com/apache/ignite/pull/8249


   


----------------------------------------------------------------
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.

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



[GitHub] [ignite] nizhikov commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r492589817



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTaskResult.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+
+/**
+ * Reperesents result of {@link VisorSystemViewTask}.
+ */
+public class VisorSystemViewTaskResult extends IgniteDataTransferObject {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Attribute values for each row of the system view. */
+    private List<List<?>> rows;
+
+    /** Names of the system view attributes. */
+    private List<String> attrs;
+
+    /** Types of the systen view attributes. */
+    List<SimpleAttributeType> types;
+
+    /**
+     * Default constructor.
+     */
+    public VisorSystemViewTaskResult() {
+        // No-op.
+    }
+
+    /**
+     * @param attrs Names of system view attributes.
+     * @param rows Attribute values for each row of the system view.

Review comment:
       nit: @param types missed in javadoc.




----------------------------------------------------------------
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.

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



[GitHub] [ignite] xtern commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r490243355



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTask.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.managers.systemview.GridSystemViewManager;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.processors.task.GridVisorManagementTask;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker.AttributeWithValueVisitor;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.toSqlName;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Reperesents visor task for obtaining system view content.
+ */
+@GridInternal
+@GridVisorManagementTask
+public class VisorSystemViewTask extends VisorOneNodeTask<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> job(VisorSystemViewTaskArg arg) {
+        return new VisorSystemViewJob(arg, false);
+    }
+
+    /**
+     *
+     */
+    private static class VisorSystemViewJob extends VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * Create job with specified argument.
+         *
+         * @param arg Job argument.
+         * @param debug Flag indicating whether debug information should be printed into node log.
+         */
+        protected VisorSystemViewJob(@Nullable VisorSystemViewTaskArg arg, boolean debug) {
+            super(arg, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected VisorSystemViewTaskResult run(@Nullable VisorSystemViewTaskArg arg) throws IgniteException {
+            GridSystemViewManager sysViewMgr = ignite.context().systemView();
+
+            String targetSysViewName = arg.systemViewName();
+
+            SystemView<?> targetSysView = sysViewMgr.view(targetSysViewName);
+
+            if (targetSysView == null) { // In this case we assume that the requested system view name is in SQL format.
+                for (SystemView<?> sysView : sysViewMgr) {
+                    if (toSqlName(sysView.name()).equals(targetSysViewName)) {
+                        targetSysView = sysView;
+
+                        break;
+                    }
+                }
+            }
+
+            if (targetSysView == null)
+                return null;

Review comment:
       Seems that it is better to put this code into a separate method.
   
   In this case, code here will look something like 
   ```
   SystemView<?> targetSysView = findSysView(arg.systemViewName());
   
               if (targetSysView == null)
                   return null;
   ```
   
   `findSysView` may look something like
   
   ```
   private SystemView<?> findSysView(String name) {
               GridSystemViewManager sysViewMgr = ignite.context().systemView();
   
               SystemView<?> targetSysView = sysViewMgr.view(name);
   
               if (targetSysView != null)
                   return targetSysView;
   
               // In this case we assume that the requested system view name is in SQL format.
               for (SystemView<?> sysView : sysViewMgr) {
                   if (toSqlName(sysView.name()).equals(name))
                       return sysView;
               }
   
               return null;
           }
   ```




----------------------------------------------------------------
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.

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



[GitHub] [ignite] nizhikov commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r492600805



##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+        List<List<?>> sysViewRows = taskRes.systemViewContent();

Review comment:
       Let's rename this to `viewRows`




----------------------------------------------------------------
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.

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



[GitHub] [ignite] nizhikov commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r492589817



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTaskResult.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+
+/**
+ * Reperesents result of {@link VisorSystemViewTask}.
+ */
+public class VisorSystemViewTaskResult extends IgniteDataTransferObject {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Attribute values for each row of the system view. */
+    private List<List<?>> rows;
+
+    /** Names of the system view attributes. */
+    private List<String> attrs;
+
+    /** Types of the systen view attributes. */
+    List<SimpleAttributeType> types;
+
+    /**
+     * Default constructor.
+     */
+    public VisorSystemViewTaskResult() {
+        // No-op.
+    }
+
+    /**
+     * @param attrs Names of system view attributes.
+     * @param rows Attribute values for each row of the system view.

Review comment:
       nit: @param types missed in javadoc.

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTaskResult.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+
+/**
+ * Reperesents result of {@link VisorSystemViewTask}.
+ */
+public class VisorSystemViewTaskResult extends IgniteDataTransferObject {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Attribute values for each row of the system view. */
+    private List<List<?>> rows;
+
+    /** Names of the system view attributes. */
+    private List<String> attrs;
+
+    /** Types of the systen view attributes. */
+    List<SimpleAttributeType> types;
+
+    /**
+     * Default constructor.
+     */
+    public VisorSystemViewTaskResult() {
+        // No-op.
+    }
+
+    /**
+     * @param attrs Names of system view attributes.
+     * @param rows Attribute values for each row of the system view.
+     */
+    public VisorSystemViewTaskResult(List<String> attrs, List<SimpleAttributeType> types, List<List<?>> rows) {
+        this.attrs = attrs;
+        this.types = types;
+        this.rows = rows;
+    }
+
+    /**
+     * @return Names of the system view attributes.

Review comment:
       Let's make this and similar comment one liner.

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTaskResult.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+
+/**
+ * Reperesents result of {@link VisorSystemViewTask}.
+ */
+public class VisorSystemViewTaskResult extends IgniteDataTransferObject {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Attribute values for each row of the system view. */
+    private List<List<?>> rows;
+
+    /** Names of the system view attributes. */
+    private List<String> attrs;
+
+    /** Types of the systen view attributes. */
+    List<SimpleAttributeType> types;
+
+    /**
+     * Default constructor.
+     */
+    public VisorSystemViewTaskResult() {
+        // No-op.
+    }
+
+    /**
+     * @param attrs Names of system view attributes.
+     * @param rows Attribute values for each row of the system view.
+     */
+    public VisorSystemViewTaskResult(List<String> attrs, List<SimpleAttributeType> types, List<List<?>> rows) {
+        this.attrs = attrs;
+        this.types = types;
+        this.rows = rows;
+    }
+
+    /**
+     * @return Names of the system view attributes.
+     */
+    public List<String> systemViewAttributes() {
+        return attrs;
+    }
+
+    /**
+     * @return Attribute values for each row of the system view.
+     */
+    public List<List<?>> systemViewContent() {
+        return rows;
+    }
+
+    /**
+     * @return Types of the system view attributes.
+     */
+    public List<SimpleAttributeType> systemViewAttributeTypes() {
+        return types;
+    }
+
+    /**
+     * {@inheritDoc}

Review comment:
       Please, make it one line comment.

##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTaskResult.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.ignite.internal.dto.IgniteDataTransferObject;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+
+/**
+ * Reperesents result of {@link VisorSystemViewTask}.
+ */
+public class VisorSystemViewTaskResult extends IgniteDataTransferObject {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** Attribute values for each row of the system view. */
+    private List<List<?>> rows;
+
+    /** Names of the system view attributes. */
+    private List<String> attrs;
+
+    /** Types of the systen view attributes. */
+    List<SimpleAttributeType> types;
+
+    /**
+     * Default constructor.
+     */
+    public VisorSystemViewTaskResult() {
+        // No-op.
+    }
+
+    /**
+     * @param attrs Names of system view attributes.
+     * @param rows Attribute values for each row of the system view.
+     */
+    public VisorSystemViewTaskResult(List<String> attrs, List<SimpleAttributeType> types, List<List<?>> rows) {
+        this.attrs = attrs;
+        this.types = types;
+        this.rows = rows;
+    }
+
+    /**
+     * @return Names of the system view attributes.
+     */
+    public List<String> systemViewAttributes() {

Review comment:
       Let's make method naming consistent with the variables names.
   
   attrs -> attributes
   rows -> rows
   types -> types

##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();

Review comment:
       Let's rename this to `titles`

##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+        List<List<?>> sysViewRows = taskRes.systemViewContent();

Review comment:
       Let's rename this to `rows`

##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+        List<List<?>> sysViewRows = taskRes.systemViewContent();
+
+        List<Integer> colLenghts = colTitles.stream().map(String::length).collect(Collectors.toList());

Review comment:
       Let's rename this to `colSzs`

##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+        List<List<?>> sysViewRows = taskRes.systemViewContent();
+
+        List<Integer> colLenghts = colTitles.stream().map(String::length).collect(Collectors.toList());
+
+        List<List<String>> rows = new ArrayList<>(sysViewRows.size());
+
+        sysViewRows.forEach(sysViewRow -> {
+            ListIterator<Integer> colLenIter = colLenghts.listIterator();
+
+            rows.add(sysViewRow.stream().map(attr -> {
+                String colVal = String.valueOf(attr);

Review comment:
       Let's rename this to `val`

##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+        List<List<?>> sysViewRows = taskRes.systemViewContent();

Review comment:
       Let's rename this to `viewRows`




----------------------------------------------------------------
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.

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



[GitHub] [ignite] xtern commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r490237898



##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,223 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+
+        List<? extends List<?>> sysViewRows = taskRes.systemViewContent();
+
+        List<Integer> colLenghts = colTitles.stream().map(String::length).collect(Collectors.toList());
+
+        List<List<String>> rows = new ArrayList<>(sysViewRows.size());
+
+        sysViewRows.forEach(sysViewRow -> {
+            ListIterator<Integer> colLenIter = colLenghts.listIterator();
+
+            rows.add(sysViewRow.stream().map(attr -> {
+                String colVal = String.valueOf(attr);
+
+                colLenIter.set(Math.max(colLenIter.next(), colVal.length()));
+
+                return colVal;
+            }).collect(Collectors.toList()));
+        });
+
+        printRow(colTitles, nCopies(colTitles.size(), STRING), colLenghts, log);
+
+        rows.forEach(row -> printRow(row, taskRes.systemViewAttributeTypes(), colLenghts, log));
+    }
+
+    /**
+     * Prints row content with respect to column types and lengths.
+     *
+     * @param row Row which content should be printed.
+     * @param types Column types in sequential order for decent row formatting.
+     * @param lengths Column lengths in sequential order for decent row formatting.
+     * @param log Logger.
+     */
+    private void printRow(
+        Collection<String> row,
+        Collection<SimpleAttributeType> types,
+        Collection<Integer> lengths,
+        Logger log
+    ) {
+        Iterator<SimpleAttributeType> typeIter = types.iterator();
+

Review comment:
       I suggest removing this newline




----------------------------------------------------------------
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.

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



[GitHub] [ignite] xtern commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r490238789



##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,223 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+
+        List<? extends List<?>> sysViewRows = taskRes.systemViewContent();
+
+        List<Integer> colLenghts = colTitles.stream().map(String::length).collect(Collectors.toList());
+
+        List<List<String>> rows = new ArrayList<>(sysViewRows.size());
+
+        sysViewRows.forEach(sysViewRow -> {
+            ListIterator<Integer> colLenIter = colLenghts.listIterator();
+
+            rows.add(sysViewRow.stream().map(attr -> {
+                String colVal = String.valueOf(attr);
+
+                colLenIter.set(Math.max(colLenIter.next(), colVal.length()));
+
+                return colVal;
+            }).collect(Collectors.toList()));
+        });
+
+        printRow(colTitles, nCopies(colTitles.size(), STRING), colLenghts, log);
+
+        rows.forEach(row -> printRow(row, taskRes.systemViewAttributeTypes(), colLenghts, log));
+    }
+
+    /**
+     * Prints row content with respect to column types and lengths.
+     *
+     * @param row Row which content should be printed.
+     * @param types Column types in sequential order for decent row formatting.
+     * @param lengths Column lengths in sequential order for decent row formatting.
+     * @param log Logger.
+     */
+    private void printRow(
+        Collection<String> row,
+        Collection<SimpleAttributeType> types,
+        Collection<Integer> lengths,
+        Logger log
+    ) {

Review comment:
       we can add an assertion here to ensure code reader that the sizes of collections are equal




----------------------------------------------------------------
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.

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



[GitHub] [ignite] xtern commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r490243355



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/visor/systemview/VisorSystemViewTask.java
##########
@@ -0,0 +1,190 @@
+/*
+ * 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.visor.systemview;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+import java.util.UUID;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.managers.systemview.GridSystemViewManager;
+import org.apache.ignite.internal.processors.task.GridInternal;
+import org.apache.ignite.internal.processors.task.GridVisorManagementTask;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.internal.visor.VisorJob;
+import org.apache.ignite.internal.visor.VisorOneNodeTask;
+import org.apache.ignite.lang.IgniteUuid;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker.AttributeWithValueVisitor;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.toSqlName;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Reperesents visor task for obtaining system view content.
+ */
+@GridInternal
+@GridVisorManagementTask
+public class VisorSystemViewTask extends VisorOneNodeTask<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+    /** */
+    private static final long serialVersionUID = 0L;
+
+    /** {@inheritDoc} */
+    @Override protected VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> job(VisorSystemViewTaskArg arg) {
+        return new VisorSystemViewJob(arg, false);
+    }
+
+    /**
+     *
+     */
+    private static class VisorSystemViewJob extends VisorJob<VisorSystemViewTaskArg, VisorSystemViewTaskResult> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /**
+         * Create job with specified argument.
+         *
+         * @param arg Job argument.
+         * @param debug Flag indicating whether debug information should be printed into node log.
+         */
+        protected VisorSystemViewJob(@Nullable VisorSystemViewTaskArg arg, boolean debug) {
+            super(arg, debug);
+        }
+
+        /** {@inheritDoc} */
+        @Override protected VisorSystemViewTaskResult run(@Nullable VisorSystemViewTaskArg arg) throws IgniteException {
+            GridSystemViewManager sysViewMgr = ignite.context().systemView();
+
+            String targetSysViewName = arg.systemViewName();
+
+            SystemView<?> targetSysView = sysViewMgr.view(targetSysViewName);
+
+            if (targetSysView == null) { // In this case we assume that the requested system view name is in SQL format.
+                for (SystemView<?> sysView : sysViewMgr) {
+                    if (toSqlName(sysView.name()).equals(targetSysViewName)) {
+                        targetSysView = sysView;
+
+                        break;
+                    }
+                }
+            }
+
+            if (targetSysView == null)
+                return null;

Review comment:
       Seems that it is better to put the view search logic into a separate method.
   
   In this case, code here will look something like 
   ```
   SystemView<?> targetSysView = findSysView(arg.systemViewName());
   
               if (targetSysView == null)
                   return null;
   ```
   
   `findSysView` may look something like
   
   ```
   private SystemView<?> findSysView(String name) {
               GridSystemViewManager sysViewMgr = ignite.context().systemView();
   
               SystemView<?> targetSysView = sysViewMgr.view(name);
   
               if (targetSysView != null)
                   return targetSysView;
   
               // In this case we assume that the requested system view name is in SQL format.
               for (SystemView<?> sysView : sysViewMgr) {
                   if (toSqlName(sysView.name()).equals(name))
                       return sysView;
               }
   
               return null;
           }
   ```




----------------------------------------------------------------
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.

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



[GitHub] [ignite] nizhikov commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
nizhikov commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r492601164



##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,221 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+        List<List<?>> sysViewRows = taskRes.systemViewContent();
+
+        List<Integer> colLenghts = colTitles.stream().map(String::length).collect(Collectors.toList());

Review comment:
       Let's rename this to `colSzs`




----------------------------------------------------------------
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.

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



[GitHub] [ignite] xtern commented on a change in pull request #8249: IGNITE-13426 Adds command to print system view content.

Posted by GitBox <gi...@apache.org>.
xtern commented on a change in pull request #8249:
URL: https://github.com/apache/ignite/pull/8249#discussion_r490236947



##########
File path: modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/systemview/SystemViewCommand.java
##########
@@ -0,0 +1,223 @@
+/*
+ * 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.commandline.systemview;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.apache.ignite.internal.client.GridClient;
+import org.apache.ignite.internal.client.GridClientConfiguration;
+import org.apache.ignite.internal.commandline.Command;
+import org.apache.ignite.internal.commandline.CommandArgIterator;
+import org.apache.ignite.internal.commandline.CommandLogger;
+import org.apache.ignite.internal.commandline.argument.CommandArgUtils;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskArg;
+import org.apache.ignite.internal.visor.systemview.VisorSystemViewTaskResult;
+import org.apache.ignite.spi.systemview.view.SystemView;
+
+import static java.util.Collections.nCopies;
+import static org.apache.ignite.internal.commandline.CommandList.SYSTEM_VIEW;
+import static org.apache.ignite.internal.commandline.CommandLogger.optional;
+import static org.apache.ignite.internal.commandline.TaskExecutor.executeTaskByNameOnNode;
+import static org.apache.ignite.internal.commandline.systemview.SystemViewCommandArg.NODE_ID;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.DATE;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.NUMBER;
+import static org.apache.ignite.internal.visor.systemview.VisorSystemViewTask.SimpleAttributeType.STRING;
+
+/**
+ * Represents command for {@link SystemView} content printing.
+ */
+public class SystemViewCommand implements Command<Object> {
+    /** Column separator. */
+    public static final String COLUMN_SEPARATOR = "    ";
+
+    /**
+     * Argument for the system view content obtainig task.
+     *
+     * @see VisorSystemViewTask
+     */
+    private VisorSystemViewTaskArg taskArg;
+
+    /** ID of the node to get the system view content from. */
+    private UUID nodeId;
+
+    /** {@inheritDoc} */
+    @Override public Object execute(GridClientConfiguration clientCfg, Logger log) throws Exception {
+        try {
+            VisorSystemViewTaskResult res;
+
+            try (GridClient client = Command.startClient(clientCfg)) {
+                res = executeTaskByNameOnNode(
+                    client,
+                    VisorSystemViewTask.class.getName(),
+                    taskArg,
+                    nodeId,
+                    clientCfg
+                );
+            }
+
+            if (res != null)
+                printSystemViewContent(res, log);
+            else
+                log.info("No system view with specified name was found [name=" + taskArg.systemViewName() + "]");
+
+            return res;
+        }
+        catch (Throwable e) {
+            log.severe("Failed to perform operation.");
+            log.severe(CommandLogger.errorMessage(e));
+
+            throw e;
+        }
+    }
+
+    /**
+     * Prints system view content obtained via {@link VisorSystemViewTask} execution.
+     *
+     * @param taskRes Result of {@link VisorSystemViewTask} execution.
+     * @param log Logger.
+     */
+    private void printSystemViewContent(VisorSystemViewTaskResult taskRes, Logger log) {
+        List<String> colTitles = taskRes.systemViewAttributes();
+

Review comment:
       I suggest removing this newline




----------------------------------------------------------------
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.

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