jmx.org.apache.cassandra.service.CassandraJMXServiceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of commons Show documentation
Show all versions of commons Show documentation
Common classes and utilities integrated with various projects
package jmx.org.apache.cassandra.service;
import com.instaclustr.operations.FunctionWithEx;
import jmx.org.apache.cassandra.CassandraJMXConnectionInfo;
import jmx.org.apache.cassandra.CassandraObjectNames;
import jmx.org.apache.cassandra.service.cassandra3.ColumnFamilyStoreMBean;
import jmx.org.apache.cassandra.service.cassandra3.StorageServiceMBean;
import jmx.org.apache.cassandra.service.cassandra4.Cassandra4ColumnFamilyStoreMBean;
import jmx.org.apache.cassandra.service.cassandra4.Cassandra4StorageServiceMBean;
public class CassandraJMXServiceImpl implements CassandraJMXService {
private final CassandraJMXConnectionInfo jmxConnectionInfo;
public CassandraJMXServiceImpl(CassandraJMXConnectionInfo jmxConnectionInfo) {
this.jmxConnectionInfo = jmxConnectionInfo;
}
@Override
public T doWithCassandra4StorageServiceMBean(final FunctionWithEx func) throws Exception {
return doWithMBean(func,
Cassandra4StorageServiceMBean.class,
CassandraObjectNames.V4.STORAGE_SERVICE_MBEAN_NAME,
jmxConnectionInfo);
}
@Override
public T doWithCassandra3StorageServiceMBean(final FunctionWithEx func) throws Exception {
return doWithStorageServiceMBean(func);
}
@Override
public T doWithStorageServiceMBean(final FunctionWithEx func) throws Exception {
return doWithMBean(func,
StorageServiceMBean.class,
CassandraObjectNames.V3.STORAGE_SERVICE_MBEAN_NAME,
jmxConnectionInfo);
}
@Override
public T doWithCassandra3ColumnFamilyStoreMBean(final FunctionWithEx func,
final String keyspace,
final String columnFamily) throws Exception {
return doWithMBean(func, ColumnFamilyStoreMBean.class,
getColumnFamilyMBeanObjectNameQuery(keyspace, columnFamily),
jmxConnectionInfo);
}
@Override
public T doWithCassandra4ColumnFamilyStoreMBean(final FunctionWithEx func,
final String keyspace,
final String columnFamily) throws Exception {
return doWithMBean(func,
Cassandra4ColumnFamilyStoreMBean.class,
getColumnFamilyMBeanObjectNameQuery(keyspace, columnFamily),
jmxConnectionInfo);
}
@Override
public CassandraJMXConnectionInfo getCassandraJmxConnectionInfo() {
return jmxConnectionInfo;
}
private String getColumnFamilyMBeanObjectNameQuery(final String keyspace, final String columnFamily) {
final String type = columnFamily.contains(".") ? "IndexColumnFamilies" : "ColumnFamilies";
return "org.apache.cassandra.db:type=*" + type + ",keyspace=" + keyspace + ",columnfamily=" + columnFamily;
}
}