Skip to content

Commit a27b56f

Browse files
committed
remove jmx calls metrics
1 parent 456caa4 commit a27b56f

File tree

6 files changed

+13
-119
lines changed

6 files changed

+13
-119
lines changed

server/src/main/java/org/apache/cassandra/sidecar/metrics/JmxOperationsMetrics.java

-60
This file was deleted.

server/src/main/java/org/apache/cassandra/sidecar/metrics/ServerMetrics.java

-5
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,4 @@ public interface ServerMetrics
5353
* @return metrics related to internal caches that are tracked.
5454
*/
5555
CacheMetrics cacheMetrics();
56-
57-
/**
58-
* @return metrics related to invocation of C* JMX operations
59-
*/
60-
JmxOperationsMetrics jmxOperationsMetrics();
6156
}

server/src/main/java/org/apache/cassandra/sidecar/metrics/ServerMetricsImpl.java

-8
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class ServerMetricsImpl implements ServerMetrics
3333
protected final RestoreMetrics restoreMetrics;
3434
protected final SchemaMetrics schemaMetrics;
3535
protected final CacheMetrics cacheMetrics;
36-
protected final JmxOperationsMetrics jmxOperationsMetrics;
3736

3837
public ServerMetricsImpl(MetricRegistry metricRegistry)
3938
{
@@ -44,7 +43,6 @@ public ServerMetricsImpl(MetricRegistry metricRegistry)
4443
this.restoreMetrics = new RestoreMetrics(metricRegistry);
4544
this.schemaMetrics = new SchemaMetrics(metricRegistry);
4645
this.cacheMetrics = new CacheMetrics(metricRegistry);
47-
this.jmxOperationsMetrics = new JmxOperationsMetrics(metricRegistry);
4846
}
4947

5048
@Override
@@ -76,10 +74,4 @@ public CacheMetrics cacheMetrics()
7674
{
7775
return cacheMetrics;
7876
}
79-
80-
@Override
81-
public JmxOperationsMetrics jmxOperationsMetrics()
82-
{
83-
return jmxOperationsMetrics;
84-
}
8577
}

server/src/main/java/org/apache/cassandra/sidecar/routes/AbstractHandler.java

-20
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import io.netty.handler.codec.http.HttpResponseStatus;
2828
import io.netty.handler.codec.http.HttpStatusClass;
29-
import io.vertx.core.AsyncResult;
3029
import io.vertx.core.Handler;
3130
import io.vertx.core.http.HttpServerRequest;
3231
import io.vertx.core.net.SocketAddress;
@@ -42,7 +41,6 @@
4241
import org.apache.cassandra.sidecar.common.server.exceptions.JmxAuthenticationException;
4342
import org.apache.cassandra.sidecar.concurrent.ExecutorPools;
4443
import org.apache.cassandra.sidecar.exceptions.NoSuchSidecarInstanceException;
45-
import org.apache.cassandra.sidecar.metrics.JmxOperationsMetrics;
4644
import org.apache.cassandra.sidecar.utils.CassandraInputValidator;
4745
import org.apache.cassandra.sidecar.utils.InstanceMetadataFetcher;
4846

@@ -344,24 +342,6 @@ protected StorageOperations getStorageOperations(String host)
344342
throw cassandraServiceUnavailable();
345343
}
346344

347-
348345
return storageOperations;
349346
}
350-
351-
protected <V> void updateJmxMetric(AsyncResult<V> result,
352-
JmxOperationsMetrics jmxOperationsMetrics,
353-
String operationName,
354-
long startTime)
355-
{
356-
if (result.succeeded())
357-
{
358-
jmxOperationsMetrics.recordTimeTaken(operationName + "Succeeded",
359-
System.nanoTime() - startTime);
360-
}
361-
else
362-
{
363-
jmxOperationsMetrics.recordTimeTaken(operationName + "Failed",
364-
System.nanoTime() - startTime);
365-
}
366-
}
367347
}

server/src/main/java/org/apache/cassandra/sidecar/routes/cassandra/GetPreemptiveOpenIntervalHandler.java

+4-16
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@
2121
import javax.inject.Singleton;
2222

