idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
7,200
private static String formatStatName ( final String stat ) { if ( stat == null || stat . isEmpty ( ) ) { return stat ; } String name = stat . replace ( " " , "" ) ; return name . substring ( 0 , 1 ) . toLowerCase ( ) + name . substring ( 1 ) ; }
Little helper to convert the first character to lowercase and remove any spaces
7,201
private void printQueryStats ( final HttpQuery query ) { switch ( query . apiVersion ( ) ) { case 0 : case 1 : query . sendReply ( query . serializer ( ) . formatQueryStatsV1 ( QueryStats . getRunningAndCompleteStats ( ) ) ) ; break ; default : throw new BadRequestException ( HttpResponseStatus . NOT_IMPLEMENTED , "Req...
Print the detailed query stats to the caller using the proper serializer
7,202
private void dropCaches ( final TSDB tsdb , final Channel chan ) { LOG . warn ( chan + " Dropping all in-memory caches." ) ; tsdb . dropCaches ( ) ; }
Drops in memory caches .
7,203
public Deferred < Boolean > allowHistogramPoint ( final String metric , final long timestamp , final byte [ ] value , final Map < String , String > tags ) { throw new UnsupportedOperationException ( "Not yet implemented." ) ; }
Determine whether or not the data point should be stored . If the data should not be stored the implementation can return false or an exception in the deferred object . Otherwise it should return true and the data point will be written to storage .
7,204
public static TagVFilter getFilter ( final String tagk , final String filter ) { if ( tagk == null || tagk . isEmpty ( ) ) { throw new IllegalArgumentException ( "Tagk cannot be null or empty" ) ; } if ( filter == null || filter . isEmpty ( ) ) { throw new IllegalArgumentException ( "Filter cannot be null or empty" ) ;...
Parses the tag value and determines if it s a group by a literal or a filter .
7,205
public static void initializeFilterMap ( final TSDB tsdb ) throws ClassNotFoundException , NoSuchMethodException , NoSuchFieldException , IllegalArgumentException , SecurityException , IllegalAccessException , InvocationTargetException { final List < TagVFilter > filter_plugins = PluginLoader . loadPlugins ( TagVFilter...
Loads plugins from the plugin directory and loads them into the map . Built - in filters don t need to go through this process .
7,206
public static void tagsToFilters ( final Map < String , String > tags , final List < TagVFilter > filters ) { mapToFilters ( tags , filters , true ) ; }
Converts the tag map to a filter list . If a filter already exists for a tag group by then the duplicate is skipped .
7,207
public static void mapToFilters ( final Map < String , String > map , final List < TagVFilter > filters , final boolean group_by ) { if ( map == null || map . isEmpty ( ) ) { return ; } for ( final Map . Entry < String , String > entry : map . entrySet ( ) ) { TagVFilter filter = getFilter ( entry . getKey ( ) , entry ...
Converts the map to a filter list . If a filter already exists for a tag group by and we re told to process group bys then the duplicate is skipped .
7,208
public static Map < String , Map < String , String > > loadedFilters ( ) { final Map < String , Map < String , String > > filters = new HashMap < String , Map < String , String > > ( tagv_filter_map . size ( ) ) ; for ( final Pair < Class < ? > , Constructor < ? extends TagVFilter > > pair : tagv_filter_map . values ( ...
Runs through the loaded plugin map and dumps the names description and examples into a map to serialize via the API .
7,209
public void runQueries ( final List < Query > queries ) throws Exception { final long start_time = System . currentTimeMillis ( ) / 1000 ; final Thread reporter = new ProgressReporter ( ) ; reporter . start ( ) ; for ( final Query query : queries ) { final List < Scanner > scanners = Internal . getScanners ( query ) ; ...
Scans the rows matching one or more standard queries . An aggregator is still required though it s ignored .
7,210
private static void usage ( final ArgP argp , final String errmsg , final int retval ) { System . err . println ( errmsg ) ; System . err . println ( "Usage: fsck" + " [flags] [START-DATE [END-DATE] query [queries...]] \n" + "Scans the OpenTSDB data table for errors. Use the --full-scan flag\n" + "to scan the entire da...
Prints usage and exits with the given retval .
7,211
private void logResults ( ) { LOG . info ( "Key Values Processed: " + kvs_processed . get ( ) ) ; LOG . info ( "Rows Processed: " + rows_processed . get ( ) ) ; LOG . info ( "Valid Datapoints: " + valid_datapoints . get ( ) ) ; LOG . info ( "Annotations: " + annotations . get ( ) ) ; LOG . info ( "Invalid Row Keys Foun...
Helper to dump the atomic counters to the log after a completed FSCK
7,212
public static void main ( String [ ] args ) throws Exception { ArgP argp = new ArgP ( ) ; argp . addOption ( "--help" , "Print help information." ) ; CliOptions . addCommon ( argp ) ; FsckOptions . addDataOptions ( argp ) ; args = CliOptions . parse ( argp , args ) ; if ( argp . has ( "--help" ) ) { usage ( argp , "" ,...
The main class executed from the tsdb script
7,213
public Deferred < byte [ ] > resolveTagkName ( final TSDB tsdb ) { final Config config = tsdb . getConfig ( ) ; if ( ! case_insensitive && literals . size ( ) <= config . getInt ( "tsd.query.filter.expansion_limit" ) ) { return resolveTags ( tsdb , literals ) ; } else { return super . resolveTagkName ( tsdb ) ; } }
Overridden here so that we can resolve the literal values if we don t have too many of them AND we re not searching with case insensitivity .
7,214
public static void installMyGnuPlot ( ) { if ( ! FOUND_GP ) { LOG . warn ( "Skipping Gnuplot Shell Script Install since Gnuplot executable was not found" ) ; return ; } if ( ! GP_FILE . exists ( ) ) { if ( ! GP_FILE . getParentFile ( ) . exists ( ) ) { GP_FILE . getParentFile ( ) . mkdirs ( ) ; } InputStream is = null ...
Installs the mygnuplot shell file
7,215
public boolean validate ( final List < Map < String , Object > > details ) { if ( this . getMetric ( ) == null || this . getMetric ( ) . isEmpty ( ) ) { if ( details != null ) { details . add ( getHttpDetails ( "Metric name was empty" ) ) ; } LOG . warn ( "Metric name was empty: " + this ) ; return false ; } if ( this ...
Pre - validation of the various fields to make sure they re valid
7,216
protected final Map < String , Object > getHttpDetails ( final String message ) { final Map < String , Object > map = new HashMap < String , Object > ( ) ; map . put ( "error" , message ) ; map . put ( "datapoint" , this ) ; return map ; }
Creates a map with an error message and this data point to return to the HTTP put data point RPC handler
7,217
final void printAsciiBucket ( final StringBuilder out , final int i ) { out . append ( '[' ) . append ( bucketLowInterval ( i ) ) . append ( '-' ) . append ( i == buckets . length - 1 ? "Inf" : bucketHighInterval ( i ) ) . append ( "): " ) . append ( buckets [ i ] ) . append ( '\n' ) ; }
Prints a bucket of this histogram in a human readable ASCII format .
7,218
private int bucketIndexFor ( final int value ) { if ( value < cutoff ) { return value / interval ; } int bucket = num_linear_buckets + log2rounddown ( ( value - cutoff ) >> exp_bucket_shift ) ; if ( bucket >= buckets . length ) { return buckets . length - 1 ; } return bucket ; }
Finds the index of the bucket in which the given value should be .
7,219
private void setupEmitters ( ) { for ( int i = 0 ; i < dps . length ; i ++ ) { iterators [ i ] = dps [ i ] . iterator ( ) ; if ( ! iterators [ i ] . hasNext ( ) ) { current_values [ i ] = null ; emitter_values [ i ] = null ; } else { current_values [ i ] = iterators [ i ] . next ( ) ; emitter_values [ i ] = new Express...
Iterates over the values and sets up the current and emitter values
7,220
< T extends Validatable > void validateCollection ( final Collection < T > collection , final String name ) { Iterator < T > iterator = collection . iterator ( ) ; int i = 0 ; while ( iterator . hasNext ( ) ) { try { iterator . next ( ) . validate ( ) ; } catch ( final IllegalArgumentException e ) { throw new IllegalAr...
Iterate through a field that is a collection of POJOs and validate each of them . Inherit member POJO s error message .
7,221
< T extends Validatable > void validatePOJO ( final T pojo , final String name ) { try { pojo . validate ( ) ; } catch ( final IllegalArgumentException e ) { throw new IllegalArgumentException ( "Invalid " + name , e ) ; } }
Validate a single POJO validate
7,222
public Deferred < ArrayList < Object > > shutdown ( ) { INSTANCE . set ( null ) ; final Collection < Deferred < Object > > deferreds = Lists . newArrayList ( ) ; if ( http_plugin_commands != null ) { for ( final Map . Entry < String , HttpRpcPlugin > entry : http_plugin_commands . entrySet ( ) ) { deferreds . add ( ent...
Called to gracefully shutdown the plugin . Implementations should close any IO they have open
7,223
private void handleTelnetRpc ( final Channel chan , final String [ ] command ) { TelnetRpc rpc = rpc_manager . lookupTelnetRpc ( command [ 0 ] ) ; if ( rpc == null ) { rpc = unknown_cmd ; } telnet_rpcs_received . incrementAndGet ( ) ; rpc . execute ( tsdb , chan , command ) ; }
Finds the right handler for a telnet - style RPC and executes it .
7,224
private AbstractHttpQuery createQueryInstance ( final TSDB tsdb , final HttpRequest request , final Channel chan ) throws BadRequestException { final String uri = request . getUri ( ) ; if ( Strings . isNullOrEmpty ( uri ) ) { throw new BadRequestException ( "Request URI is empty" ) ; } else if ( uri . charAt ( 0 ) != ...
Using the request URI creates a query instance capable of handling the given request .
7,225
private boolean applyCorsConfig ( final HttpRequest req , final AbstractHttpQuery query ) throws BadRequestException { final String domain = req . headers ( ) . get ( "Origin" ) ; if ( query . method ( ) == HttpMethod . OPTIONS || ( cors_domains != null && domain != null && ! domain . isEmpty ( ) ) ) { if ( cors_domain...
Helper method to apply CORS configuration to a request either a built - in RPC or a user plugin .
7,226
static String getDirectoryFromSystemProp ( final String prop ) { final String dir = System . getProperty ( prop ) ; String err = null ; if ( dir == null ) { err = "' is not set." ; } else if ( dir . isEmpty ( ) ) { err = "' is empty." ; } else if ( dir . charAt ( dir . length ( ) - 1 ) != '/' ) { err = "' is not termin...
Returns the directory path stored in the given system property .
7,227
public boolean addChild ( final Branch branch ) { if ( branch == null ) { throw new IllegalArgumentException ( "Null branches are not allowed" ) ; } if ( branches == null ) { branches = new TreeSet < Branch > ( ) ; branches . add ( branch ) ; return true ; } if ( branches . contains ( branch ) ) { return false ; } bran...
Adds a child branch to the local branch set if it doesn t exist . Also initializes the set if it hasn t been initialized yet
7,228
public boolean addLeaf ( final Leaf leaf , final Tree tree ) { if ( leaf == null ) { throw new IllegalArgumentException ( "Null leaves are not allowed" ) ; } if ( leaves == null ) { leaves = new HashMap < Integer , Leaf > ( ) ; leaves . put ( leaf . hashCode ( ) , leaf ) ; return true ; } if ( leaves . containsKey ( le...
Adds a leaf to the local branch looking for collisions
7,229
public Deferred < ArrayList < Boolean > > storeBranch ( final TSDB tsdb , final Tree tree , final boolean store_leaves ) { if ( tree_id < 1 || tree_id > 65535 ) { throw new IllegalArgumentException ( "Missing or invalid tree ID" ) ; } final ArrayList < Deferred < Boolean > > storage_results = new ArrayList < Deferred <...
Attempts to write the branch definition and optionally child leaves to storage via CompareAndSets . Each returned deferred will be a boolean regarding whether the CAS call was successful or not . This will be a mix of the branch call and leaves . Some of these may be false which is OK because if the branch definition a...
7,230
private static Scanner setupBranchScanner ( final TSDB tsdb , final byte [ ] branch_id ) { final byte [ ] start = branch_id ; final byte [ ] end = Arrays . copyOf ( branch_id , branch_id . length ) ; final Scanner scanner = tsdb . getClient ( ) . newScanner ( tsdb . treeTable ( ) ) ; scanner . setStartKey ( start ) ; b...
Configures an HBase scanner to fetch the requested branch and all child branches . It uses a row key regex filter to match any rows starting with the given branch and another INT_WIDTH bytes deep . Deeper branches are ignored .
7,231
public int purgeTree ( final int tree_id , final boolean delete_definition ) throws Exception { if ( delete_definition ) { LOG . info ( "Deleting tree branches and definition for: " + tree_id ) ; } else { LOG . info ( "Deleting tree branches for: " + tree_id ) ; } Tree . deleteTree ( tsdb , tree_id , delete_definition ...
Attempts to delete all data generated by the given tree and optionally the tree definition itself .
7,232
private Scanner getScanner ( ) throws HBaseException { final short metric_width = TSDB . metrics_width ( ) ; final byte [ ] start_row = Arrays . copyOfRange ( Bytes . fromLong ( start_id ) , 8 - metric_width , 8 ) ; final byte [ ] end_row = Arrays . copyOfRange ( Bytes . fromLong ( end_id ) , 8 - metric_width , 8 ) ; L...
Returns a scanner set to scan the range configured for this thread
7,233
public RollupInterval getRollupInterval ( final String interval ) { if ( interval == null || interval . isEmpty ( ) ) { throw new IllegalArgumentException ( "Interval cannot be null or empty" ) ; } final RollupInterval rollup = forward_intervals . get ( interval ) ; if ( rollup == null ) { throw new NoSuchRollupForInte...
Fetches the RollupInterval corresponding to the forward interval string map
7,234
public List < RollupInterval > getRollupInterval ( final long interval , final String str_interval ) { if ( interval <= 0 ) { throw new IllegalArgumentException ( "Interval cannot be null or empty" ) ; } final Map < Long , RollupInterval > rollups = new TreeMap < Long , RollupInterval > ( Collections . reverseOrder ( )...
Fetches the RollupInterval corresponding to the integer interval in seconds . It returns a list of matching RollupInterval and best next matches in the order . It will help to search on the next best rollup tables . It is guaranteed that it return a non - empty list For example if the interval is 1 day then it may retu...
7,235
public RollupInterval getRollupIntervalForTable ( final String table ) { if ( table == null || table . isEmpty ( ) ) { throw new IllegalArgumentException ( "The table name cannot be null or empty" ) ; } final RollupInterval rollup = reverse_intervals . get ( table ) ; if ( rollup == null ) { throw new NoSuchRollupForTa...
Fetches the RollupInterval corresponding to the rollup or pre - agg table name .
7,236
public void ensureTablesExist ( final TSDB tsdb ) { final List < Deferred < Object > > deferreds = new ArrayList < Deferred < Object > > ( forward_intervals . size ( ) * 2 ) ; for ( RollupInterval interval : forward_intervals . values ( ) ) { deferreds . add ( tsdb . getClient ( ) . ensureTableExists ( interval . getTe...
Makes sure each of the rollup tables exists
7,237
public static void checkDirectory ( final String dir , final boolean need_write , final boolean create ) { if ( dir . isEmpty ( ) ) throw new IllegalArgumentException ( "Directory path is empty" ) ; final File f = new File ( dir ) ; if ( ! f . exists ( ) && ! ( create && f . mkdirs ( ) ) ) { throw new IllegalArgumentEx...
Verifies a directory and checks to see if it s writeable or not if configured
7,238
@ SuppressWarnings ( "unchecked" ) public static final < T > T parseToObject ( final String json , final TypeReference < T > type ) { if ( json == null || json . isEmpty ( ) ) throw new IllegalArgumentException ( "Incoming data was null or empty" ) ; if ( type == null ) throw new IllegalArgumentException ( "Missing typ...
Deserializes a JSON formatted string to a specific class type
7,239
public static final String serializeToString ( final Object object ) { if ( object == null ) throw new IllegalArgumentException ( "Object was null" ) ; try { return jsonMapper . writeValueAsString ( object ) ; } catch ( JsonProcessingException e ) { throw new JSONException ( e ) ; } }
Serializes the given object to a JSON string
7,240
public static final byte [ ] serializeToBytes ( final Object object ) { if ( object == null ) throw new IllegalArgumentException ( "Object was null" ) ; try { return jsonMapper . writeValueAsBytes ( object ) ; } catch ( JsonProcessingException e ) { throw new JSONException ( e ) ; } }
Serializes the given object to a JSON byte array
7,241
public void compile ( ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Compiling " + this ) ; } if ( results . size ( ) < 1 ) { throw new IllegalArgumentException ( "No results for any variables in " + "the expression: " + this ) ; } if ( results . size ( ) < names . size ( ) ) { throw new IllegalArgumentException ...
Builds the iterator by computing the intersection of all series in all sets and sets up the output .
7,242
public static void loadJAR ( String jar ) throws IOException , SecurityException , IllegalArgumentException , NoSuchMethodException , IllegalAccessException , InvocationTargetException { if ( ! jar . toLowerCase ( ) . endsWith ( ".jar" ) ) { throw new IllegalArgumentException ( "File specified did not end with .jar" ) ...
Attempts to load the given jar into the class path
7,243
private static void searchForJars ( final File file , List < File > jars ) { if ( file . isFile ( ) ) { if ( file . getAbsolutePath ( ) . toLowerCase ( ) . endsWith ( ".jar" ) ) { jars . add ( file ) ; LOG . debug ( "Found a jar: " + file . getAbsolutePath ( ) ) ; } } else if ( file . isDirectory ( ) ) { File [ ] files...
Recursive method to search for JAR files starting at a given level
7,244
private static void addFile ( File f ) throws IOException , SecurityException , IllegalArgumentException , NoSuchMethodException , IllegalAccessException , InvocationTargetException { addURL ( f . toURI ( ) . toURL ( ) ) ; }
Attempts to add the given file object to the class loader
7,245
private DataPoints scale ( final DataPoints points , final double scale_factor ) { final List < DataPoint > dps = new ArrayList < DataPoint > ( ) ; final boolean scale_is_int = ( scale_factor == Math . floor ( scale_factor ) ) && ! Double . isInfinite ( scale_factor ) ; final SeekableView view = points . iterator ( ) ;...
Multiplies each data point in the series by the scale factor maintaining integers if both the data point and scale are integers .
7,246
public HashMap < String , String > parseSuggestV1 ( ) { final String json = query . getContent ( ) ; if ( json == null || json . isEmpty ( ) ) { throw new BadRequestException ( HttpResponseStatus . BAD_REQUEST , "Missing message content" , "Supply valid JSON formatted data in the body of your request" ) ; } try { retur...
Parses a suggestion query
7,247
public HashMap < String , String > parseUidRenameV1 ( ) { final String json = query . getContent ( ) ; if ( json == null || json . isEmpty ( ) ) { throw new BadRequestException ( HttpResponseStatus . BAD_REQUEST , "Missing message content" , "Supply valid JSON formatted data in the body of your request" ) ; } try { ret...
Parses metric tagk or tagv and name to rename UID
7,248
public TSQuery parseQueryV1 ( ) { final String json = query . getContent ( ) ; if ( json == null || json . isEmpty ( ) ) { throw new BadRequestException ( HttpResponseStatus . BAD_REQUEST , "Missing message content" , "Supply valid JSON formatted data in the body of your request" ) ; } try { TSQuery data_query = JSON ....
Parses a timeseries data query
7,249
public LastPointQuery parseLastPointQueryV1 ( ) { final String json = query . getContent ( ) ; if ( json == null || json . isEmpty ( ) ) { throw new BadRequestException ( HttpResponseStatus . BAD_REQUEST , "Missing message content" , "Supply valid JSON formatted data in the body of your request" ) ; } try { return JSON...
Parses a last data point query
7,250
public UIDMeta parseUidMetaV1 ( ) { final String json = query . getContent ( ) ; if ( json == null || json . isEmpty ( ) ) { throw new BadRequestException ( HttpResponseStatus . BAD_REQUEST , "Missing message content" , "Supply valid JSON formatted data in the body of your request" ) ; } try { return JSON . parseToObje...
Parses a single UIDMeta object
7,251
public TSMeta parseTSMetaV1 ( ) { final String json = query . getContent ( ) ; if ( json == null || json . isEmpty ( ) ) { throw new BadRequestException ( HttpResponseStatus . BAD_REQUEST , "Missing message content" , "Supply valid JSON formatted data in the body of your request" ) ; } try { return JSON . parseToObject...
Parses a single TSMeta object
7,252
public TreeRule parseTreeRuleV1 ( ) { final String json = query . getContent ( ) ; if ( json == null || json . isEmpty ( ) ) { throw new BadRequestException ( HttpResponseStatus . BAD_REQUEST , "Missing message content" , "Supply valid JSON formatted data in the body of your request" ) ; } return JSON . parseToObject (...
Parses a single TreeRule object
7,253
public List < TreeRule > parseTreeRulesV1 ( ) { final String json = query . getContent ( ) ; if ( json == null || json . isEmpty ( ) ) { throw new BadRequestException ( HttpResponseStatus . BAD_REQUEST , "Missing message content" , "Supply valid JSON formatted data in the body of your request" ) ; } return JSON . parse...
Parses one or more tree rules
7,254
public Map < String , Object > parseTreeTSUIDsListV1 ( ) { final String json = query . getContent ( ) ; if ( json == null || json . isEmpty ( ) ) { throw new BadRequestException ( HttpResponseStatus . BAD_REQUEST , "Missing message content" , "Supply valid JSON formatted data in the body of your request" ) ; } return J...
Parses a tree ID and optional list of TSUIDs to search for collisions or not matched TSUIDs .
7,255
public Annotation parseAnnotationV1 ( ) { final String json = query . getContent ( ) ; if ( json == null || json . isEmpty ( ) ) { throw new BadRequestException ( HttpResponseStatus . BAD_REQUEST , "Missing message content" , "Supply valid JSON formatted data in the body of your request" ) ; } return JSON . parseToObje...
Parses an annotation object
7,256
public List < Annotation > parseAnnotationsV1 ( ) { final String json = query . getContent ( ) ; if ( json == null || json . isEmpty ( ) ) { throw new BadRequestException ( HttpResponseStatus . BAD_REQUEST , "Missing message content" , "Supply valid JSON formatted data in the body of your request" ) ; } return JSON . p...
Parses a list of annotation objects
7,257
public AnnotationBulkDelete parseAnnotationBulkDeleteV1 ( ) { final String json = query . getContent ( ) ; if ( json == null || json . isEmpty ( ) ) { throw new BadRequestException ( HttpResponseStatus . BAD_REQUEST , "Missing message content" , "Supply valid JSON formatted data in the body of your request" ) ; } retur...
Parses a bulk annotation deletion query object
7,258
public SearchQuery parseSearchQueryV1 ( ) { final String json = query . getContent ( ) ; if ( json == null || json . isEmpty ( ) ) { throw new BadRequestException ( HttpResponseStatus . BAD_REQUEST , "Missing message content" , "Supply valid JSON formatted data in the body of your request" ) ; } return JSON . parseToOb...
Parses a SearchQuery request
7,259
public ChannelBuffer formatConfigV1 ( final Config config ) { TreeMap < String , String > map = new TreeMap < String , String > ( config . getMap ( ) ) ; for ( Map . Entry < String , String > entry : map . entrySet ( ) ) { if ( entry . getKey ( ) . toUpperCase ( ) . contains ( "PASS" ) ) { map . put ( entry . getKey ( ...
Format the running configuration
7,260
private ChannelBuffer serializeJSON ( final Object obj ) { if ( query . hasQueryStringParam ( "jsonp" ) ) { return ChannelBuffers . wrappedBuffer ( JSON . serializeToJSONPBytes ( query . getQueryStringParam ( "jsonp" ) , obj ) ) ; } return ChannelBuffers . wrappedBuffer ( JSON . serializeToBytes ( obj ) ) ; }
Helper object for the format calls to wrap the JSON response in a JSONP function if requested . Used for code dedupe .
7,261
public Deferred < TreeMap < byte [ ] , Span > > scan ( ) { start_time = System . currentTimeMillis ( ) ; int i = 0 ; for ( final Scanner scanner : scanners ) { new ScannerCB ( scanner , i ++ ) . scan ( ) ; } return results ; }
Starts all of the scanners asynchronously and returns the data fetched once all of the scanners have completed . Note that the result may be an exception if one or more of the scanners encountered an exception . The first error will be returned others will be logged .
7,262
private void validateAndTriggerCallback ( final List < KeyValue > kvs , final Map < byte [ ] , List < Annotation > > annotations , final List < SimpleEntry < byte [ ] , List < HistogramDataPoint > > > histograms ) { countdown . countDown ( ) ; final long count = countdown . getCount ( ) ; if ( kvs . size ( ) > 0 ) { kv...
Called each time a scanner completes with valid or empty data .
7,263
private String getGnuplotBasePath ( final TSDB tsdb , final HttpQuery query ) { final Map < String , List < String > > q = query . getQueryString ( ) ; q . remove ( "ignore" ) ; final HashMap < String , List < String > > qs = new HashMap < String , List < String > > ( q ) ; qs . remove ( "png" ) ; qs . remove ( "json" ...
Returns the base path to use for the Gnuplot files .
7,264
private boolean isDiskCacheHit ( final HttpQuery query , final long end_time , final int max_age , final String basepath ) throws IOException { final String cachepath = basepath + ( query . hasQueryStringParam ( "ascii" ) ? ".txt" : ".png" ) ; final File cachedfile = new File ( cachepath ) ; if ( cachedfile . exists ( ...
Checks whether or not it s possible to re - serve this query from disk .
7,265
private static boolean staleCacheFile ( final HttpQuery query , final long end_time , final long max_age , final File cachedfile ) { final long mtime = cachedfile . lastModified ( ) / 1000 ; if ( mtime <= 0 ) { return true ; } final long now = System . currentTimeMillis ( ) / 1000 ; final long staleness = now - mtime ;...
Returns whether or not the given cache file can be used or is stale .
7,266
private static void writeFile ( final HttpQuery query , final String path , final byte [ ] contents ) { try { final FileOutputStream out = new FileOutputStream ( path ) ; try { out . write ( contents ) ; } finally { out . close ( ) ; } } catch ( FileNotFoundException e ) { logError ( query , "Failed to create file " + ...
Writes the given byte array into a file . This function logs an error but doesn t throw if it fails .
7,267
private static byte [ ] readFile ( final HttpQuery query , final File file , final int max_length ) { final int length = ( int ) file . length ( ) ; if ( length <= 0 ) { return null ; } FileInputStream in ; try { in = new FileInputStream ( file . getPath ( ) ) ; } catch ( FileNotFoundException e ) { return null ; } try...
Reads a file into a byte array .
7,268
private static String stringify ( final String s ) { final StringBuilder buf = new StringBuilder ( 1 + s . length ( ) + 1 ) ; buf . append ( '"' ) ; HttpQuery . escapeJson ( s , buf ) ; buf . append ( '"' ) ; return buf . toString ( ) ; }
Formats and quotes the given string so it s a suitable Gnuplot string .
7,269
private static String popParam ( final Map < String , List < String > > querystring , final String param ) { final List < String > params = querystring . remove ( param ) ; if ( params == null ) { return null ; } final String given = params . get ( params . size ( ) - 1 ) ; if ( given . contains ( "`" ) || given . cont...
Pops out of the query string the given parameter .
7,270
static void setPlotParams ( final HttpQuery query , final Plot plot ) { final HashMap < String , String > params = new HashMap < String , String > ( ) ; final Map < String , List < String > > querystring = query . getQueryString ( ) ; String value ; if ( ( value = popParam ( querystring , "yrange" ) ) != null ) { param...
Applies the plot parameters from the query to the given plot .
7,271
private static void printMetricHeader ( final PrintWriter writer , final String metric , final long timestamp ) { writer . print ( metric ) ; writer . print ( ' ' ) ; writer . print ( timestamp / 1000L ) ; writer . print ( ' ' ) ; }
Helper method to write metric name and timestamp .
7,272
private static String findGnuplotHelperScript ( ) { if ( ! GnuplotInstaller . FOUND_GP ) { LOG . warn ( "Skipping Gnuplot Shell Script Install since Gnuplot executable was not found" ) ; return null ; } if ( ! GnuplotInstaller . GP_FILE . exists ( ) ) { GnuplotInstaller . installMyGnuPlot ( ) ; } if ( GnuplotInstaller ...
Iterate through the class path and look for the Gnuplot helper script .
7,273
public static Deferred < TSMeta > parseFromColumn ( final TSDB tsdb , final KeyValue column , final boolean load_uidmetas ) { if ( column . value ( ) == null || column . value ( ) . length < 1 ) { throw new IllegalArgumentException ( "Empty column value" ) ; } final TSMeta parsed_meta = JSON . parseToObject ( column . ...
Parses a TSMeta object from the given column optionally loading the UIDMeta objects
7,274
public static Deferred < Boolean > metaExistsInStorage ( final TSDB tsdb , final String tsuid ) { final GetRequest get = new GetRequest ( tsdb . metaTable ( ) , UniqueId . stringToUid ( tsuid ) ) ; get . family ( FAMILY ) ; get . qualifier ( META_QUALIFIER ) ; final class ExistsCB implements Callback < Boolean , ArrayL...
Determines if an entry exists in storage or not . This is used by the UID Manager tool to determine if we need to write a new TSUID entry or not . It will not attempt to verify if the stored data is valid just checks to see if something is stored in the proper column .
7,275
public static Deferred < Boolean > counterExistsInStorage ( final TSDB tsdb , final byte [ ] tsuid ) { final GetRequest get = new GetRequest ( tsdb . metaTable ( ) , tsuid ) ; get . family ( FAMILY ) ; get . qualifier ( COUNTER_QUALIFIER ) ; final class ExistsCB implements Callback < Boolean , ArrayList < KeyValue > > ...
Determines if the counter column exists for the TSUID . This is used by the UID Manager tool to determine if we need to write a new TSUID entry or not . It will not attempt to verify if the stored data is valid just checks to see if something is stored in the proper column .
7,276
public void validate ( ) { if ( time == null ) { throw new IllegalArgumentException ( "missing time" ) ; } validatePOJO ( time , "time" ) ; if ( metrics == null || metrics . isEmpty ( ) ) { throw new IllegalArgumentException ( "missing or empty metrics" ) ; } final Set < String > variable_ids = new HashSet < String > (...
Validates the query
7,277
private void validateFilters ( ) { Set < String > ids = new HashSet < String > ( ) ; for ( Filter filter : filters ) { ids . add ( filter . getId ( ) ) ; } for ( Metric metric : metrics ) { if ( metric . getFilter ( ) != null && ! metric . getFilter ( ) . isEmpty ( ) && ! ids . contains ( metric . getFilter ( ) ) ) { t...
Validates the filters making sure each metric has a filter
7,278
public static void validateId ( final String id ) { if ( id == null || id . isEmpty ( ) ) { throw new IllegalArgumentException ( "The ID cannot be null or empty" ) ; } for ( int i = 0 ; i < id . length ( ) ; i ++ ) { final char c = id . charAt ( i ) ; if ( ! ( Character . isLetterOrDigit ( c ) ) ) { throw new IllegalAr...
Makes sure the ID has only letters and characters
7,279
public static void loadPluginPath ( final String plugin_path ) { if ( plugin_path != null && ! plugin_path . isEmpty ( ) ) { try { PluginLoader . loadJARs ( plugin_path ) ; } catch ( Exception e ) { LOG . error ( "Error loading plugins from plugin path: " + plugin_path , e ) ; throw new RuntimeException ( "Error loadin...
Called by initializePlugins also used to load startup plugins .
7,280
public Deferred < String > getUidName ( final UniqueIdType type , final byte [ ] uid ) { if ( uid == null ) { throw new IllegalArgumentException ( "Missing UID" ) ; } switch ( type ) { case METRIC : return this . metrics . getNameAsync ( uid ) ; case TAGK : return this . tag_names . getNameAsync ( uid ) ; case TAGV : r...
Attempts to find the name for a unique identifier given a type
7,281
public Deferred < ArrayList < Object > > checkNecessaryTablesExist ( ) { final ArrayList < Deferred < Object > > checks = new ArrayList < Deferred < Object > > ( 2 ) ; checks . add ( client . ensureTableExists ( config . getString ( "tsd.storage.hbase.data_table" ) ) ) ; checks . add ( client . ensureTableExists ( conf...
Verifies that the data and UID tables exist in HBase and optionally the tree and meta data tables if the user has enabled meta tracking or tree building
7,282
public Deferred < Object > addHistogramPoint ( final String metric , final long timestamp , final byte [ ] raw_data , final Map < String , String > tags ) { if ( raw_data == null || raw_data . length < MIN_HISTOGRAM_BYTES ) { return Deferred . fromError ( new IllegalArgumentException ( "The histogram raw data is invali...
Adds an encoded Histogram data point in the TSDB .
7,283
public List < String > suggestMetrics ( final String search , final int max_results ) { return metrics . suggest ( search , max_results ) ; }
Given a prefix search returns matching metric names .
7,284
public List < String > suggestTagNames ( final String search , final int max_results ) { return tag_names . suggest ( search , max_results ) ; }
Given a prefix search returns matching tagk names .
7,285
public List < String > suggestTagValues ( final String search , final int max_results ) { return tag_values . suggest ( search , max_results ) ; }
Given a prefix search returns matching tag values .
7,286
public byte [ ] assignUid ( final String type , final String name ) { Tags . validateString ( type , name ) ; if ( type . toLowerCase ( ) . equals ( "metric" ) ) { try { final byte [ ] uid = this . metrics . getId ( name ) ; throw new IllegalArgumentException ( "Name already exists with UID: " + UniqueId . uidToString ...
Attempts to assign a UID to a name for the given type Used by the UniqueIdRpc call to generate IDs for new metrics tagks or tagvs . The name must pass validation and if it s already assigned a UID this method will throw an error with the proper UID . Otherwise if it can create the UID it will be returned
7,287
public Deferred < Object > deleteUidAsync ( final String type , final String name ) { final UniqueIdType uid_type = UniqueId . stringToUniqueIdType ( type ) ; switch ( uid_type ) { case METRIC : return metrics . deleteAsync ( name ) ; case TAGK : return tag_names . deleteAsync ( name ) ; case TAGV : return tag_values ....
Attempts to delete the given UID name mapping from the storage table as well as the local cache .
7,288
public void renameUid ( final String type , final String oldname , final String newname ) { Tags . validateString ( type , oldname ) ; Tags . validateString ( type , newname ) ; if ( type . toLowerCase ( ) . equals ( "metric" ) ) { try { this . metrics . getId ( oldname ) ; this . metrics . rename ( oldname , newname )...
Attempts to rename a UID from existing name to the given name Used by the UniqueIdRpc call to rename name of existing metrics tagks or tagvs . The name must pass validation . If the UID doesn t exist the method will throw an error . Chained IllegalArgumentException is directly exposed to caller . If the rename was succ...
7,289
public void indexTSMeta ( final TSMeta meta ) { if ( search != null ) { search . indexTSMeta ( meta ) . addErrback ( new PluginError ( ) ) ; } }
Index the given timeseries meta object via the configured search plugin
7,290
public void deleteTSMeta ( final String tsuid ) { if ( search != null ) { search . deleteTSMeta ( tsuid ) . addErrback ( new PluginError ( ) ) ; } }
Delete the timeseries meta object from the search index
7,291
public void indexUIDMeta ( final UIDMeta meta ) { if ( search != null ) { search . indexUIDMeta ( meta ) . addErrback ( new PluginError ( ) ) ; } }
Index the given UID meta object via the configured search plugin
7,292
public void deleteUIDMeta ( final UIDMeta meta ) { if ( search != null ) { search . deleteUIDMeta ( meta ) . addErrback ( new PluginError ( ) ) ; } }
Delete the UID meta object from the search index
7,293
public void indexAnnotation ( final Annotation note ) { if ( search != null ) { search . indexAnnotation ( note ) . addErrback ( new PluginError ( ) ) ; } if ( rt_publisher != null ) { rt_publisher . publishAnnotation ( note ) ; } }
Index the given Annotation object via the configured search plugin
7,294
public void deleteAnnotation ( final Annotation note ) { if ( search != null ) { search . deleteAnnotation ( note ) . addErrback ( new PluginError ( ) ) ; } }
Delete the annotation object from the search index
7,295
public Deferred < Boolean > processTSMetaThroughTrees ( final TSMeta meta ) { if ( config . enable_tree_processing ( ) ) { return TreeBuilder . processAllTrees ( this , meta ) ; } return Deferred . fromResult ( false ) ; }
Processes the TSMeta through all of the trees if configured to do so
7,296
public Deferred < SearchQuery > executeSearch ( final SearchQuery query ) { if ( search == null ) { throw new IllegalStateException ( "Searching has not been enabled on this TSD" ) ; } return search . executeQuery ( query ) ; }
Executes a search query using the search plugin
7,297
public void preFetchHBaseMeta ( ) { LOG . info ( "Pre-fetching meta data for all tables" ) ; final long start = System . currentTimeMillis ( ) ; final ArrayList < Deferred < Object > > deferreds = new ArrayList < Deferred < Object > > ( ) ; deferreds . add ( client . prefetchMeta ( table ) ) ; deferreds . add ( client ...
Blocks while pre - fetching meta data from the data and uid tables so that performance improves particularly with a large number of regions and region servers .
7,298
final Deferred < ArrayList < KeyValue > > get ( final byte [ ] key ) { return client . get ( new GetRequest ( table , key , FAMILY ) ) ; }
Gets the entire given row from the data table .
7,299
final Deferred < Object > put ( final byte [ ] key , final byte [ ] qualifier , final byte [ ] value , long timestamp ) { return client . put ( RequestBuilder . buildPutRequest ( config , table , key , FAMILY , qualifier , value , timestamp ) ) ; }
Puts the given value into the data table .