本文整理汇总了Java中org.apache.cassandra.service.StorageServiceMBean类的典型用法代码示例。如果您正苦于以下问题:Java StorageServiceMBean类的具体用法?Java StorageServiceMBean怎么用?Java StorageServiceMBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StorageServiceMBean类属于org.apache.cassandra.service包,在下文中一共展示了StorageServiceMBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JmxProxyImpl
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
private JmxProxyImpl(
Optional<RepairStatusHandler> handler,
String host,
String hostBeforeTranslation,
JMXServiceURL jmxUrl,
JMXConnector jmxConnector,
Object ssProxy,
ObjectName ssMbeanName,
MBeanServerConnection mbeanServer,
CompactionManagerMBean cmProxy,
EndpointSnitchInfoMBean endpointSnitchMbean,
FailureDetectorMBean fdProxy) {
this.host = host;
this.hostBeforeTranslation = hostBeforeTranslation;
this.jmxUrl = jmxUrl;
this.jmxConnector = jmxConnector;
this.ssMbeanName = ssMbeanName;
this.mbeanServer = mbeanServer;
this.ssProxy = ssProxy;
this.repairStatusHandler = handler;
this.cmProxy = cmProxy;
this.endpointSnitchMbean = endpointSnitchMbean;
this.clusterName = Cluster.toSymbolicName(((StorageServiceMBean) ssProxy).getClusterName());
this.fdProxy = fdProxy;
}
示例2: getRangesForLocalEndpoint
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
@Override
public List<RingRange> getRangesForLocalEndpoint(String keyspace) throws ReaperException {
checkNotNull(ssProxy, "Looks like the proxy is not connected");
List<RingRange> localRanges = Lists.newArrayList();
try {
Map<List<String>, List<String>> ranges = ((StorageServiceMBean) ssProxy).getRangeToEndpointMap(keyspace);
String localEndpoint = getLocalEndpoint();
// Filtering ranges for which the local node is a replica
// For local mode
ranges
.entrySet()
.stream()
.forEach(entry -> {
if (entry.getValue().contains(localEndpoint)) {
localRanges.add(
new RingRange(new BigInteger(entry.getKey().get(0)), new BigInteger(entry.getKey().get(1))));
}
});
LOG.info("LOCAL RANGES {}", localRanges);
return localRanges;
} catch (RuntimeException e) {
LOG.error(e.getMessage());
throw new ReaperException(e.getMessage(), e);
}
}
示例3: tokenRangeToEndpoint
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
@NotNull
@Override
public List<String> tokenRangeToEndpoint(String keyspace, RingRange tokenRange) {
checkNotNull(ssProxy, "Looks like the proxy is not connected");
Set<Map.Entry<List<String>, List<String>>> entries
= ((StorageServiceMBean) ssProxy).getRangeToEndpointMap(keyspace).entrySet();
for (Map.Entry<List<String>, List<String>> entry : entries) {
BigInteger rangeStart = new BigInteger(entry.getKey().get(0));
BigInteger rangeEnd = new BigInteger(entry.getKey().get(1));
if (new RingRange(rangeStart, rangeEnd).encloses(tokenRange)) {
LOG.debug("[tokenRangeToEndpoint] Found replicas for token range {} : {}", tokenRange, entry.getValue());
return entry.getValue();
}
}
LOG.error("[tokenRangeToEndpoint] no replicas found for token range {}", tokenRange);
LOG.debug("[tokenRangeToEndpoint] checked token ranges were {}", entries);
return Lists.newArrayList();
}
示例4: main
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
JMXServiceURL jmxUrl;
JMXConnector jmxc = null;
try {
jmxUrl = new JMXServiceURL(String.format("service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi", InetAddress.getLocalHost().getCanonicalHostName(), 7199));
jmxc = JMXConnectorFactory.connect(jmxUrl);
MBeanServerConnection mbeanServerConn = jmxc.getMBeanServerConnection();
ObjectName name = new ObjectName("org.apache.cassandra.db:type=StorageService");
StorageServiceMBean ssProxy = JMX.newMBeanProxy(mbeanServerConn, name, StorageServiceMBean.class);
ssProxy.forceTerminateAllRepairSessions();
System.out.println("All repair sessions terminated");
} catch (Exception e) {
System.err.println("Failed to stop all repair sessions: " + e);
} finally {
if (jmxc != null) {
jmxc.close();
}
}
}
示例5: newStorageService
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
private StorageServiceMBean newStorageService() {
return (StorageServiceMBean) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{StorageServiceMBean.class},
new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
String name = method.getName();
switch (name) {
case "takeSnapshot":
invocations.add("takeSnapshot");
return null;
case "clearSnapshot":
invocations.add("clearSnapshot");
return null;
case "getAllDataFileLocations":
return new String[]{dataDir};
default:
throw new UnsupportedOperationException(name);
}
}
});
}
示例6: connect
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
/**
* Create a connection to the JMX agent and setup the M[X]Bean proxies.
*
* @throws IOException on connection failures
*/
public void connect() throws IOException
{
JMXServiceURL jmxUrl = new JMXServiceURL(String.format(fmtUrl, host, port));
Map<String,Object> env = new HashMap<>();
if (username != null)
{
String[] creds = { username, password };
env.put(JMXConnector.CREDENTIALS, creds);
}
env.put("com.sun.jndi.rmi.factory.socket", getRMIClientSocketFactory());
jmxc = JMXConnectorFactory.connect(jmxUrl, env);
mbeanServerConn = jmxc.getMBeanServerConnection();
try
{
ObjectName name = new ObjectName(ssObjName);
ssProxy = newMBeanProxy(mbeanServerConn, name, StorageServiceMBean.class);
}
catch (MalformedObjectNameException e)
{
throw new RuntimeException(
"Invalid ObjectName? Please report this as a bug.", e);
}
}
示例7: getTokens
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
@Override
public List<BigInteger> getTokens() {
checkNotNull(ssProxy, "Looks like the proxy is not connected");
return Lists.transform(
Lists.newArrayList(((StorageServiceMBean) ssProxy).getTokenToEndpointMap().keySet()), s -> new BigInteger(s));
}
示例8: getRangeToEndpointMap
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
@Override
public Map<List<String>, List<String>> getRangeToEndpointMap(String keyspace) throws ReaperException {
checkNotNull(ssProxy, "Looks like the proxy is not connected");
try {
return ((StorageServiceMBean) ssProxy).getRangeToEndpointMap(keyspace);
} catch (RuntimeException e) {
LOG.error(e.getMessage());
throw new ReaperException(e.getMessage(), e);
}
}
示例9: getLocalEndpoint
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
public String getLocalEndpoint() throws ReaperException {
String cassandraVersion = getCassandraVersion();
if (versionCompare(cassandraVersion, "2.1.10") >= 0) {
return ((StorageServiceMBean) ssProxy)
.getHostIdToEndpoint()
.get(((StorageServiceMBean) ssProxy).getLocalHostId());
} else {
// pre-2.1.10 compatibility
BiMap<String, String> hostIdBiMap =
ImmutableBiMap.copyOf(((StorageServiceMBean) ssProxy).getHostIdMap());
String localHostId = ((StorageServiceMBean) ssProxy).getLocalHostId();
return hostIdBiMap.inverse().get(localHostId);
}
}
示例10: getEndpointToHostId
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
@NotNull
@Override
public Map<String, String> getEndpointToHostId() {
checkNotNull(ssProxy, "Looks like the proxy is not connected");
Map<String, String> hosts;
try {
hosts = ((StorageServiceMBean) ssProxy).getEndpointToHostId();
} catch (UndeclaredThrowableException e) {
hosts = ((StorageServiceMBean) ssProxy).getHostIdMap();
}
return hosts;
}
示例11: cancelAllRepairs
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
@Override
public void cancelAllRepairs() {
checkNotNull(ssProxy, "Looks like the proxy is not connected");
try {
((StorageServiceMBean) ssProxy).forceTerminateAllRepairSessions();
} catch (RuntimeException e) {
// This can happen if the node is down (UndeclaredThrowableException),
// in which case repairs will be cancelled anyway...
LOG.warn("Failed to terminate all repair sessions; node down?", e);
}
}
示例12: triggerRepairPost2dot2
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
private int triggerRepairPost2dot2(
boolean fullRepair,
RepairParallelism repairParallelism,
String keyspace,
Collection<String> columnFamilies,
BigInteger beginToken,
BigInteger endToken,
String cassandraVersion,
Collection<String> datacenters) {
Map<String, String> options = new HashMap<>();
options.put(RepairOption.PARALLELISM_KEY, repairParallelism.getName());
// options.put(RepairOption.PRIMARY_RANGE_KEY, Boolean.toString(primaryRange));
options.put(RepairOption.INCREMENTAL_KEY, Boolean.toString(!fullRepair));
options.put(RepairOption.JOB_THREADS_KEY, Integer.toString(1));
options.put(RepairOption.TRACE_KEY, Boolean.toString(Boolean.FALSE));
options.put(RepairOption.COLUMNFAMILIES_KEY, StringUtils.join(columnFamilies, ","));
// options.put(RepairOption.PULL_REPAIR_KEY, Boolean.FALSE);
if (fullRepair) {
options.put(RepairOption.RANGES_KEY, beginToken.toString() + ":" + endToken.toString());
}
options.put(RepairOption.DATACENTERS_KEY, StringUtils.join(datacenters, ","));
// options.put(RepairOption.HOSTS_KEY, StringUtils.join(specificHosts, ","));
return ((StorageServiceMBean) ssProxy).repairAsync(keyspace, options);
}
示例13: clearSnapshot
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
@Override
public void clearSnapshot(String repairId, String keyspaceName) throws ReaperException {
if (repairId == null || ("").equals(repairId)) {
// Passing in null or empty string will clear all snapshots on the hos
throw new IllegalArgumentException("repairId cannot be null or empty string");
}
try {
((StorageServiceMBean) ssProxy).clearSnapshot(repairId, keyspaceName);
} catch (IOException e) {
throw new ReaperException(e);
}
}
示例14: getLiveNodes
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
@Override
public List<String> getLiveNodes() throws ReaperException {
checkNotNull(ssProxy, "Looks like the proxy is not connected");
try {
return ((StorageServiceMBean) ssProxy).getLiveNodes();
} catch (RuntimeException e) {
LOG.error(e.getMessage());
throw new ReaperException(e.getMessage(), e);
}
}
示例15: getSSProxy
import org.apache.cassandra.service.StorageServiceMBean; //导入依赖的package包/类
public StorageServiceMBean getSSProxy(MBeanServerConnection mbeanConn)
{
StorageServiceMBean proxy = null;
try
{
ObjectName name = new ObjectName(ssObjName);
proxy = JMX.newMBeanProxy(mbeanConn, name, StorageServiceMBean.class);
}
catch (MalformedObjectNameException e)
{
throw new RuntimeException(e);
}
return proxy;
}