コード例 #1
0
ファイル: DataTree.java プロジェクト: gildafnai82/craq
 /**
  * update the count of bytes of this stat datanode
  *
  * @param lastPrefix the path of the node that is quotaed
  * @param diff the diff to added to number of bytes
  */
 public void updateBytes(String lastPrefix, long diff) {
   String statNode = Quotas.statPath(lastPrefix);
   DataNode node = nodes.get(statNode);
   StatsTrack updatedStat = null;
   synchronized (node) {
     updatedStat = new StatsTrack(new String(node.data));
     updatedStat.setBytes(updatedStat.getBytes() + diff);
     node.data = updatedStat.toString().getBytes();
   }
   // now check if the bytes match the quota
   String quotaNode = Quotas.quotaPath(lastPrefix);
   node = nodes.get(quotaNode);
   StatsTrack thisStats = null;
   synchronized (node) {
     thisStats = new StatsTrack(new String(node.data));
   }
   if (thisStats.getBytes() < updatedStat.getBytes()) {
     LOG.warn(
         "Quota exceeded: "
             + lastPrefix
             + " bytes="
             + updatedStat.getBytes()
             + " limit="
             + thisStats.getBytes());
   }
 }
コード例 #2
0
ファイル: DataTree.java プロジェクト: gildafnai82/craq
 /**
  * update the quota for the given path
  *
  * @param path the path to be used
  */
 private void updateQuotaForPath(String path) {
   Counts c = new Counts();
   getCounts(path, c);
   StatsTrack strack = new StatsTrack();
   strack.setBytes(c.bytes);
   strack.setCount(c.count);
   String statPath = Quotas.quotaZookeeper + path + "/" + Quotas.statNode;
   DataNode node = getNode(statPath);
   // it should exist
   if (node == null) {
     LOG.warn("Missing quota stat node " + statPath);
     return;
   }
   synchronized (node) {
     node.data = strack.toString().getBytes();
   }
 }