Skip to content

Commit

Permalink
Remove diagnostic related methods from ICassandraManagementProxy, onl…
Browse files Browse the repository at this point in the history
…y enable the Diagnostic REST interfaces if JMX backend is used.
  • Loading branch information
burmanm committed Aug 9, 2023
1 parent 4367582 commit 32a0584
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 42 deletions.
17 changes: 10 additions & 7 deletions src/server/src/main/java/io/cassandrareaper/ReaperApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,16 @@ public void run(ReaperApplicationConfiguration config, Environment environment)
environment.jersey().register(addCryptoResource);

HttpClient httpClient = createHttpClient(config, environment);
ScheduledExecutorService ses = environment.lifecycle().scheduledExecutorService("Diagnostics").threads(6).build();
final DiagEventSubscriptionResource eventsResource = new DiagEventSubscriptionResource(context, httpClient, ses,
context.storage.getEventsDao());
environment.jersey().register(eventsResource);
final DiagEventSseResource diagEvents = new DiagEventSseResource(context, httpClient, ses,
context.storage.getEventsDao());
environment.jersey().register(diagEvents);

if (context.managementConnectionFactory instanceof JmxManagementConnectionFactory) {
ScheduledExecutorService ses = environment.lifecycle().scheduledExecutorService("Diagnostics").threads(6).build();
final DiagEventSubscriptionResource eventsResource = new DiagEventSubscriptionResource(context, httpClient, ses,
context.storage.getEventsDao());
environment.jersey().register(eventsResource);
final DiagEventSseResource diagEvents = new DiagEventSseResource(context, httpClient, ses,
context.storage.getEventsDao());
environment.jersey().register(diagEvents);
}

if (config.isAccessControlEnabled()) {
SessionHandler sessionHandler = new SessionHandler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ private DiagnosticProxy(JmxCassandraManagementProxy proxy) {
}

public static DiagnosticProxy create(JmxCassandraManagementProxy proxy) {

return new DiagnosticProxy(proxy);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
import io.cassandrareaper.service.RingRange;

import java.io.IOException;
import java.io.Serializable;
import java.math.BigInteger;
import java.net.UnknownHostException;
import java.time.Duration;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.concurrent.ExecutionException;
import javax.management.JMException;
import javax.management.openmbean.CompositeData;
Expand Down Expand Up @@ -157,16 +155,6 @@ void forceKeyspaceCompaction(boolean var1, String var2, String... var3) throws I
// From EndpointSnitchInfoMBean
String getDatacenter(String var1) throws UnknownHostException;

// from DiagnosticEventPersistenceMBean
SortedMap<Long, Map<String, Serializable>> readEvents(String eventClass, Long lastKey, int limit);

void enableEventPersistence(String eventClass);

void disableEventPersistence(String eventClass);

// From LastEventIdBroadcasterMBean
Map<String, Comparable> getLastEventIdsIfModified(long lastUpdate);

// From StreamManagerMBean
Set<CompositeData> getCurrentStreams();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import io.cassandrareaper.service.RingRange;

import java.io.IOException;
import java.io.Serializable;
import java.math.BigInteger;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
Expand All @@ -35,8 +34,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.concurrent.ExecutionException;
import javax.management.JMException;
import javax.management.openmbean.CompositeData;
Expand Down Expand Up @@ -221,25 +218,6 @@ public String getDatacenter(String var1) throws UnknownHostException {
return "";
}

// from DiagnosticEventPersistenceMBean
public SortedMap<Long, Map<String, Serializable>> readEvents(String eventClass, Long lastKey, int limit) {
//TODO: implement me
return new TreeMap<>();
}

public void enableEventPersistence(String eventClass) {
//TODO: implement me
}

public void disableEventPersistence(String eventClass) {
//TODO: implement me
}

// From LastEventIdBroadcasterMBean
public Map<String, Comparable> getLastEventIdsIfModified(long lastUpdate) {
return new HashMap<String, Comparable>();
}

// From StreamManagerMBean
public Set<CompositeData> getCurrentStreams() {
return new HashSet<CompositeData>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ private DiagEventSubscriptionService(AppContext context, HttpClient httpClient,

public static DiagEventSubscriptionService create(AppContext cxt, HttpClient client, ScheduledExecutorService exec,
IEventsDao eventsDao) {
Preconditions.checkState(cxt.managementConnectionFactory instanceof JmxManagementConnectionFactory,
"JMX diagnostic events are only available when JMX connections are used.");
return new DiagEventSubscriptionService(cxt, client, exec, eventsDao);
}

Expand Down

0 comments on commit 32a0584

Please sign in to comment.