Package org.apache.zookeeper
Class StatsTrack
- java.lang.Object
-
- org.apache.zookeeper.StatsTrack
-
public class StatsTrack extends Object
a class that represents the stats associated with quotas
-
-
Constructor Summary
Constructors Constructor Description StatsTrack()a default constructor for statsStatsTrack(byte[] stat)StatsTrack(String stat)the stat string should be of the form key1str=long,key2str=long,..
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)longgetByteHardLimit()get the count of bytes allowed as part of quota (hard limit)longgetBytes()get the count of bytes allowed as part of quotalonggetCount()get the count of nodes allowed as part of quotalonggetCountHardLimit()get the count of nodes allowed as part of quota (hard limit)byte[]getStatsBytes()inthashCode()static booleanisValidStatsData(byte[] data)Strictly validate thatdatais a well-formed stats/limits value, i.e.voidsetByteHardLimit(long bytes)set the byte hard limitvoidsetBytes(long bytes)set the bytes for this stat tracker.voidsetCount(long count)set the count for this stat tracker.voidsetCountHardLimit(long count)set the count hard limitStringtoString()
-
-
-
Constructor Detail
-
StatsTrack
public StatsTrack()
a default constructor for stats
-
StatsTrack
public StatsTrack(byte[] stat)
- Parameters:
stat- the byte[] stat to be initialized with
-
StatsTrack
public StatsTrack(String stat)
the stat string should be of the form key1str=long,key2str=long,.. where either , or ; are valid separators uninitialized values are returned as -1- Parameters:
stat- the stat string to be initialized with
-
-
Method Detail
-
isValidStatsData
public static boolean isValidStatsData(byte[] data)
Strictly validate thatdatais a well-formed stats/limits value, i.e. a (possibly empty) list ofkey=longpairs separated by,or;. Unlike the constructor, this performs no repair — it is used at request-preparation time to reject malformed writes to the quotazookeeper_stats/zookeeper_limitsnodes before they are ever committed, so clients get a clear error and the quota bookkeeping never ingests garbage.- Parameters:
data- the candidate node data (UTF-8 encoded); empty is accepted (treated as uninitialized), null is rejected- Returns:
- true if the data parses cleanly as StatsTrack content
-
getCount
public long getCount()
get the count of nodes allowed as part of quota- Returns:
- the count as part of this string
-
setCount
public void setCount(long count)
set the count for this stat tracker.- Parameters:
count- the count to set with
-
getCountHardLimit
public long getCountHardLimit()
get the count of nodes allowed as part of quota (hard limit)- Returns:
- the count as part of this string
-
setCountHardLimit
public void setCountHardLimit(long count)
set the count hard limit- Parameters:
count- the count limit to set
-
getBytes
public long getBytes()
get the count of bytes allowed as part of quota- Returns:
- the bytes as part of this string
-
setBytes
public void setBytes(long bytes)
set the bytes for this stat tracker.- Parameters:
bytes- the bytes to set with
-
getByteHardLimit
public long getByteHardLimit()
get the count of bytes allowed as part of quota (hard limit)- Returns:
- the bytes as part of this string
-
setByteHardLimit
public void setByteHardLimit(long bytes)
set the byte hard limit- Parameters:
bytes- the byte limit to set
-
getStatsBytes
public byte[] getStatsBytes()
-
-