cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cassandra] jonmeredith commented on a change in pull request #357: CASSANDRA-15319 against trunk
Date Tue, 24 Sep 2019 17:57:24 GMT
jonmeredith commented on a change in pull request #357: CASSANDRA-15319 against trunk
URL: https://github.com/apache/cassandra/pull/357#discussion_r327754698
 
 

 ##########
 File path: test/distributed/org/apache/cassandra/distributed/impl/Coordinator.java
 ##########
 @@ -82,6 +86,55 @@ public Coordinator(Instance instance)
         }).call();
     }
 
+    @Override
+    public Future<Object[][]> asyncTraceExecute(UUID sessionId, String query, Enum<?>
consistencyLevelOrigin, Object... boundValues)
+    {
+        return instance.async(() -> {
+            try
+            {
+                Tracing.instance.newSession(sessionId, Collections.emptyMap());
+                ClientState clientState = makeFakeClientState();
+                ConsistencyLevel consistencyLevel = ConsistencyLevel.valueOf(consistencyLevelOrigin.name());
+                CQLStatement prepared = QueryProcessor.getStatement(query, clientState);
+                List<ByteBuffer> boundBBValues = new ArrayList<>();
+                for (Object boundValue : boundValues)
+                {
+                    boundBBValues.add(ByteBufferUtil.objectToBytes(boundValue));
+                }
+
+                prepared.validate(QueryState.forInternalCalls().getClientState());
+                ResultMessage res = prepared.execute(QueryState.forInternalCalls(),
+                                                     QueryOptions.create(consistencyLevel,
+                                                                         boundBBValues,
+                                                                         false,
+                                                                         Integer.MAX_VALUE,
+                                                                         null,
+                                                                         null,
+                                                                         ProtocolVersion.V4,
+                                                                         null),
+                                                     System.nanoTime());
+                if (res != null && res.kind == ResultMessage.Kind.ROWS)
+                {
+                    return RowUtil.toObjects((ResultMessage.Rows) res);
+                }
+                else
+                {
+                    return new Object[][]{};
+                }
+            }
+            finally
+            {
+                Tracing.instance.stopSession();
+            }
+        }).call();
+    }
+    
+    @Override
+    public Object[][] traceExecute(UUID sessionId, String query, Enum<?> consistencyLevelOrigin,
Object... boundValues)
 
 Review comment:
   Renamed the function to be consistent.  
   
   I left passing the `sessionId` in as I think it's useful to be able to group a series of
statements under the same sessionId - the MessageForwardingTest does that, otherwise you have
to take all the tracing results or query for each trace session.  I didn't think allowing
clients to provide it would break anything.

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


With regards,
Apache Git Services

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


Mime
View raw message