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 2023/01/12 05:39:28 UTC

[GitHub] [ignite] nizhikov opened a new pull request, #10478: IGNITE-18533 Management API to kill client connection

nizhikov opened a new pull request, #10478:
URL: https://github.com/apache/ignite/pull/10478

   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.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

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


[GitHub] [ignite] nizhikov merged pull request #10478: IGNITE-18533 Management API to kill client connection

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

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


[GitHub] [ignite] timoninmaxim commented on a diff in pull request #10478: IGNITE-18533 Management API to kill client connection

Posted by GitBox <gi...@apache.org>.
timoninmaxim commented on code in PR #10478:
URL: https://github.com/apache/ignite/pull/10478#discussion_r1069040421


##########
modules/control-utility/src/main/java/org/apache/ignite/internal/commandline/query/KillCommand.java:
##########
@@ -212,6 +215,24 @@ public class KillCommand extends AbstractCommand<Object> {
 
                 break;
 
+            case CLIENT:
+                taskName = VisorClientConnectionDropTask.class.getName();
+
+                for (int i = 0; i < 2; i++) {

Review Comment:
   Should it be replaced with while loop over `argIter` iterator?



##########
modules/indexing/src/test/java/org/apache/ignite/util/KillCommandsTests.java:
##########
@@ -472,6 +479,40 @@ public static void doTestCancelContinuousQuery(IgniteEx cli, List<IgniteEx> srvs
         }
     }
 
+    /**
+     * Test cancel of the continuous query.

Review Comment:
   Wrong javadoc - there is no continuous query in the test



##########
modules/indexing/src/test/java/org/apache/ignite/util/KillCommandsTests.java:
##########
@@ -472,6 +479,40 @@ public static void doTestCancelContinuousQuery(IgniteEx cli, List<IgniteEx> srvs
         }
     }
 
+    /**
+     * Test cancel of the continuous query.
+     *
+     * @param srvs Server nodes.
+     * @param cliCanceler Client connection cancel closure.
+     */
+    public static void doTestCancelClientConnection(List<IgniteEx> srvs, Consumer<Long> cliCanceler) {
+        AtomicReference<IgniteClient> cli = new AtomicReference<>(
+            Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER))
+        );
+
+        assertEquals(ClusterState.ACTIVE, cli.get().cluster().state());
+
+        List<List<?>> conns = execute(srvs.get(0), "SELECT CONNECTION_ID FROM SYS.CLIENT_CONNECTIONS");
+
+        assertEquals(1, conns.size());

Review Comment:
   Let's create more connections to test that it's killed the specified connection only. Also KILL ALL should be tested with multiple connections.



##########
docs/_docs/sql-reference/operational-commands.adoc:
##########
@@ -397,3 +397,30 @@ control.bat --kill CONSISTENCY
 ----
 
 --
+== KILL CLIENT operations
+
+The `KILL CLIENT` command allows you to cancel local client (thin/jdbc/odbc) connection.
+
+[tabs]
+--
+
+tab:Unix[]
+[source,bash]
+----
+./control.sh --kill CLIENT connection_id [--node-id node_id]
+----
+
+tab:Windows[]
+[source,bash]
+----
+control.bat --kill CLIENT connection_id [--node-id node_id]
+----
+
+--
+
+=== Parameters
+
+* `connection_id` - corresponds to the connection id of the client. Note, connection_id are local value.

Review Comment:
   should doc that if connection id isn't specified then all connections drops



##########
modules/control-utility/src/test/java/org/apache/ignite/util/KillCommandsControlShTest.java:
##########
@@ -153,6 +154,18 @@ public void testCancelContinuousQuery() throws Exception {
         });
     }
 