2323
import com.google.inject.Inject;
24-
import io.vertx.core.Future;
2524
import io.vertx.core.http.HttpServerRequest;
2625
import io.vertx.core.net.SocketAddress;
2726
import io.vertx.ext.web.RoutingContext;
28-
import org.apache.cassandra.sidecar.common.response.GetPreemptiveOpenIntervalResponse;
2927
import org.apache.cassandra.sidecar.common.server.StorageOperations;
3028
import org.apache.cassandra.sidecar.concurrent.ExecutorPools;
31-
import org.apache.cassandra.sidecar.metrics.JmxOperationsMetrics;
3229
import org.apache.cassandra.sidecar.metrics.SidecarMetrics;
3330
import org.apache.cassandra.sidecar.routes.AbstractHandler;
3431
import org.apache.cassandra.sidecar.utils.CassandraInputValidator;
@@ -40,7 +37,6 @@
4037
@Singleton
4138
public class GetPreemptiveOpenIntervalHandler extends AbstractHandler<Void>
4239
{
43-
private final JmxOperationsMetrics jmxOperationsMetrics;
4440

4541
@Inject
4642
protected GetPreemptiveOpenIntervalHandler(InstanceMetadataFetcher metadataFetcher,
@@ -49,7 +45,6 @@ protected GetPreemptiveOpenIntervalHandler(InstanceMetadataFetcher metadataFetch
4945
SidecarMetrics sidecarMetrics)
5046
{
5147
super(metadataFetcher, executorPools, validator);
52-
this.jmxOperationsMetrics = sidecarMetrics.server().jmxOperationsMetrics();
5348
}
5449

5550
@Override
@@ -65,20 +60,13 @@ protected void handleInternal(RoutingContext context,
6560
SocketAddress remoteAddress,
6661
Void request)
6762
{
68-
getSSTablePreemptiveOpenInterval(host, remoteAddress)
69-
.onSuccess(context::json)
70-
.onFailure(cause -> processFailure(cause, context, host, remoteAddress, request));
71-
}
72-
73-
protected Future<GetPreemptiveOpenIntervalResponse> getSSTablePreemptiveOpenInterval(String host, SocketAddress remoteAddress)
74-
{
75-
long startTime = System.nanoTime();
7663
StorageOperations storageOperations = getStorageOperations(host);
7764
logger.debug("Retrieving SSTable's preemptiveOpenInterval, remoteAddress={}, instance={}",
7865
remoteAddress, host);
7966

80-
return executorPools.service()
81-
.executeBlocking(storageOperations::getSSTablePreemptiveOpenIntervalInMB)
82-
.onComplete(ar -> updateJmxMetric(ar, jmxOperationsMetrics, "getSSTablePreemptiveOpenInterval", startTime));
67+
executorPools.service()
68+
.executeBlocking(storageOperations::getSSTablePreemptiveOpenIntervalInMB)
69+
.onSuccess(context::json)
70+
.onFailure(cause -> processFailure(cause, context, host, remoteAddress, request));
8371
}
8472
}

server/src/test/integration/org/apache/cassandra/sidecar/routes/cassandra/GetPreemptiveOpenIntervalHandlerIntegrationTest.java

+9-10
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import io.vertx.junit5.VertxTestContext;
2929
import org.apache.cassandra.sidecar.testing.IntegrationTestBase;
3030
import org.apache.cassandra.testing.CassandraIntegrationTest;
31-
import org.apache.cassandra.testing.CassandraTestContext;
3231

3332
import static io.netty.handler.codec.http.HttpResponseStatus.OK;
3433
import static org.assertj.core.api.Assertions.assertThat;
@@ -42,38 +41,38 @@ public class GetPreemptiveOpenIntervalHandlerIntegrationTest extends Integration
4241
private static final String testRoute = "/api/v1/cassandra/sstable/preemptive-open-interval";
4342

4443
@CassandraIntegrationTest
45-
void testDefaultValue(CassandraTestContext context, VertxTestContext testContext)
44+
void testDefaultValue(VertxTestContext testContext)
4645
{
4746
client.get(server.actualPort(), "127.0.0.1", testRoute)
4847
.expect(ResponsePredicate.SC_OK)
49-
.send(testContext.succeeding(response -> verifyResponse(context, testContext, response, 50)));
48+
.send(testContext.succeeding(response -> verifyValidResponse(testContext, response, 50)));
5049
}
5150

5251
@CassandraIntegrationTest(yamlProps = "sstable_preemptive_open_interval_in_mb=60")
53-
void testPreemptiveOpenInterval60(CassandraTestContext context, VertxTestContext testContext)
52+
void testPreemptiveOpenInterval60(VertxTestContext testContext)
5453
{
5554
client.get(server.actualPort(), "127.0.0.1", testRoute)
5655
.expect(ResponsePredicate.SC_OK)
57-
.send(testContext.succeeding(response -> verifyResponse(context, testContext, response, 60)));
56+
.send(testContext.succeeding(response -> verifyValidResponse(testContext, response, 60)));
5857
}
5958

6059
@CassandraIntegrationTest(yamlProps = "sstable_preemptive_open_interval_in_mb=70")
61-
void testPreemptiveOpenInterval70(CassandraTestContext context, VertxTestContext testContext)
60+
void testPreemptiveOpenInterval70(VertxTestContext testContext)
6261
{
6362
client.get(server.actualPort(), "127.0.0.1", testRoute)
6463
.expect(ResponsePredicate.SC_OK)
65-
.send(testContext.succeeding(response -> verifyResponse(context, testContext, response, 70)));
64+
.send(testContext.succeeding(response -> verifyValidResponse(testContext, response, 70)));
6665
}
6766

6867
@CassandraIntegrationTest(yamlProps = "sstable_preemptive_open_interval_in_mb=-1")
69-
void testPreemptiveOpenIntervalNegative(CassandraTestContext context, VertxTestContext testContext)
68+
void testPreemptiveOpenIntervalNegative(VertxTestContext testContext)
7069
{
7170
client.get(server.actualPort(), "127.0.0.1", testRoute)
7271
.expect(ResponsePredicate.SC_OK)
73-
.send(testContext.succeeding(response -> verifyResponse(context, testContext, response, -1)));
72+
.send(testContext.succeeding(response -> verifyValidResponse(testContext, response, -1)));
7473
}
7574

76-
void verifyResponse(CassandraTestContext context, VertxTestContext testContext, HttpResponse<Buffer> response, int expectedValue)
75+
void verifyValidResponse(VertxTestContext testContext, HttpResponse<Buffer> response, int expectedValue)
7776
{
7877
testContext.verify(() -> {
7978
JsonObject responseJson = response.bodyAsJsonObject();

0 commit comments

Comments
 (0)