Search in sources :

Example 1 with StatsTrack

use of org.apache.zookeeper_voltpatches.StatsTrack in project voltdb by VoltDB.

the class DataTree method updateBytes.

/**
     * 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
     * @throws IOException
     *             if path is not found
     */
public void updateBytes(String lastPrefix, long diff) {
    String statNode = Quotas.statPath(lastPrefix);
    DataNode node = nodes.get(statNode);
    if (node == null) {
        // should never be null but just to make
        // findbugs happy
        LOG.error("Missing stat node for bytes " + statNode);
        return;
    }
    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);
    if (node == null) {
        // should never be null but just to make
        // findbugs happy
        LOG.error("Missing quota node for bytes " + quotaNode);
        return;
    }
    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());
    }
}
Also used : StatsTrack(org.apache.zookeeper_voltpatches.StatsTrack) DataNode(org.apache.zookeeper_voltpatches.server.DataNode)

Example 2 with StatsTrack

use of org.apache.zookeeper_voltpatches.StatsTrack in project voltdb by VoltDB.

the class DataTree method updateQuotaForPath.

/**
     * 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();
    }
}
Also used : StatsTrack(org.apache.zookeeper_voltpatches.StatsTrack) DataNode(org.apache.zookeeper_voltpatches.server.DataNode)

Example 3 with StatsTrack

use of org.apache.zookeeper_voltpatches.StatsTrack in project voltdb by VoltDB.

the class DataTree method updateCount.

/**
     * update the count of this stat datanode
     *
     * @param lastPrefix
     *            the path of the node that is quotaed.
     * @param diff
     *            the diff to be added to the count
     */
public void updateCount(String lastPrefix, int diff) {
    String statNode = Quotas.statPath(lastPrefix);
    DataNode node = nodes.get(statNode);
    StatsTrack updatedStat = null;
    if (node == null) {
        // should not happen
        LOG.error("Missing count node for stat " + statNode);
        return;
    }
    synchronized (node) {
        updatedStat = new StatsTrack(new String(node.data));
        updatedStat.setCount(updatedStat.getCount() + diff);
        node.data = updatedStat.toString().getBytes();
    }
    // now check if the counts match the quota
    String quotaNode = Quotas.quotaPath(lastPrefix);
    node = nodes.get(quotaNode);
    StatsTrack thisStats = null;
    if (node == null) {
        // should not happen
        LOG.error("Missing count node for quota " + quotaNode);
        return;
    }
    synchronized (node) {
        thisStats = new StatsTrack(new String(node.data));
    }
    if (thisStats.getCount() < updatedStat.getCount()) {
        LOG.warn("Quota exceeded: " + lastPrefix + " count=" + updatedStat.getCount() + " limit=" + thisStats.getCount());
    }
}
Also used : StatsTrack(org.apache.zookeeper_voltpatches.StatsTrack) DataNode(org.apache.zookeeper_voltpatches.server.DataNode)

Aggregations

StatsTrack (org.apache.zookeeper_voltpatches.StatsTrack)3 DataNode (org.apache.zookeeper_voltpatches.server.DataNode)3