cassandra-pr mailing list archives

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

 ##########
 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:
   should we rename it to `executeWithTracing` to be consistent with the other code? We should
also probably not expose `sessionId` here, and maybe return a pair of the resultset and tracing
result here?

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