isCassandraStarted.set(true); NodeProbe bean = JMXNodeTool.instance(this.config); instanceState.setIsGossipActive(bean.isGossipRunning()); instanceState.setIsNativeTransportActive(bean.isNativeTransportRunning()); instanceState.setIsThriftActive(bean.isThriftServerRunning()); } else {
boolean gossipInitialized = probe.isGossipRunning(); System.out.printf("%-23s: %s%n", "ID", probe.getLocalHostId()); System.out.printf("%-23s: %s%n", "Gossip active", gossipInitialized); System.out.printf("%-23s: %s%n", "Thrift active", probe.isThriftServerRunning()); System.out.printf("%-23s: %s%n", "Native Transport active", probe.isNativeTransportRunning()); System.out.printf("%-23s: %s%n", "Load", probe.getLoadString()); if (gossipInitialized) System.out.printf("%-23s: %s%n", "Generation No", probe.getCurrentGenerationNumber()); else System.out.printf("%-23s: %s%n", "Generation No", 0); long secondsUp = probe.getUptime() / 1000; System.out.printf("%-23s: %d%n", "Uptime (seconds)", secondsUp); MemoryUsage heapUsage = probe.getHeapMemoryUsage(); double memUsed = (double) heapUsage.getUsed() / (1024 * 1024); double memMax = (double) heapUsage.getMax() / (1024 * 1024); System.out.printf("%-23s: %s%n", "Data Center", probe.getDataCenter()); System.out.printf("%-23s: %s%n", "Rack", probe.getRack()); System.out.printf("%-23s: %s%n", "Exceptions", probe.getStorageMetric("Exceptions")); CacheServiceMBean cacheService = probe.getCacheServiceMBean(); probe.getCacheMetric("KeyCache", "Entries"), FileUtils.stringifyFileSize((long) probe.getCacheMetric("KeyCache", "Size")), FileUtils.stringifyFileSize((long) probe.getCacheMetric("KeyCache", "Capacity")),
@Override public void execute(NodeProbe probe) joiningNodes = probe.getJoiningNodes(); leavingNodes = probe.getLeavingNodes(); movingNodes = probe.getMovingNodes(); loadMap = probe.getLoadMap(); tokensToEndpoints = probe.getTokenToEndpointMap(); liveNodes = probe.getLiveNodes(); unreachableNodes = probe.getUnreachableNodes(); hostIDMap = probe.getHostIdMap(); epSnitchInfo = probe.getEndpointSnitchInfoProxy(); try ownerships = probe.effectiveOwnership(keyspace); hasEffectiveOwns = true; } catch (IllegalStateException e) ownerships = probe.getOwnership(); errors.append("Note: " + e.getMessage() + "%n");
private static CassandraStatus getCassandraStatus(final NodeProbe probe) { return CassandraStatus.create( CassandraMode.valueOf( probe.getOperationMode() ), probe.isJoined(), probe.isThriftServerRunning(), probe.isNativeTransportRunning(), probe.isInitialized(), probe.isGossipRunning(), probe.getLocalHostId(), probe.getEndpoint(), probe.getTokens().size(), probe.getDataCenter(), probe.getRack(), probe.getReleaseVersion()); }
/** * Get the information if the native transport is active on the node. Get the information about node such as which * protocols are active, uptime, and exception count. * * @return NodeInfo for the node */ @Override public NodeInfo getNodeInfo() { NodeInfo nodeInfo = new NodeInfo(this.nodeProbe.isGossipRunning(), this.nodeProbe.isThriftServerRunning(), this.nodeProbe.isNativeTransportRunning(), this.nodeProbe.getUptime(), this.nodeProbe.getExceptionCount()); return nodeInfo; }
SetHostStat hoststats,boolean showEffectiveOwnership) Collection<String> liveNodes = probe.getLiveNodes(); Collection<String> deadNodes = probe.getUnreachableNodes(); Collection<String> joiningNodes = probe.getJoiningNodes(); Collection<String> leavingNodes = probe.getLeavingNodes(); Collection<String> movingNodes = probe.getMovingNodes(); Map<String, String> loadMap = probe.getLoadMap(); try rack = probe.getEndpointSnitchInfoProxy().getRack(endpoint);
NodeProbe nodeProbe = new NodeProbe(nodehost, port); if (nodeProbe.getTokens().size() != 1) { System.err.println("Cluster is using vnodes and should already be automatically balanced!"); System.exit(1); Map<String, String> loadMap = nodeProbe.getLoadMap(); for (String s : loadMap.values()) { if (s.contains("KB")) String partitioner = nodeProbe.getPartitioner(); BigInteger minToken, maxToken; List<String> liveNodes = nodeProbe.getLiveNodes(); String dc = nodeProbe.getEndpointSnitchInfoProxy().getDatacenter(host); List<String> tokens = nodeProbe.getTokens(host); if (!dryrun) { String ip = op.host.substring(op.host.lastIndexOf("/") + 1); NodeProbe np = new NodeProbe(ip, 7199); np.move(op.newToken.toString()); moved = true; } else {
@Override public void execute(NodeProbe probe) { CompactionManagerMBean cm = probe.getCompactionManagerProxy(); Map<String, Map<String, Integer>> pendingTaskNumberByTable = (Map<String, Map<String, Integer>>) probe.getCompactionMetric("PendingTasksByTableName"); int numTotalPendingTask = 0; for (Entry<String, Map<String, Integer>> ksEntry : pendingTaskNumberByTable.entrySet()) { for (Entry<String, Integer> tableEntry : ksEntry.getValue().entrySet()) numTotalPendingTask += tableEntry.getValue(); } System.out.println("pending tasks: " + numTotalPendingTask); for (Entry<String, Map<String, Integer>> ksEntry : pendingTaskNumberByTable.entrySet()) { String ksName = ksEntry.getKey(); for (Entry<String, Integer> tableEntry : ksEntry.getValue().entrySet()) { String tableName = tableEntry.getKey(); int pendingTaskCount = tableEntry.getValue(); System.out.println("- " + ksName + '.' + tableName + ": " + pendingTaskCount); } } System.out.println(); reportCompactionTable(cm.getCompactions(), probe.getCompactionThroughput(), humanReadable); }
/** * Get compaction settings info for. * * @return compaction settings info. */ @Override public CompactionSettingsInfo getCompactionSettingsInfo() { return new CompactionSettingsInfo(nodeProbe.getCompactionThroughput(), nodeProbe.getCompactionManagerProxy().getCoreCompactorThreads(), nodeProbe.getCompactionManagerProxy().getMaximumCompactorThreads(), nodeProbe.getCompactionManagerProxy().getCoreValidationThreads(), nodeProbe.getCompactionManagerProxy().getMaximumValidatorThreads()); }
public static void main(String[] args) throws IOException { if (args.length < 1) { System.out.println(String.format("Usage: %s [ALL | host [host ...]]", TruncateHints.class.getName())); System.exit(1); } NodeProbe nodeProbe = new NodeProbe(InetAddress.getLocalHost().getCanonicalHostName(), 7199); for (String arg : args) { if (arg.equals("ALL")) { nodeProbe.truncateHints(); } else { nodeProbe.truncateHints(arg); } } System.out.println("Hints truncated!"); } }
@Override public void execute(NodeProbe probe) { System.out.println( probe.isThriftServerRunning() ? "running" : "not running"); } }
@Override public void execute(NodeProbe probe) { System.out.println( probe.isNativeTransportRunning() ? "running" : "not running"); } }
@Override public void execute(NodeProbe probe) { System.out.println( probe.isGossipRunning() ? "running" : "not running"); } }
/** Clears a snapshot of the indicated key space with the given name. * * @param name The name of the snapshot. * @param keySpace The name of the key space. * @throws IOException If an error occurs clearing the snapshot. */ public void clearSnapshot(String name, String keySpace) throws IOException { getProbe().clearSnapshot(name, keySpace); }
@Override public void execute(NodeProbe probe) { System.out.println("Current compaction throughput: " + probe.getCompactionThroughput() + " MB/s"); } }
/** * Get unreachable nodes from the node's point of view (using the node's failure detection mechanism). * * @return unreachable nodes list. If no nodes are unreachable, returns the empty list. */ @Override public List<String> getUnreachableNodes() { List<String> unreachableNodes = this.nodeProbe.getUnreachableNodes(); return unreachableNodes; }
/** * Gets the list of all active compactions. * * @return compaction info list */ public List<CompactionInfo> getCompactions() { List<CompactionInfo> compactions = new ArrayList<>(); for (Map<String, String> compaction : this.nodeProbe.getCompactionManagerProxy().getCompactions()) { compactions.add(new CompactionInfo(Long.parseLong(compaction.get("total")), Long.parseLong(compaction.get("completed")), compaction.get("unit"), compaction.get("taskType"), compaction.get("keyspace"), compaction.get("columnfamily"), compaction.get("compactionId"))); } return compactions; }
CompactionManagerMBean compactionManagerMBean = (probe == null) ? null : probe.getCompactionManagerProxy(); probe.close();
boolean gossipInitialized = probe.isGossipRunning(); System.out.printf("%-23s: %s%n", "ID", probe.getLocalHostId()); System.out.printf("%-23s: %s%n", "Gossip active", gossipInitialized); System.out.printf("%-23s: %s%n", "Thrift active", probe.isThriftServerRunning()); System.out.printf("%-23s: %s%n", "Native Transport active", probe.isNativeTransportRunning()); System.out.printf("%-23s: %s%n", "Load", probe.getLoadString()); if (gossipInitialized) System.out.printf("%-23s: %s%n", "Generation No", probe.getCurrentGenerationNumber()); else System.out.printf("%-23s: %s%n", "Generation No", 0); long secondsUp = probe.getUptime() / 1000; System.out.printf("%-23s: %d%n", "Uptime (seconds)", secondsUp); MemoryUsage heapUsage = probe.getHeapMemoryUsage(); double memUsed = (double) heapUsage.getUsed() / (1024 * 1024); double memMax = (double) heapUsage.getMax() / (1024 * 1024); System.out.printf("%-23s: %s%n", "Data Center", probe.getDataCenter()); System.out.printf("%-23s: %s%n", "Rack", probe.getRack()); System.out.printf("%-23s: %s%n", "Exceptions", probe.getStorageMetric("Exceptions")); CacheServiceMBean cacheService = probe.getCacheServiceMBean(); probe.getCacheMetric("KeyCache", "Entries"), FileUtils.stringifyFileSize((long) probe.getCacheMetric("KeyCache", "Size")), FileUtils.stringifyFileSize((long) probe.getCacheMetric("KeyCache", "Capacity")),