net.opentsdb.tree
public final class TreeBuilder extends Object
processTimeseriesMeta(net.opentsdb.meta.TSMeta)
with a TSMeta
object.
When processing, the builder runs the meta data through each of the rules in
the rule set and recursively builds a tree. After running through all of the
rules, if valid results were obtained, each branch is saved to storage if
they haven't been processed before (in the processed_branches
map).
If a leaf was found, it will be saved. If any collisions or not-matched
reports occurred, they will be saved to storage.
If processTimeseriesMeta(net.opentsdb.meta.TSMeta)
is called with the testing flag, the
tree will be built but none of the branches will be stored. This is used for
RPC calls to display the results to a user and test_messages
will
contain a detailed description of the processing results.
Warning: This class is not thread safe. It should only be used by a single thread to process a TSMeta at a time. If processing multiple TSMetas you can create the builder and run all of the meta objects through the process methods.
Constructor and Description |
---|
TreeBuilder(TSDB tsdb,
Tree tree)
Constructor to initialize the builder.
|
Modifier and Type | Method and Description |
---|---|
Branch |
getRootBranch() |
ArrayList<String> |
getTestMessage() |
Tree |
getTree() |
static com.stumbleupon.async.Deferred<Branch> |
loadOrInitializeRoot(TSDB tsdb,
int tree_id,
boolean is_testing)
Attempts to retrieve or initialize the root branch for the configured tree.
|
static com.stumbleupon.async.Deferred<Boolean> |
processAllTrees(TSDB tsdb,
TSMeta meta)
Attempts to run the given TSMeta object through all of the trees in the
system.
|
com.stumbleupon.async.Deferred<ArrayList<Boolean>> |
processTimeseriesMeta(TSMeta meta)
Convenience overload of
processTimeseriesMeta(TSMeta, boolean) that
sets the testing flag to false. |
com.stumbleupon.async.Deferred<ArrayList<Boolean>> |
processTimeseriesMeta(TSMeta meta,
boolean is_testing)
Runs the TSMeta object through the
Tree s rule set, optionally
storing the resulting branches, leaves and meta data. |
void |
setTree(Tree tree) |
public TreeBuilder(TSDB tsdb, Tree tree)
max_rule_level
based on the tree's rulestsdb
- The TSDB to use for accesstree
- A tree with rules configured and ready for parsingpublic com.stumbleupon.async.Deferred<ArrayList<Boolean>> processTimeseriesMeta(TSMeta meta)
processTimeseriesMeta(TSMeta, boolean)
that
sets the testing flag to false. Any changes processed from this method will
be saved to storagemeta
- The timeseries meta object to processIllegalArgumentException
- if the tree has not been set or is invalidpublic com.stumbleupon.async.Deferred<ArrayList<Boolean>> processTimeseriesMeta(TSMeta meta, boolean is_testing)
Tree
s rule set, optionally
storing the resulting branches, leaves and meta data.
If the testing flag is set, no results will be saved but the caller can
fetch the root branch from this object as it will contain the tree that
would result from the processing. Also, the test_messages
list
will contain details about the process for debugging purposes.meta
- The timeseries meta object to processis_testing
- Whether or not changes should be written to storage. If
false, resulting branches and leaves will be saved. If true, results will
not be flushed to storage.IllegalArgumentException
- if the tree has not been set or is invalidorg.hbase.async.HBaseException
- if a storage exception occurredpublic static com.stumbleupon.async.Deferred<Branch> loadOrInitializeRoot(TSDB tsdb, int tree_id, boolean is_testing)
tsdb
- The tsdb to use for storage callstree_id
- ID of the tree the root should be fetched/initialized foris_testing
- Whether or not the root should be written to storage if
initialized.public static com.stumbleupon.async.Deferred<Boolean> processAllTrees(TSDB tsdb, TSMeta meta)
tsdb
- The TSDB to use for accessmeta
- The timeseries meta object to processIllegalArgumentException
- if the tree has not been set or is invalidorg.hbase.async.HBaseException
- if a storage exception occurredpublic Tree getTree()
public Branch getRootBranch()
public void setTree(Tree tree)
tree
- The tree to store locally