Package org.apache.cassandra.tools

Examples of org.apache.cassandra.tools.NodeProbe


   */
  public synchronized NodeProbe getProbe(String host) {
   
    int port = Integer.parseInt(properties.getProperty("cassandra.jmx.port"));
   
    NodeProbe probe = probeMap.get(host + ":" + port);
    if (probe == null) {
      try {
        probe = new NodeProbe(host, port);
        probeMap.put(host + ":" + port, probe);
      } catch (IOException e) {
        return null;
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    } else {
      try {
        // check the connectivity
        probe.getToken();
      } catch (RuntimeException e) {
        // clean jmx if failed to get token
        probeMap.remove(host + ":" + port);
        // retry
        try {
          probe = new NodeProbe(host, port);
          probeMap.put(host + ":" + port, probe);
        } catch (Exception ee) {
          return null;
        }
      }
View Full Code Here


   */
  @SuppressWarnings({ "rawtypes", "unchecked" })
  @RequestMapping(value="/ring/", method=RequestMethod.GET)
  public void describeRing(ModelMap model) throws Exception {
   
    NodeProbe probe = clientProvider.getProbe();
    if (probe == null) {
      // TODO JMX Connection failed
      throw new RuntimeException("JMX Connection failed.");
    }
   
    List<String> liveNodes = probe.getLiveNodes();
    List<String> deadNodes = probe.getUnreachableNodes();
    List<String> joiningNodes = probe.getJoiningNodes();
    List<String> leavingNodes = probe.getLeavingNodes();
    Map<String, String> loadMap = probe.getLoadMap();
   
    Map<Token, String> endpointMap = probe.getTokenToEndpointMap();
    List<Node> nodes = new ArrayList<Node>(endpointMap.size());
    List<Token> sortedTokens = new ArrayList<Token>(endpointMap.keySet());
    Collections.sort(sortedTokens);

    for (Object token : sortedTokens) {
     
      String primaryEndpoint = endpointMap.get(token);

      Node node = new Node();
      node.address = primaryEndpoint;
      node.token = token.toString();
      node.load = loadMap.get(node.address);
      node.up =
        liveNodes.contains(primaryEndpoint) ? "up" :
        deadNodes.contains(primaryEndpoint) ? "down" :
                "?";
     
      node.state =
        joiningNodes.contains(primaryEndpoint) ? "Joining" :
        leavingNodes.contains(primaryEndpoint) ? "Leaving" :
        "Normal";
     
      if (node.load == null) {
        node.load = "?";
      }
      nodes.add(node);
     
      NodeProbe inProbe = clientProvider.getProbe(node.address);
      if (inProbe != null) {
        node.operationMode = inProbe.getOperationMode();
        node.uptime = getUptimeString(inProbe.getUptime());
        node.jmx = true;
       
        MemoryUsage memory = inProbe.getHeapMemoryUsage();
           
            node.memoryUsed = String.format("%.2f MB", (double) memory.getUsed() / (1024 * 1024));
            node.memoryMax  = String.format("%.2f MB", (double) memory.getMax() / (1024 * 1024));
            node.memoryCommited = String.format("%.2f MB", (double) memory.getCommitted() / (1024 * 1024));
      }
    }
   
    // List live nodes which are not in range.
    for (String deadAddress : deadNodes) {
      Node deadNode = new Node();
      deadNode.address = deadAddress;
      deadNode.load = loadMap.get(deadAddress);
      NodeProbe inProbe = clientProvider.getProbe(deadAddress);
      if (inProbe != null) {
        deadNode.operationMode = inProbe.getOperationMode();
        deadNode.uptime = getUptimeString(inProbe.getUptime());
      }
    }
   
    model.put("nodes", nodes);
    model.put("menu_ring", Boolean.TRUE);
View Full Code Here

  @RequestMapping(value="/ring/{address}/", method=RequestMethod.GET)
  public String describeNode(
      @PathVariable("address") String address,
      ModelMap model) {
   
    NodeProbe probe = clientProvider.getProbe(address);
   
    model.addAttribute("address", address);
    model.addAttribute("token", probe.getToken());
    model.addAttribute("mode", probe.getOperationMode());
    model.addAttribute("uptime", getUptimeString(probe.getUptime()));
   
    // Column family store
    probe.getColumnFamilyStoreMBeanProxies();
    Iterator<Entry<String, ColumnFamilyStoreMBean>> iterator = probe.getColumnFamilyStoreMBeanProxies();
   
    Map<String, Map<String, ColumnFamilyStoreMBean>> cfparent = new TreeMap<String, Map<String,ColumnFamilyStoreMBean>>();
   
    while (iterator.hasNext()) {
      Entry<String, ColumnFamilyStoreMBean> entry = iterator.next();
      String keyspace = entry.getKey();
      String columnFamily = entry.getValue().getColumnFamilyName();
     
      Map<String, ColumnFamilyStoreMBean> cfmap = cfparent.get(keyspace);
      if (cfmap == null) {
        cfmap = new TreeMap<String, ColumnFamilyStoreMBean>();
        cfparent.put(keyspace, cfmap);
      }
      cfmap.put(columnFamily, entry.getValue());
    }
   
    // Thread pool stats
    Iterator<Entry<String, JMXEnabledThreadPoolExecutorMBean>> tpIterator = probe.getThreadPoolMBeanProxies();
    Map<String, IExecutorMBean> tpMap = new TreeMap<String, IExecutorMBean>();
    while (tpIterator.hasNext()) {
      Entry<String, JMXEnabledThreadPoolExecutorMBean> entry = tpIterator.next();
      tpMap.put(entry.getKey(), entry.getValue());
    }
   
    model.addAttribute("cfparent", cfparent);
    model.addAttribute("tpmap", tpMap);
    model.addAttribute("address", address);
    model.addAttribute("menu_ring", true);
   
    // TODO not implemented yet
//    model.addAttribute("streamDestinations", probe.getStreamDestinations());
//    model.addAttribute("streamSources", probe.getStreamSources());
    model.addAttribute("currentGenerationNumber", probe.getCurrentGenerationNumber());
   
    /*
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(bout);
    probe.getCompactionThreshold(ps, null, null);
View Full Code Here

      @PathVariable("address") final String address,
      ModelMap model) throws Exception {
    cassandraService.scheduleExecution(new Runnable() {
      @Override
      public void run() {
        NodeProbe probe = clientProvider.getProbe(address);
        if (probe != null) {
          try {
            //probe.forceTableCleanup(tableName, columnFamilies);
          } catch (Exception e) {
            log.error("Failed to cleanup " + address, e);
View Full Code Here

      @PathVariable("address") final String address,
      ModelMap model) throws Exception {
    cassandraService.scheduleExecution(new Runnable() {
      @Override
      public void run() {
        NodeProbe probe = clientProvider.getProbe(address);
        if (probe != null) {
          try {
            //probe.forceTableCompaction();
          } catch (Exception e) {
            log.error("Failed force table compaction " + address, e);
View Full Code Here

      @PathVariable("address") final String address,
      ModelMap model) throws Exception {
    cassandraService.scheduleExecution(new Runnable() {
      @Override
      public void run() {
        NodeProbe probe = clientProvider.getProbe(address);
        if (probe != null) {
          try {
            probe.drain();
          } catch (Exception e) {
            log.error("Failed to drain " + address, e);
          }
        }
      }
View Full Code Here

      @PathVariable("address") final String address,
      ModelMap model) throws Exception {
    cassandraService.scheduleExecution(new Runnable() {
      @Override
      public void run() {
        NodeProbe probe = clientProvider.getProbe(address);
        if (probe != null) {
          try {
            probe.decommission();
          } catch (Exception e) {
            log.error("Failed to decomission " + address, e);
          }
        }
      }
View Full Code Here

      @RequestParam("token") final String token,
      ModelMap model) throws Exception {
    cassandraService.scheduleExecution(new Runnable() {
      @Override
      public void run() {
        NodeProbe probe = clientProvider.getProbe(address);
        if (probe != null) {
          try {
            probe.move(token);
          } catch (Exception e) {
            log.error("Failed to move " + token, e);
          }
        }
      }
View Full Code Here

      ModelMap model) throws Exception {
    final String[] columnFamilies = columnFamily.split(",");
    cassandraService.scheduleExecution(new Runnable() {
      @Override
      public void run() {
        NodeProbe probe = clientProvider.getProbe(address);
        if (probe != null) {
          try {
            probe.forceTableFlush(keyspace, columnFamilies);
          } catch (Exception e) {
            log.error("Failed to flush column families " + keyspace + ":" + columnFamilies, e);
          }
        }
      }
View Full Code Here

      ModelMap model) throws Exception {
    final String[] columnFamilies = columnFamily.split(",");
    cassandraService.scheduleExecution(new Runnable() {
      @Override
      public void run() {
        NodeProbe probe = clientProvider.getProbe(address);
        if (probe != null) {
          try {
            probe.forceTableRepair(keyspace, columnFamilies);
          } catch (Exception e) {
            log.error("Failed to repair column families " + keyspace + ":" + columnFamilies, e);
          }
        }
      }
View Full Code Here

TOP

Related Classes of org.apache.cassandra.tools.NodeProbe

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.