public static Deferred < TreeRule > fetchRule ( final TSDB tsdb , final int tree_id , final int level , final int order ) { if ( tree_id < 1 || tree_id > 65535 ) { throw new IllegalArgumentException ( "Invalid Tree ID" ) ; } if ( level < 0 ) { throw new IllegalArgumentException ( "Invalid rule level" ) ; } if ( order < 0 ) { throw new IllegalArgumentException ( "Invalid rule order" ) ; } // fetch the whole row final GetRequest get = new GetRequest ( tsdb . treeTable ( ) , Tree . idToBytes ( tree_id ) ) ; get . family ( Tree . TREE_FAMILY ( ) ) ; get . qualifier ( getQualifier ( level , order ) ) ; /** * Called after fetching to parse the results */ final class FetchCB implements Callback < Deferred < TreeRule > , ArrayList < KeyValue > > { @ Override public Deferred < TreeRule > call ( final ArrayList < KeyValue > row ) { if ( row == null || row . isEmpty ( ) ) { return Deferred . fromResult ( null ) ; } return Deferred . fromResult ( parseFromStorage ( row . get ( 0 ) ) ) ; } } return tsdb . getClient ( ) . get ( get ) . addCallbackDeferring ( new FetchCB ( ) ) ; }
Attempts to retrieve the specified tree rule from storage .