+    /** @throws Exception If failed. */
+    @Test
+    public void testCancelClientConnection() {
+        doTestCancelClientConnection(srvs, connId -> {
+            String nodeId = srvs.get(0).localNode().id().toString();
+
+            int res = execute("--kill", "client", "--node-id", nodeId, connId == null ? "ALL" : Long.toString(connId));

Review Comment:
   Should command failed if connection wasn't dropped, in case of error or wrong/non-existent connection id?
   
   Let's add test for specific node id also



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

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


[GitHub] [ignite] nizhikov commented on a diff in pull request #10478: IGNITE-18533 Management API to kill client connection

Posted by GitBox <gi...@apache.org>.
nizhikov commented on code in PR #10478:
URL: https://github.com/apache/ignite/pull/10478#discussion_r1069152269


##########
modules/control-utility/src/test/java/org/apache/ignite/util/KillCommandsControlShTest.java:
##########
@@ -153,6 +154,18 @@ public void testCancelContinuousQuery() throws Exception {
         });
     }
 
+    /** @throws Exception If failed. */
+    @Test
+    public void testCancelClientConnection() {
+        doTestCancelClientConnection(srvs, connId -> {
+            String nodeId = srvs.get(0).localNode().id().toString();
+
+            int res = execute("--kill", "client", "--node-id", nodeId, connId == null ? "ALL" : Long.toString(connId));

Review Comment:
   > Should command failed if connection wasn't dropped
   
   Yes. Fixed.
   
   > Let's add test for specific node id also
   
   Added.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

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


[GitHub] [ignite] nizhikov commented on a diff in pull request #10478: IGNITE-18533 Management API to kill client connection

Posted by GitBox <gi...@apache.org>.
nizhikov commented on code in PR #10478:
URL: https://github.com/apache/ignite/pull/10478#discussion_r1069153360


##########
docs/_docs/sql-reference/operational-commands.adoc:
##########
@@ -397,3 +397,30 @@ control.bat --kill CONSISTENCY
 ----
 
 --
+== KILL CLIENT operations
+
+The `KILL CLIENT` command allows you to cancel local client (thin/jdbc/odbc) connection.
+
+[tabs]
+--
+
+tab:Unix[]
+[source,bash]
+----
+./control.sh --kill CLIENT connection_id [--node-id node_id]
+----
+
+tab:Windows[]
+[source,bash]
+----
+control.bat --kill CLIENT connection_id [--node-id node_id]
+----
+
+--
+
+=== Parameters
+
+* `connection_id` - corresponds to the connection id of the client. Note, connection_id are local value.

Review Comment:
   Yes. Fixed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

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


[GitHub] [ignite] nizhikov commented on a diff in pull request #10478: IGNITE-18533 Management API to kill client connection

Posted by GitBox <gi...@apache.org>.
nizhikov commented on code in PR #10478:
URL: https://github.com/apache/ignite/pull/10478#discussion_r1069196091


##########
modules/indexing/src/test/java/org/apache/ignite/util/KillCommandsTests.java:
##########
@@ -472,6 +479,40 @@ public static void doTestCancelContinuousQuery(IgniteEx cli, List<IgniteEx> srvs
         }
     }
 
+    /**
+     * Test cancel of the continuous query.
+     *
+     * @param srvs Server nodes.
+     * @param cliCanceler Client connection cancel closure.
+     */
+    public static void doTestCancelClientConnection(List<IgniteEx> srvs, Consumer<Long> cliCanceler) {
+        AtomicReference<IgniteClient> cli = new AtomicReference<>(
+            Ignition.startClient(new ClientConfiguration().setAddresses(Config.SERVER))
+        );
+
+        assertEquals(ClusterState.ACTIVE, cli.get().cluster().state());
+
+        List<List<?>> conns = execute(srvs.get(0), "SELECT CONNECTION_ID FROM SYS.CLIENT_CONNECTIONS");
+
+        assertEquals(1, conns.size());

Review Comment:
   Tests added.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

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


[GitHub] [ignite] timoninmaxim commented on a diff in pull request #10478: IGNITE-18533 Management API to kill client connection

Posted by GitBox <gi...@apache.org>.
timoninmaxim commented on code in PR #10478:
URL: https://github.com/apache/ignite/pull/10478#discussion_r1069243003


##########
modules/core/src/main/java/org/apache/ignite/internal/sql/command/SqlKillClientCommand.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.sql.command;
+
+import org.apache.ignite.internal.sql.SqlLexer;
+import org.apache.ignite.internal.sql.SqlLexerTokenType;
+import org.apache.ignite.internal.sql.SqlParserUtils;
+import org.apache.ignite.spi.systemview.view.ClientConnectionView;
+
+/**
+ * KILL CLIENT command.
+ *
+ * @see org.apache.ignite.internal.visor.client.VisorClientConnectionDropTask
+ * @see ClientConnectionView#connectionId()
+ */
+public class SqlKillClientCommand implements SqlCommand {
+    /** Connections id. */
+    private Long connectionId;
+
+    /** {@inheritDoc} */
+    @Override public SqlCommand parse(SqlLexer lex) {
+        if (lex.shift()) {
+            if (lex.tokenType() == SqlLexerTokenType.DEFAULT) {
+                String connIdStr = lex.token();
+
+                if (!connIdStr.equals("ALL"))

Review Comment:
   it's better to switch arguments - "ALL".equals(connIdStr).



##########
docs/_docs/sql-reference/operational-commands.adoc:
##########
@@ -397,3 +397,30 @@ control.bat --kill CONSISTENCY
 ----
 
 --
+== KILL CLIENT operations
+
+The `KILL CLIENT` command allows you to cancel local client (thin/jdbc/odbc) connection.
+
+[tabs]
+--
+
+tab:Unix[]
+[source,bash]
+----
+./control.sh --kill CLIENT connection_id [--node-id node_id]
+----
+
+tab:Windows[]
+[source,bash]
+----
+control.bat --kill CLIENT connection_id [--node-id node_id]
+----
+
+--
+
+=== Parameters
+
+* `connection_id` - corresponds to the connection id of the client. Specify ALL to droll all connections. Note, connection_id are local value.

Review Comment:
   s/droll/drop/



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

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