List of usage examples for org.apache.zookeeper StatsTrack getCount
public int getCount()
From source file:com.github.mosuka.zookeeper.nicli.command.ListQuotaCommand.java
License:Apache License
@Override public void run(Map<String, Object> parameters) { String path = null;//from w ww . j a va2 s. co m try { path = (String) parameters.get("path"); String quotaPath = Quotas.quotaZookeeper + path + "/" + Quotas.limitNode; String statPath = Quotas.quotaZookeeper + path + "/" + Quotas.statNode; ZooKeeper zk = getZookeeperConnection().getZooKeeper(); Stat quotaStat = new Stat(); byte[] quotaData = zk.getData(quotaPath, false, quotaStat); StatsTrack quotaStatsTrack = new StatsTrack(new String(quotaData)); Map<String, Object> quotaMap = new LinkedHashMap<String, Object>(); quotaMap.put("path", quotaPath); quotaMap.put("count", quotaStatsTrack.getCount()); quotaMap.put("bytes", quotaStatsTrack.getBytes()); putResponse("quota", quotaMap); Stat statStat = new Stat(); byte[] statData = zk.getData(statPath, false, statStat); StatsTrack statStatsTrack = new StatsTrack(new String(statData)); Map<String, Object> statMap = new LinkedHashMap<String, Object>(); statMap.put("path", statPath); statMap.put("count", statStatsTrack.getCount()); statMap.put("bytes", statStatsTrack.getBytes()); putResponse("stat", statMap); setStatus(Command.STATUS_SUCCESS); setMessage(Command.SUCCESS_MESSAGE); } catch (KeeperException e) { setStatus(Command.STATUS_ERROR); setMessage("quota for " + path + " does not exist."); } catch (InterruptedException e) { setStatus(Command.STATUS_ERROR); setMessage(e.getMessage()); } catch (ClassCastException e) { setStatus(Command.STATUS_ERROR); setMessage(e.getMessage()); } catch (NullPointerException e) { setStatus(Command.STATUS_ERROR); setMessage(e.getMessage()); } }