This is an automated email from the ASF dual-hosted git repository. samt pushed a commit to branch cassandra-4.0 in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-4.0 by this push: new 5467921 Init client metrics in CQLConnectionTest new c7795ee Merge branch 'cassandra-4.0.0' into cassandra-4.0 5467921 is described below commit 546792169e7df90c905139d1a275056bbef850d4 Author: Sam Tunnicliffe <s...@beobal.com> AuthorDate: Mon Jun 7 19:21:19 2021 +0100 Init client metrics in CQLConnectionTest Patch by Sam Tunnicliffe; reviewed by Mick Semb Wever for CASSANDRA-16722 --- .../apache/cassandra/transport/SimpleClient.java | 2 +- .../cassandra/transport/CQLConnectionTest.java | 30 +++++++++------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/java/org/apache/cassandra/transport/SimpleClient.java b/src/java/org/apache/cassandra/transport/SimpleClient.java index 0ca1c58..ae89e93 100644 --- a/src/java/org/apache/cassandra/transport/SimpleClient.java +++ b/src/java/org/apache/cassandra/transport/SimpleClient.java @@ -719,7 +719,7 @@ public class SimpleClient implements Closeable if (bufferSize + messageSize >= MAX_FRAMED_PAYLOAD_SIZE) { combiner.add(flushBuffer(ctx, buffer, bufferSize)); - buffer.clear(); + buffer = new ArrayList<>(); bufferSize = 0; } buffer.add(f); diff --git a/test/unit/org/apache/cassandra/transport/CQLConnectionTest.java b/test/unit/org/apache/cassandra/transport/CQLConnectionTest.java index eec9fed..96f28a2 100644 --- a/test/unit/org/apache/cassandra/transport/CQLConnectionTest.java +++ b/test/unit/org/apache/cassandra/transport/CQLConnectionTest.java @@ -47,6 +47,7 @@ import org.apache.cassandra.auth.AllowAllNetworkAuthorizer; import org.apache.cassandra.concurrent.NamedThreadFactory; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.cql3.QueryProcessor; +import org.apache.cassandra.metrics.ClientMetrics; import org.apache.cassandra.net.*; import org.apache.cassandra.net.proxy.InboundProxyHandler; import org.apache.cassandra.service.NativeTransportService; @@ -500,10 +501,12 @@ public class CQLConnectionTest private Server server(ServerConfigurator configurator) { - return new Server.Builder().withHost(address) - .withPort(port) - .withPipelineConfigurator(configurator) - .build(); + Server server = new Server.Builder().withHost(address) + .withPort(port) + .withPipelineConfigurator(configurator) + .build(); + ClientMetrics.instance.init(Collections.singleton(server)); + return server; } private Envelope randomEnvelope(int streamId, Message.Type type) @@ -624,18 +627,18 @@ public class CQLConnectionTest if (flusher == null) flusher = new SimpleClient.SimpleFlusher(frameEncoder); - Flusher.FlushItem.Framed item = (Flusher.FlushItem.Framed)toFlushItem.toFlushItem(channel, message, fixedResponse); Envelope response = Envelope.create(responseTemplate.header.type, message.getStreamId(), ProtocolVersion.V5, responseTemplate.header.flags, responseTemplate.body.copy()); - item.release(); flusher.enqueue(response); - // Schedule the proto-flusher to collate any messages to be served // and flush them to the outbound pipeline flusher.schedule(channel.pipeline().lastContext()); + // this simulates the release of the allocated resources that a real flusher would do + Flusher.FlushItem.Framed item = (Flusher.FlushItem.Framed)toFlushItem.toFlushItem(channel, message, fixedResponse); + item.release(); } } @@ -1005,6 +1008,7 @@ public class CQLConnectionTest inboundMessages.add(decoder.decode(buffer)); responsesReceived.countDown(); } + catch (Exception e) { throw new IOException(e); @@ -1030,15 +1034,10 @@ public class CQLConnectionTest @Override public void exceptionCaught(final ChannelHandlerContext ctx, Throwable cause) throws Exception { - // if the connection is closed finish early as - // we don't want to wait for expected responses if (cause instanceof IOException) { connected = false; disconnectionError = cause; - int remaining = (int) responsesReceived.getCount(); - for (int i=0; i < remaining; i++) - responsesReceived.countDown(); } } }); @@ -1084,12 +1083,7 @@ public class CQLConnectionTest private void awaitResponses() throws InterruptedException { - if (!responsesReceived.await(10, TimeUnit.SECONDS)) - { - fail(String.format("Didn't receive all responses, expected %d, actual %d", - expectedResponses, - inboundMessages.size())); - } + responsesReceived.await(1, TimeUnit.SECONDS); } private boolean isConnected() --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org