2018-12-13 14:47:20 -05:00
---
2019-08-21 00:48:59 -04:00
id: lookups-cached-global
2018-12-13 14:47:20 -05:00
title: "Globally Cached Lookups"
---
2018-11-13 12:38:37 -05:00
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
2024-06-03 19:04:15 -04:00
To use this Apache Druid extension, [include ](../configuration/extensions.md#loading-extensions ) `druid-lookups-cached-global` in the extensions load list.
2016-03-22 16:54:49 -04:00
## Configuration
2023-08-16 22:01:21 -04:00
:::info
Static configuration is no longer supported. Lookups can be configured through
2024-06-03 19:04:15 -04:00
[dynamic configuration ](./lookups.md#configuration ).
2023-08-16 22:01:21 -04:00
:::
2016-05-24 13:56:40 -04:00
2016-06-07 13:43:35 -04:00
Globally cached lookups are appropriate for lookups which are not possible to pass at query time due to their size,
2016-05-24 13:56:40 -04:00
or are not desired to be passed at query time because the data is to reside in and be handled by the Druid servers,
2019-02-28 21:10:39 -05:00
and are small enough to reasonably populate in-memory. This usually means tens to tens of thousands of entries per lookup.
2016-03-22 16:54:49 -04:00
2019-02-28 21:10:39 -05:00
Globally cached lookups all draw from the same cache pool, allowing each process to have a fixed cache pool that can be used by cached lookups.
2016-05-24 13:56:40 -04:00
2024-06-03 19:04:15 -04:00
Globally cached lookups can be specified as part of the [cluster wide config for lookups ](./lookups.md ) as a type of `cachedNamespace`
2016-03-22 16:54:49 -04:00
```json
2016-05-24 13:56:40 -04:00
{
"type": "cachedNamespace",
"extractionNamespace": {
2016-03-22 16:54:49 -04:00
"type": "uri",
"uri": "file:/tmp/prefix/",
"namespaceParseSpec": {
"format": "csv",
"columns": [
2020-12-24 12:49:01 -05:00
"[\"key\"",
"\"value\"]"
]
2016-03-22 16:54:49 -04:00
},
"pollPeriod": "PT5M"
},
2016-05-24 13:56:40 -04:00
"firstCacheTimeout": 0
}
```
2019-08-21 00:48:59 -04:00
2016-05-24 13:56:40 -04:00
```json
{
"type": "cachedNamespace",
"extractionNamespace": {
2016-03-22 16:54:49 -04:00
"type": "jdbc",
"connectorConfig": {
"connectURI": "jdbc:mysql:\/\/localhost:3306\/druid",
"user": "druid",
"password": "diurd"
},
"table": "lookupTable",
"keyColumn": "mykeyColumn",
2017-08-09 13:47:46 -04:00
"valueColumn": "myValueColumn",
"filter" : "myFilterSQL (Where clause statement e.g LOOKUPTYPE=1)",
2016-03-22 16:54:49 -04:00
"tsColumn": "timeColumn"
2016-05-24 13:56:40 -04:00
},
"firstCacheTimeout": 120000,
"injective":true
}
2016-03-22 16:54:49 -04:00
```
2016-05-24 13:56:40 -04:00
The parameters are as follows
2016-05-24 20:28:39 -04:00
2016-05-24 13:56:40 -04:00
|Property|Description|Required|Default|
|--------|-----------|--------|-------|
|`extractionNamespace`|Specifies how to populate the local cache. See below|Yes|-|
2016-06-03 16:58:10 -04:00
|`firstCacheTimeout`|How long to wait (in ms) for the first run of the cache to populate. 0 indicates to not wait|No|`0` (do not wait)|
2024-06-03 19:04:15 -04:00
|`injective`|If the underlying map is [injective ](./lookups.md#query-rewrites ) (keys and values are unique) then optimizations can occur internally by setting this to `true` |No|`false`|
2016-05-24 13:56:40 -04:00
2019-02-28 21:10:39 -05:00
If `firstCacheTimeout` is set to a non-zero value, it should be less than `druid.manager.lookups.hostUpdateTimeout` . If `firstCacheTimeout` is NOT set, then management is essentially asynchronous and does not know if a lookup succeeded or failed in starting. In such a case logs from the processes using lookups should be monitored for repeated failures.
2016-06-03 16:58:10 -04:00
2019-02-28 21:10:39 -05:00
Proper functionality of globally cached lookups requires the following extension to be loaded on the Broker, Peon, and Historical processes:
2016-05-24 13:56:40 -04:00
`druid-lookups-cached-global`
2016-03-22 16:54:49 -04:00
2016-06-07 13:42:41 -04:00
## Example configuration
2024-06-03 19:04:15 -04:00
In a simple case where only one [tier ](./lookups.md#dynamic-configuration ) exists (`realtime_customer2`) with one `cachedNamespace` lookup called `country_code` , the resulting configuration JSON looks similar to the following:
2016-06-07 13:42:41 -04:00
```json
{
"realtime_customer2": {
"country_code": {
2018-04-06 19:13:17 -04:00
"version": "v0",
"lookupExtractorFactory": {
"type": "cachedNamespace",
"extractionNamespace": {
"type": "jdbc",
"connectorConfig": {
"connectURI": "jdbc:mysql:\/\/localhost:3306\/druid",
"user": "druid",
"password": "diurd"
},
"table": "lookupValues",
"keyColumn": "value_id",
"valueColumn": "value_text",
"filter": "value_type='country'",
"tsColumn": "timeColumn"
},
"firstCacheTimeout": 120000,
"injective": true
}
2016-06-07 13:42:41 -04:00
}
}
}
```
2019-01-30 22:41:07 -05:00
Where the Coordinator endpoint `/druid/coordinator/v1/lookups/realtime_customer2/country_code` should return
2016-06-07 13:42:41 -04:00
```json
{
2018-04-06 19:13:17 -04:00
"version": "v0",
"lookupExtractorFactory": {
"type": "cachedNamespace",
"extractionNamespace": {
"type": "jdbc",
"connectorConfig": {
"connectURI": "jdbc:mysql://localhost:3306/druid",
"user": "druid",
"password": "diurd"
},
"table": "lookupValues",
"keyColumn": "value_id",
"valueColumn": "value_text",
"filter": "value_type='country'",
"tsColumn": "timeColumn"
2016-06-07 13:42:41 -04:00
},
2018-04-06 19:13:17 -04:00
"firstCacheTimeout": 120000,
"injective": true
}
2016-06-07 13:42:41 -04:00
}
```
2016-03-22 16:54:49 -04:00
## Cache Settings
2019-08-21 00:48:59 -04:00
Lookups are cached locally on Historical processes. The following are settings used by the processes which service queries when
2019-01-30 22:41:07 -05:00
setting namespaces (Broker, Peon, Historical)
2016-03-22 16:54:49 -04:00
|Property|Description|Default|
|--------|-----------|-------|
2016-05-24 13:56:40 -04:00
|`druid.lookup.namespace.cache.type`|Specifies the type of caching to be used by the namespaces. May be one of [`offHeap`, `onHeap` ]. `offHeap` uses a temporary file for off-heap storage of the namespace (memory mapped files). `onHeap` stores all cache on the heap in standard java map types.|`onHeap`|
2017-09-25 12:52:36 -04:00
|`druid.lookup.namespace.numExtractionThreads`|The number of threads in the thread pool dedicated for lookup extraction and updates. This number may need to be scaled up, if you have a lot of lookups and they take long time to extract, to avoid timeouts.|2|
2019-09-17 15:47:30 -04:00
|`druid.lookup.namespace.numBufferedEntries`|If using off-heap caching, the number of records to be stored on an on-heap buffer.|100,000|
2016-03-22 16:54:49 -04:00
2019-08-21 00:48:59 -04:00
The cache is populated in different ways depending on the settings below. In general, most namespaces employ
2016-03-22 16:54:49 -04:00
a `pollPeriod` at the end of which time they poll the remote resource of interest for updates.
2016-05-24 13:56:40 -04:00
`onHeap` uses `ConcurrentMap` s in the java heap, and thus affects garbage collection and heap sizing.
2018-05-04 13:00:55 -04:00
`offHeap` uses an on-heap buffer and MapDB using memory-mapped files in the java temporary directory.
So if total number of entries in the `cachedNamespace` is in excess of the buffer's configured capacity, the extra will be kept in memory as page cache, and paged in and out by general OS tunings.
It's highly recommended that `druid.lookup.namespace.numBufferedEntries` is set when using `offHeap` , the value should be chosen from the range between 10% and 50% of the number of entries in the lookup.
2019-08-21 00:48:59 -04:00
## Supported lookups
2016-05-24 13:56:40 -04:00
2024-06-03 19:04:15 -04:00
For additional lookups, please see our [extensions list ](../configuration/extensions.md ).
2016-03-22 16:54:49 -04:00
2019-08-21 00:48:59 -04:00
### URI lookup
2016-03-22 16:54:49 -04:00
2019-09-17 15:47:30 -04:00
The remapping values for each globally cached lookup can be specified by a JSON object as per the following examples:
2016-03-22 16:54:49 -04:00
```json
{
"type":"uri",
2016-05-02 15:54:34 -04:00
"uri": "s3://bucket/some/key/prefix/renames-0003.gz",
2016-03-22 16:54:49 -04:00
"namespaceParseSpec":{
"format":"csv",
2020-12-24 12:49:01 -05:00
"columns":[
"[\"key\"",
"\"value\"]"
]
2016-03-22 16:54:49 -04:00
},
2016-05-24 13:56:40 -04:00
"pollPeriod":"PT5M"
2016-03-22 16:54:49 -04:00
}
```
2016-05-02 15:54:34 -04:00
```json
{
"type":"uri",
"uriPrefix": "s3://bucket/some/key/prefix/",
"fileRegex":"renames-[0-9]*\\.gz",
"namespaceParseSpec":{
"format":"csv",
2020-12-24 12:49:01 -05:00
"columns":[
"[\"key\"",
"\"value\"]"
]
2016-05-02 15:54:34 -04:00
},
Warn if cache size of lookup is beyond max size (#11863)
Enhanced the ExtractionNamespace interface in lookups-cached-global core extension with the ability to set a maxHeapPercentage for the cache of the respective namespace. The reason for adding this functionality, is make it easier to detect when a lookup table grows to a size that the underlying service cannot handle, because it does not have enough memory. The default value of maxHeap for the interface is -1, which indicates that no maxHeapPercentage has been set. For the JdbcExtractionNamespace and UriExtractionNamespace implementations, the default value is null, which will cause the respective service that the lookup is loaded in, to warn when its cache is beyond mxHeapPercentage of the service's configured max heap size. If a positive non-null value is set for the namespace's maxHeapPercentage config, this value will be honored for all services that the respective lookup is loaded onto, and consequently log warning messages when the cache of the respective lookup grows beyond this respective percentage of the services configured max heap size. Warnings are logged every time that either Uri based or Jdbc based lookups are regenerated, if the maxHeapPercentage constraint is violated. No other implementations will log warnings at this time. No error is thrown when the size exceeds the maxHeapPercentage at this time, as doing so could break functionality for existing users. Previously the JdbcCacheGenerator generated its cache by materializing all rows of the underling table in memory at once; this made it difficult to log warning messages in the case that the results from the jdbc query were very large and caused the service to run out of memory. To help with this, this pr makes it so that the jdbc query results are instead streamed through an iterator.
2021-11-03 21:32:22 -04:00
"pollPeriod":"PT5M",
"maxHeapPercentage": 10
2016-05-02 15:54:34 -04:00
}
```
2016-06-07 13:42:41 -04:00
2016-03-22 16:54:49 -04:00
|Property|Description|Required|Default|
|--------|-----------|--------|-------|
|`pollPeriod`|Period between polling for updates|No|0 (only once)|
2024-03-13 14:52:01 -04:00
|`uri`|URI for the lookup file. Can be a file, HDFS, S3 or GCS path|Either `uri` or `uriPrefix` must be set|None|
|`uriPrefix`|A URI prefix that specifies a directory or other searchable resource where lookup files are located |Either `uri` or `uriPrefix` must be set|None|
2016-05-02 15:54:34 -04:00
|`fileRegex`|Optional regex for matching the file name under `uriPrefix` . Only used if `uriPrefix` is used|No|`".*"`|
2016-03-22 16:54:49 -04:00
|`namespaceParseSpec`|How to interpret the data at the URI|Yes||
Warn if cache size of lookup is beyond max size (#11863)
Enhanced the ExtractionNamespace interface in lookups-cached-global core extension with the ability to set a maxHeapPercentage for the cache of the respective namespace. The reason for adding this functionality, is make it easier to detect when a lookup table grows to a size that the underlying service cannot handle, because it does not have enough memory. The default value of maxHeap for the interface is -1, which indicates that no maxHeapPercentage has been set. For the JdbcExtractionNamespace and UriExtractionNamespace implementations, the default value is null, which will cause the respective service that the lookup is loaded in, to warn when its cache is beyond mxHeapPercentage of the service's configured max heap size. If a positive non-null value is set for the namespace's maxHeapPercentage config, this value will be honored for all services that the respective lookup is loaded onto, and consequently log warning messages when the cache of the respective lookup grows beyond this respective percentage of the services configured max heap size. Warnings are logged every time that either Uri based or Jdbc based lookups are regenerated, if the maxHeapPercentage constraint is violated. No other implementations will log warnings at this time. No error is thrown when the size exceeds the maxHeapPercentage at this time, as doing so could break functionality for existing users. Previously the JdbcCacheGenerator generated its cache by materializing all rows of the underling table in memory at once; this made it difficult to log warning messages in the case that the results from the jdbc query were very large and caused the service to run out of memory. To help with this, this pr makes it so that the jdbc query results are instead streamed through an iterator.
2021-11-03 21:32:22 -04:00
|`maxHeapPercentage`|The maximum percentage of heap size that the lookup should consume. If the lookup grows beyond this size, warning messages will be logged in the respective service logs.|No|10% of JVM heap size|
2016-03-22 16:54:49 -04:00
2021-03-29 16:10:41 -04:00
One of either `uri` or `uriPrefix` must be specified, as either a local file system (file://), HDFS (hdfs://), S3 (s3://) or GCS (gs://) location. HTTP location is not currently supported.
2016-03-22 16:54:49 -04:00
2016-05-02 15:54:34 -04:00
The `pollPeriod` value specifies the period in ISO 8601 format between checks for replacement data for the lookup. If the source of the lookup is capable of providing a timestamp, the lookup will only be updated if it has changed since the prior tick of `pollPeriod` . A value of 0, an absent parameter, or `null` all mean populate once and do not attempt to look for new data later. Whenever an poll occurs, the updating system will look for a file with the most recent timestamp and assume that one with the most recent data set, replacing the local cache of the lookup data.
2016-03-22 16:54:49 -04:00
The `namespaceParseSpec` can be one of a number of values. Each of the examples below would rename foo to bar, baz to bat, and buck to truck. All parseSpec types assumes each input is delimited by a new line. See below for the types of parseSpec supported.
2016-05-02 15:54:34 -04:00
Only ONE file which matches the search will be used. For most implementations, the discriminator for choosing the URIs is by whichever one reports the most recent timestamp for its modification time.
2019-08-21 00:48:59 -04:00
#### csv lookupParseSpec
2016-03-22 16:54:49 -04:00
|Parameter|Description|Required|Default|
|---------|-----------|--------|-------|
2017-05-16 01:57:31 -04:00
|`columns`|The list of columns in the csv file|no if `hasHeaderRow` is set|`null`|
2016-03-22 16:54:49 -04:00
|`keyColumn`|The name of the column containing the key|no|The first column|
|`valueColumn`|The name of the column containing the value|no|The second column|
2017-05-16 01:57:31 -04:00
|`hasHeaderRow`|A flag to indicate that column information can be extracted from the input files' header row|no|false|
|`skipHeaderRows`|Number of header rows to be skipped|no|0|
If both `skipHeaderRows` and `hasHeaderRow` options are set, `skipHeaderRows` is first applied. For example, if you set
`skipHeaderRows` to 2 and `hasHeaderRow` to true, Druid will skip the first two lines and then extract column information
from the third line.
2016-03-22 16:54:49 -04:00
*example input*
```
bar,something,foo
bat,something2,baz
truck,something3,buck
```
*example namespaceParseSpec*
```json
"namespaceParseSpec": {
"format": "csv",
"columns": ["value","somethingElse","key"],
"keyColumn": "key",
"valueColumn": "value"
}
```
2019-08-21 00:48:59 -04:00
#### tsv lookupParseSpec
2016-03-22 16:54:49 -04:00
|Parameter|Description|Required|Default|
|---------|-----------|--------|-------|
2017-05-16 01:57:31 -04:00
|`columns`|The list of columns in the tsv file|yes|`null`|
2016-03-22 16:54:49 -04:00
|`keyColumn`|The name of the column containing the key|no|The first column|
|`valueColumn`|The name of the column containing the value|no|The second column|
|`delimiter`|The delimiter in the file|no|tab (`\t`)|
2016-05-10 06:11:16 -04:00
|`listDelimiter`|The list delimiter in the file|no| (`\u0001`)|
2017-05-16 01:57:31 -04:00
|`hasHeaderRow`|A flag to indicate that column information can be extracted from the input files' header row|no|false|
|`skipHeaderRows`|Number of header rows to be skipped|no|0|
2016-03-22 16:54:49 -04:00
2017-05-16 01:57:31 -04:00
If both `skipHeaderRows` and `hasHeaderRow` options are set, `skipHeaderRows` is first applied. For example, if you set
`skipHeaderRows` to 2 and `hasHeaderRow` to true, Druid will skip the first two lines and then extract column information
from the third line.
2016-03-22 16:54:49 -04:00
*example input*
```
bar|something,1|foo
bat|something,2|baz
truck|something,3|buck
```
*example namespaceParseSpec*
```json
"namespaceParseSpec": {
"format": "tsv",
"columns": ["value","somethingElse","key"],
"keyColumn": "key",
"valueColumn": "value",
"delimiter": "|"
}
```
2019-08-21 00:48:59 -04:00
#### customJson lookupParseSpec
2016-03-22 16:54:49 -04:00
|Parameter|Description|Required|Default|
|---------|-----------|--------|-------|
|`keyFieldName`|The field name of the key|yes|null|
|`valueFieldName`|The field name of the value|yes|null|
*example input*
```json
{"key": "foo", "value": "bar", "somethingElse" : "something"}
{"key": "baz", "value": "bat", "somethingElse" : "something"}
{"key": "buck", "somethingElse": "something", "value": "truck"}
```
*example namespaceParseSpec*
```json
"namespaceParseSpec": {
"format": "customJson",
"keyFieldName": "key",
"valueFieldName": "value"
}
```
2016-11-03 16:53:04 -04:00
With customJson parsing, if the value field for a particular row is missing or null then that line will be skipped, and
will not be included in the lookup.
2016-03-22 16:54:49 -04:00
2019-08-21 00:48:59 -04:00
#### simpleJson lookupParseSpec
2019-09-17 15:47:30 -04:00
The `simpleJson` lookupParseSpec does not take any parameters. It is simply a line delimited JSON file where the field is the key, and the field's value is the value.
2016-03-22 16:54:49 -04:00
*example input*
2019-08-21 00:48:59 -04:00
2016-03-22 16:54:49 -04:00
```json
{"foo": "bar"}
{"baz": "bat"}
{"buck": "truck"}
```
*example namespaceParseSpec*
```json
"namespaceParseSpec":{
"format": "simpleJson"
}
```
2019-08-21 00:48:59 -04:00
### JDBC lookup
2016-03-22 16:54:49 -04:00
2019-09-17 15:47:30 -04:00
The JDBC lookups will poll a database to populate its local cache. If the `tsColumn` is set it must be able to accept comparisons in the format `'2015-01-01 00:00:00'` . For example, the following must be valid SQL for the table `SELECT * FROM some_lookup_table WHERE timestamp_column > '2015-01-01 00:00:00'` . If `tsColumn` is set, the caching service will attempt to only poll values that were written *after* the last sync. If `tsColumn` is not set, the entire table is pulled every time.
2016-03-22 16:54:49 -04:00
|Parameter|Description|Required|Default|
|---------|-----------|--------|-------|
2024-06-03 19:04:15 -04:00
|`connectorConfig`|The connector config to use. You can set `connectURI` , `user` and `password` . You can selectively allow JDBC properties in `connectURI` . See [JDBC connections security config ](../configuration/index.md#jdbc-connections-to-external-databases ) for more details.|Yes||
2016-03-22 16:54:49 -04:00
|`table`|The table which contains the key value pairs|Yes||
|`keyColumn`|The column in `table` which contains the keys|Yes||
|`valueColumn`|The column in `table` which contains the values|Yes||
2017-08-09 13:47:46 -04:00
|`filter`|The filter to use when selecting lookups, this is used to create a where clause on lookup population|No|No Filter|
2016-03-22 16:54:49 -04:00
|`tsColumn`| The column in `table` which contains when the key was updated|No|Not used|
|`pollPeriod`|How often to poll the DB|No|0 (only once)|
2023-10-09 00:05:39 -04:00
|`jitterSeconds`| How much jitter to add (in seconds) up to maximum as a delay (actual value will be used as random from 0 to `jitterSeconds` ), used to distribute db load more evenly|No|0|
2023-11-07 13:07:28 -05:00
|`loadTimeoutSeconds`| How much time (in seconds) it can take to query and populate lookup values. It will be helpful in lookup updates. On lookup update, it will wait maximum of `loadTimeoutSeconds` for new lookup to come up and continue serving from old lookup until new lookup successfully loads. |No|0|
Warn if cache size of lookup is beyond max size (#11863)
Enhanced the ExtractionNamespace interface in lookups-cached-global core extension with the ability to set a maxHeapPercentage for the cache of the respective namespace. The reason for adding this functionality, is make it easier to detect when a lookup table grows to a size that the underlying service cannot handle, because it does not have enough memory. The default value of maxHeap for the interface is -1, which indicates that no maxHeapPercentage has been set. For the JdbcExtractionNamespace and UriExtractionNamespace implementations, the default value is null, which will cause the respective service that the lookup is loaded in, to warn when its cache is beyond mxHeapPercentage of the service's configured max heap size. If a positive non-null value is set for the namespace's maxHeapPercentage config, this value will be honored for all services that the respective lookup is loaded onto, and consequently log warning messages when the cache of the respective lookup grows beyond this respective percentage of the services configured max heap size. Warnings are logged every time that either Uri based or Jdbc based lookups are regenerated, if the maxHeapPercentage constraint is violated. No other implementations will log warnings at this time. No error is thrown when the size exceeds the maxHeapPercentage at this time, as doing so could break functionality for existing users. Previously the JdbcCacheGenerator generated its cache by materializing all rows of the underling table in memory at once; this made it difficult to log warning messages in the case that the results from the jdbc query were very large and caused the service to run out of memory. To help with this, this pr makes it so that the jdbc query results are instead streamed through an iterator.
2021-11-03 21:32:22 -04:00
|`maxHeapPercentage`|The maximum percentage of heap size that the lookup should consume. If the lookup grows beyond this size, warning messages will be logged in the respective service logs.|No|10% of JVM heap size|
2016-03-22 16:54:49 -04:00
```json
{
"type":"jdbc",
"connectorConfig":{
"connectURI":"jdbc:mysql://localhost:3306/druid",
"user":"druid",
"password":"diurd"
},
"table":"some_lookup_table",
"keyColumn":"the_old_dim_value",
"valueColumn":"the_new_dim_value",
"tsColumn":"timestamp_column",
Warn if cache size of lookup is beyond max size (#11863)
Enhanced the ExtractionNamespace interface in lookups-cached-global core extension with the ability to set a maxHeapPercentage for the cache of the respective namespace. The reason for adding this functionality, is make it easier to detect when a lookup table grows to a size that the underlying service cannot handle, because it does not have enough memory. The default value of maxHeap for the interface is -1, which indicates that no maxHeapPercentage has been set. For the JdbcExtractionNamespace and UriExtractionNamespace implementations, the default value is null, which will cause the respective service that the lookup is loaded in, to warn when its cache is beyond mxHeapPercentage of the service's configured max heap size. If a positive non-null value is set for the namespace's maxHeapPercentage config, this value will be honored for all services that the respective lookup is loaded onto, and consequently log warning messages when the cache of the respective lookup grows beyond this respective percentage of the services configured max heap size. Warnings are logged every time that either Uri based or Jdbc based lookups are regenerated, if the maxHeapPercentage constraint is violated. No other implementations will log warnings at this time. No error is thrown when the size exceeds the maxHeapPercentage at this time, as doing so could break functionality for existing users. Previously the JdbcCacheGenerator generated its cache by materializing all rows of the underling table in memory at once; this made it difficult to log warning messages in the case that the results from the jdbc query were very large and caused the service to run out of memory. To help with this, this pr makes it so that the jdbc query results are instead streamed through an iterator.
2021-11-03 21:32:22 -04:00
"pollPeriod":600000,
2023-10-09 00:05:39 -04:00
"jitterSeconds": 120,
Warn if cache size of lookup is beyond max size (#11863)
Enhanced the ExtractionNamespace interface in lookups-cached-global core extension with the ability to set a maxHeapPercentage for the cache of the respective namespace. The reason for adding this functionality, is make it easier to detect when a lookup table grows to a size that the underlying service cannot handle, because it does not have enough memory. The default value of maxHeap for the interface is -1, which indicates that no maxHeapPercentage has been set. For the JdbcExtractionNamespace and UriExtractionNamespace implementations, the default value is null, which will cause the respective service that the lookup is loaded in, to warn when its cache is beyond mxHeapPercentage of the service's configured max heap size. If a positive non-null value is set for the namespace's maxHeapPercentage config, this value will be honored for all services that the respective lookup is loaded onto, and consequently log warning messages when the cache of the respective lookup grows beyond this respective percentage of the services configured max heap size. Warnings are logged every time that either Uri based or Jdbc based lookups are regenerated, if the maxHeapPercentage constraint is violated. No other implementations will log warnings at this time. No error is thrown when the size exceeds the maxHeapPercentage at this time, as doing so could break functionality for existing users. Previously the JdbcCacheGenerator generated its cache by materializing all rows of the underling table in memory at once; this made it difficult to log warning messages in the case that the results from the jdbc query were very large and caused the service to run out of memory. To help with this, this pr makes it so that the jdbc query results are instead streamed through an iterator.
2021-11-03 21:32:22 -04:00
"maxHeapPercentage": 10
2016-03-22 16:54:49 -04:00
}
```
2016-05-24 13:56:40 -04:00
2023-08-16 22:01:21 -04:00
:::info
If using JDBC, you will need to add your database's client JAR files to the extension's directory.
For Postgres, the connector JAR is already included.
2024-09-16 18:52:37 -04:00
See the MySQL extension documentation for instructions to obtain [MySQL ](../development/extensions-core/mysql.md#install-mysql-connectorj ) or [MariaDB ](../development/extensions-core/mysql.md#install-mariadb-connectorj ) connector libraries.
2023-08-16 22:01:21 -04:00
The connector JAR should reside in the classpath of Druid's main class loader.
To add the connector JAR to the classpath, you can copy the downloaded file to `lib/` under the distribution root directory. Alternatively, create a symbolic link to the connector in the `lib` directory.
:::
2019-11-06 16:31:26 -05:00
2019-08-21 00:48:59 -04:00
## Introspection
2016-05-24 13:56:40 -04:00
2016-06-07 13:43:35 -04:00
Globally cached lookups have introspection points at `/keys` and `/values` which return a complete set of the keys and values (respectively) in the lookup. Introspection to `/` returns the entire map. Introspection to `/version` returns the version indicator for the lookup.