Expose StorageServiceMBean#getKeyspaceReplicationInfo (backport from 4.0 and CASSANDRA-13853)

patch by Stefan Miklosovic; reviewed by Mick Semb Wever for CASSANDRA-16447
This commit is contained in:
Stefan Miklosovic 2021-02-15 14:04:59 +01:00 committed by Mick Semb Wever
parent e9209527f2
commit ec9b7b9d37
No known key found for this signature in database
GPG Key ID: E91335D77E3E87CB
3 changed files with 16 additions and 0 deletions

View File

@ -1,4 +1,5 @@
3.11.11
* Add StorageServiceMBean.getKeyspaceReplicationInfo(keyspaceName) (CASSANDRA-16447)
* Upgrade jackson-databind to 2.9.10.8 (CASSANDRA-16462)
Merged from 3.0:
* Ignore trailing zeros in hint files (CASSANDRA-16523)

View File

@ -84,6 +84,7 @@ import org.apache.cassandra.repair.*;
import org.apache.cassandra.repair.messages.RepairOption;
import org.apache.cassandra.schema.CompactionParams.TombstoneOption;
import org.apache.cassandra.schema.KeyspaceMetadata;
import org.apache.cassandra.schema.ReplicationParams;
import org.apache.cassandra.schema.SchemaKeyspace;
import org.apache.cassandra.service.paxos.CommitVerbHandler;
import org.apache.cassandra.service.paxos.PrepareVerbHandler;
@ -2996,6 +2997,15 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
return Schema.instance.getVersion().toString();
}
public String getKeyspaceReplicationInfo(String keyspaceName)
{
Keyspace keyspaceInstance = Schema.instance.getKeyspaceInstance(keyspaceName);
if (keyspaceInstance == null)
throw new IllegalArgumentException(); // ideally should never happen
ReplicationParams replicationParams = keyspaceInstance.getMetadata().params.replication;
return replicationParams.klass.getSimpleName() + " " + replicationParams.options.toString();
}
public List<String> getLeavingNodes()
{
return stringify(tokenMetadata.getLeavingEndpoints());

View File

@ -97,6 +97,11 @@ public interface StorageServiceMBean extends NotificationEmitter
*/
public String getSchemaVersion();
/**
* Fetch the replication factor for a given keyspace.
* @return string representation of replication information
*/
public String getKeyspaceReplicationInfo(String keyspaceName);
/**
* Get the list of all data file locations from conf