Did you look at how status fetches and initialises the keyspace? Have a
look at org.apache.cassandra.service.StorageService#effectiveOwnership. It
uses a keyspace and its RF to measure ownership. The same method should
work for any nodetool command that needs a keyspace. Note that depending on
what you are using it for you may need to handle each strategy differently
(and also handle LocalStrategy).

On 21 December 2017 at 01:02, Tyagi, Preetika <preetika.ty...@intel.com>
wrote:

> Hi,
>
> If I need to get the replication factor of a given keyspace in nodetool
> commands (e.g. status), how can I do that? I'm trying to figure it out for
> a JIRA item I'm working on.
>
> I tried using the below:
> Keyspace keyspace = Keyspace.open(keyspaceName);
> Int rf = keyspace.getReplicationStrategy().getReplicationFactor()
>
> However, it runs into some issues since internally something doesn't get
> initialized while looking up keyspaces/metatadata.
>
> Any ideas on how I can approach it differently?
>
> Thanks,
> Preetika
>
>

Reply via email to