net.opentsdb.tree
public final class TreeRule extends Object
Modifier and Type | Class and Description |
---|---|
static class |
TreeRule.TreeRuleType
Types of tree rules
|
Constructor and Description |
---|
TreeRule()
Default constructor necessary for de/serialization
|
TreeRule(int tree_id)
Constructor initializes the tree ID
|
TreeRule(TreeRule original)
Copy constructor that creates a completely independent copy of the original
object
|
Modifier and Type | Method and Description |
---|---|
boolean |
copyChanges(TreeRule rule,
boolean overwrite)
Copies changed fields from the incoming rule to the local rule
|
static com.stumbleupon.async.Deferred<Object> |
deleteAllRules(TSDB tsdb,
int tree_id)
Attempts to delete all rules belonging to the given tree.
|
static com.stumbleupon.async.Deferred<Object> |
deleteRule(TSDB tsdb,
int tree_id,
int level,
int order)
Attempts to delete the specified rule from storage
|
static com.stumbleupon.async.Deferred<TreeRule> |
fetchRule(TSDB tsdb,
int tree_id,
int level,
int order)
Attempts to retrieve the specified tree rule from storage.
|
Pattern |
getCompiledRegex() |
String |
getCustomField() |
String |
getDescription() |
String |
getDisplayFormat() |
String |
getField() |
int |
getLevel() |
String |
getNotes() |
int |
getOrder() |
static byte[] |
getQualifier(int level,
int order)
Completes the column qualifier given a level and order using the configured
prefix
|
String |
getRegex() |
int |
getRegexGroupIdx() |
String |
getSeparator() |
int |
getTreeId() |
TreeRule.TreeRuleType |
getType() |
static TreeRule |
parseFromStorage(org.hbase.async.KeyValue column)
Parses a rule from the given column.
|
static byte[] |
RULE_PREFIX() |
void |
setCustomField(String custom_field) |
void |
setDescription(String description) |
void |
setDisplayFormat(String display_format) |
void |
setField(String field) |
void |
setLevel(int level) |
void |
setNotes(String notes) |
void |
setOrder(int order) |
void |
setRegex(String regex) |
void |
setRegexGroupIdx(int regex_group_idx) |
void |
setSeparator(String separator) |
void |
setTreeId(int tree_id) |
void |
setType(TreeRule.TreeRuleType type) |
static TreeRule.TreeRuleType |
stringToType(String type)
Parses a string into a rule type enumerator
|
com.stumbleupon.async.Deferred<Boolean> |
syncToStorage(TSDB tsdb,
boolean overwrite)
Attempts to write the rule to storage via CompareAndSet, merging changes
with an existing rule.
|
String |
toString() |
public TreeRule()
public TreeRule(int tree_id)
tree_id
- The tree this rule belongs topublic TreeRule(TreeRule original)
original
- The original object to copy fromPatternSyntaxException
- if the regex is invalidpublic boolean copyChanges(TreeRule rule, boolean overwrite)
rule
- The rule to copy fromoverwrite
- Whether or not to replace all fields in the local objectpublic String toString()
public com.stumbleupon.async.Deferred<Boolean> syncToStorage(TSDB tsdb, boolean overwrite)
tsdb
- The TSDB to use for storage accessoverwrite
- When the RPC method is PUT, will overwrite all user
accessible fieldsorg.hbase.async.HBaseException
- if there was an issueIllegalArgumentException
- if parsing failed or the tree ID was
invalid or validation failedIllegalStateException
- if the data hasn't changed. This is OK!JSONException
- if the object could not be serializedpublic static TreeRule parseFromStorage(org.hbase.async.KeyValue column)
column
- The column to parseIllegalArgumentException
- if the column was emptyJSONException
- if the object could not be serializedpublic static com.stumbleupon.async.Deferred<TreeRule> fetchRule(TSDB tsdb, int tree_id, int level, int order)
tsdb
- The TSDB to use for storage accesstree_id
- ID of the tree the rule belongs tolevel
- Level where the rule residesorder
- Order where the rule residesorg.hbase.async.HBaseException
- if there was an issueIllegalArgumentException
- if the one of the required parameters was
missingJSONException
- if the object could not be serializedpublic static com.stumbleupon.async.Deferred<Object> deleteRule(TSDB tsdb, int tree_id, int level, int order)
tsdb
- The TSDB to use for storage accesstree_id
- ID of the tree the rule belongs tolevel
- Level where the rule residesorder
- Order where the rule residesorg.hbase.async.HBaseException
- if there was an issueIllegalArgumentException
- if the one of the required parameters was
missingpublic static com.stumbleupon.async.Deferred<Object> deleteAllRules(TSDB tsdb, int tree_id)
tsdb
- The TSDB to use for storage accesstree_id
- ID of the tree the rules belongs toorg.hbase.async.HBaseException
- if there was an issueIllegalArgumentException
- if the one of the required parameters was
missingpublic static TreeRule.TreeRuleType stringToType(String type)
type
- The string to parseIllegalArgumentException
- if the type was empty or invalidpublic static byte[] RULE_PREFIX()
public static byte[] getQualifier(int level, int order)
level
- The level of the ruleorder
- The order of the rulepublic TreeRule.TreeRuleType getType()
public String getField()
public String getCustomField()
public String getRegex()
public String getSeparator()
public String getDescription()
public String getNotes()
public int getRegexGroupIdx()
public String getDisplayFormat()
public int getLevel()
public int getOrder()
public int getTreeId()
public Pattern getCompiledRegex()
public void setType(TreeRule.TreeRuleType type)
type
- The type of rulepublic void setField(String field)
field
- The field name for matchingpublic void setCustomField(String custom_field)
custom_field
- The custom field name to set if matchingpublic void setRegex(String regex)
regex
- Stores AND compiles the regex string for use in processingPatternSyntaxException
- if the regex is invalidpublic void setSeparator(String separator)
separator
- A character or string to separate onpublic void setDescription(String description)
description
- A brief description of the rulepublic void setNotes(String notes)
notes
- Optional detailed notes about the rulepublic void setRegexGroupIdx(int regex_group_idx)
regex_group_idx
- An optional index (start at 0) to use for regex
group extraction. Must be a positive value.public void setDisplayFormat(String display_format)
display_format
- Optional format string to alter the display namepublic void setLevel(int level)
level
- The top level processing order. Must be 0 or greaterIllegalArgumentException
- if the level was negativepublic void setOrder(int order)
order
- The order of processing within a level.
Must be 0 or greaterIllegalArgumentException
- if the order was negativepublic void setTreeId(int tree_id)
tree_id
- The tree_id to set