cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject cassandra git commit: Add ability to specify driver name and version
Date Mon, 19 Mar 2018 12:26:18 GMT
Repository: cassandra
Updated Branches:
  refs/heads/14275-4.0 [created] 5dc55e715


Add ability to specify driver name and version

patch by Dinesh Joshi; reviewed by Aleksey Yeschenko for CASSANDRA-14275


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/5dc55e71
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/5dc55e71
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/5dc55e71

Branch: refs/heads/14275-4.0
Commit: 5dc55e715eba6667c388da9f8f1eb7a46489b35c
Parents: 9714a7c
Author: Dinesh Joshi <dinesh.joshi@yahoo.com>
Authored: Mon Feb 26 16:59:23 2018 -0800
Committer: Aleksey Yeshchenko <aleksey@apple.com>
Committed: Mon Mar 19 12:25:41 2018 +0000

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/service/ClientState.java   | 27 ++++++++++++++++++++
 .../cassandra/tools/nodetool/ClientStats.java   |  4 +--
 .../org/apache/cassandra/transport/Server.java  |  2 ++
 .../transport/messages/StartupMessage.java      | 11 ++++++++
 5 files changed, 43 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5dc55e71/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9458f19..9436539 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0
+ * Add ability to specify driver name and version (CASSANDRA-14275)
  * Abstract streaming for pluggable storage (CASSANDRA-14115)
  * Forced incremental repairs should promote sstables if they can (CASSANDRA-14294)
  * Use Murmur3 for validation compactions (CASSANDRA-14002)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5dc55e71/src/java/org/apache/cassandra/service/ClientState.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/ClientState.java b/src/java/org/apache/cassandra/service/ClientState.java
index 97b6172..3e2be80 100644
--- a/src/java/org/apache/cassandra/service/ClientState.java
+++ b/src/java/org/apache/cassandra/service/ClientState.java
@@ -21,6 +21,7 @@ import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -106,6 +107,10 @@ public class ClientState
     // The remote address of the client - null for internal clients.
     private final InetSocketAddress remoteAddress;
 
+    // Driver String for the client
+    private volatile String driverName;
+    private volatile String driverVersion;
+
     // The biggest timestamp that was returned by getTimestamp/assigned to a query. This
is global to ensure that the
     // timestamp assigned are strictly monotonic on a node, which is likely what user expect
intuitively (more likely,
     // most new user will intuitively expect timestamp to be strictly monotonic cluster-wise,
but while that last part
@@ -135,6 +140,8 @@ public class ClientState
         this.remoteAddress = source.remoteAddress;
         this.user = source.user;
         this.keyspace = source.keyspace;
+        this.driverName = source.driverName;
+        this.driverVersion = source.driverVersion;
     }
 
     /**
@@ -243,6 +250,26 @@ public class ClientState
         }
     }
 
+    public Optional<String> getDriverName()
+    {
+        return Optional.ofNullable(driverName);
+    }
+
+    public Optional<String> getDriverVersion()
+    {
+        return Optional.ofNullable(driverVersion);
+    }
+
+    public void setDriverName(String driverName)
+    {
+        this.driverName = driverName;
+    }
+
+    public void setDriverVersion(String driverVersion)
+    {
+        this.driverVersion = driverVersion;
+    }
+
     public static QueryHandler getCQLQueryHandler()
     {
         return cqlQueryHandler;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5dc55e71/src/java/org/apache/cassandra/tools/nodetool/ClientStats.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/nodetool/ClientStats.java b/src/java/org/apache/cassandra/tools/nodetool/ClientStats.java
index 21915cb..4529c86 100644
--- a/src/java/org/apache/cassandra/tools/nodetool/ClientStats.java
+++ b/src/java/org/apache/cassandra/tools/nodetool/ClientStats.java
@@ -43,11 +43,11 @@ public class ClientStats extends NodeToolCmd
             if (!clients.isEmpty())
             {
                 TableBuilder table = new TableBuilder();
-                table.add("Address", "SSL", "Version", "User", "Keyspace", "Requests");
+                table.add("Address", "SSL", "Version", "User", "Keyspace", "Requests", "Driver-Name",
"Driver-Version");
                 for (Map<String, String> conn : clients)
                 {
                     table.add(conn.get("address"), conn.get("ssl"), conn.get("version"),

-                              conn.get("user"), conn.get("keyspace"), conn.get("requests"));
+                              conn.get("user"), conn.get("keyspace"), conn.get("requests"),
conn.get("driverName"), conn.get("driverVersion"));
                 }
                 table.printTo(System.out);
                 System.out.println();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5dc55e71/src/java/org/apache/cassandra/transport/Server.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/Server.java b/src/java/org/apache/cassandra/transport/Server.java
index 2c5e28a..0504b2f 100644
--- a/src/java/org/apache/cassandra/transport/Server.java
+++ b/src/java/org/apache/cassandra/transport/Server.java
@@ -196,6 +196,8 @@ public class Server implements CassandraDaemon.Server
                         .put("version", String.valueOf(conn.getVersion().asInt()))
                         .put("requests", String.valueOf(conn.requests.getCount()))
                         .put("ssl", conn.channel().pipeline().get(SslHandler.class) == null
? "false" : "true")
+                        .put("driverName", conn.getClientState().getDriverName().orElse("undefined"))
+                        .put("driverVersion", conn.getClientState().getDriverVersion().orElse("undefined"))
                         .build());
             }
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5dc55e71/src/java/org/apache/cassandra/transport/messages/StartupMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/messages/StartupMessage.java b/src/java/org/apache/cassandra/transport/messages/StartupMessage.java
index bf4a619..f72121a 100644
--- a/src/java/org/apache/cassandra/transport/messages/StartupMessage.java
+++ b/src/java/org/apache/cassandra/transport/messages/StartupMessage.java
@@ -23,6 +23,7 @@ import java.util.Map;
 import io.netty.buffer.ByteBuf;
 
 import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.service.ClientState;
 import org.apache.cassandra.service.QueryState;
 import org.apache.cassandra.transport.*;
 import org.apache.cassandra.utils.CassandraVersion;
@@ -36,6 +37,8 @@ public class StartupMessage extends Message.Request
     public static final String CQL_VERSION = "CQL_VERSION";
     public static final String COMPRESSION = "COMPRESSION";
     public static final String PROTOCOL_VERSIONS = "PROTOCOL_VERSIONS";
+    public static final String DRIVER_NAME = "DRIVER_NAME";
+    public static final String DRIVER_VERSION = "DRIVER_VERSION";
 
     public static final Message.Codec<StartupMessage> codec = new Message.Codec<StartupMessage>()
     {
@@ -98,6 +101,14 @@ public class StartupMessage extends Message.Request
             }
         }
 
+        ClientState clientState = state.getClientState();
+        String driverName = options.get(DRIVER_NAME);
+        if (null != driverName)
+        {
+            clientState.setDriverName(driverName);
+            clientState.setDriverVersion(options.get(DRIVER_VERSION));
+        }
+
         if (DatabaseDescriptor.getAuthenticator().requireAuthentication())
             return new AuthenticateMessage(DatabaseDescriptor.getAuthenticator().getClass().getName());
         else


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message