-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Config slurper master #191
Changes from 96 commits
51d993a
eb50f85
64503c2
93af80d
daabf0e
52303e0
1766d91
3f2517d
9abe713
83a6fb8
f030d84
a690dc0
a7f3ef5
2d3bb87
d5be970
bb96450
b4b76e4
af23ce1
f1bbbb7
7aff9bb
0894bec
02789c4
98d3637
7665012
4eb5d55
18a3ef8
99845c3
da7773a
9071bce
78da58d
bda3a6c
0dad160
aae028c
4f9e824
802e60f
62eedae
70c87fb
8552f8e
412be7b
d013895
e8bbb61
9ff07bf
e04d369
c982d43
caf0052
3f8bd0b
fe09ada
4cf8108
56b8d3b
6e5ca46
b8df865
9822d42
4504cd6
a9c9094
2c233f5
7010ea3
f8b44bc
925599b
36ef864
e0b673e
f4b6488
fc69d89
33ba9dd
f18830a
42fb25a
402ac33
5326ec0
c97f728
5406749
cf47962
60b3c15
4352c0c
e1f131b
27e5f24
b51f921
1e1f759
43f398f
a66db2b
0bb826a
932144a
19c546a
a1f63fc
750ebc2
82a8847
3944ed1
10bbc70
2ab0669
d6c1b2a
a9b9809
32f0a9e
6ce0de3
7b0799e
c73b626
bbc5720
8886b8c
e0480a8
ccb1b57
c32785f
7c97a3c
b1c57cc
a3cad5c
3939765
2edfedd
0ee5996
d8b674c
8adb318
ebd786a
f598cbc
c04817d
34c5c19
6739979
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,7 @@ public class DruidDimensionsLoader extends Loader<Boolean> { | |
|
||
/** | ||
* DruidDimensionsLoader fetches data from Druid and adds it to the dimension cache. | ||
* The dimensions loaded are taken from the system config. | ||
* | ||
* @param physicalTableDictionary The physical tables | ||
* @param dimensionDictionary The dimensions to update | ||
|
@@ -83,6 +84,30 @@ public DruidDimensionsLoader( | |
PhysicalTableDictionary physicalTableDictionary, | ||
DimensionDictionary dimensionDictionary, | ||
DruidWebService druidWebService | ||
) { | ||
this( | ||
physicalTableDictionary, | ||
dimensionDictionary, | ||
//Our configuration framework automatically converts a comma-separated config value into a list. | ||
SYSTEM_CONFIG.getListProperty(DRUID_DIM_LOADER_DIMENSIONS), | ||
druidWebService | ||
); | ||
} | ||
|
||
/** | ||
* DruidDimensionsLoader fetches data from Druid and adds it to the dimension cache. | ||
* The dimensions to be loaded can be passed in as a parameter. | ||
* | ||
* @param physicalTableDictionary The physical tables | ||
* @param dimensionDictionary The dimension dictionary to load dimensions from. | ||
* @param dimensionsToLoad The dimensions to use. | ||
* @param druidWebService The druid webservice to query. | ||
*/ | ||
public DruidDimensionsLoader( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we move this constructor up under the other one? In general, it's best to group constructors, since they tend to call each other, and it's easier to see what's going on. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
PhysicalTableDictionary physicalTableDictionary, | ||
DimensionDictionary dimensionDictionary, | ||
List<String> dimensionsToLoad, | ||
DruidWebService druidWebService | ||
) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When is this constructor needed, is it actually needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This constructor is called from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
super( | ||
DruidDimensionsLoader.class.getSimpleName(), | ||
|
@@ -100,17 +125,14 @@ public DruidDimensionsLoader( | |
|
||
lastRunTimestamp = new AtomicReference<>(); | ||
|
||
//Our configuration framework automatically converts a comma-separated config value into a list. | ||
List<String> dimensionStr = SYSTEM_CONFIG.getListProperty(DRUID_DIM_LOADER_DIMENSIONS); | ||
|
||
// A DruidSearchQuery requires a list of dimensions, which we would have to explicitly create at serialization | ||
// time if `dimensions` were a flat list instead of a list of singleton lists. | ||
dimensions = dimensionStr.stream() | ||
// A DruidSearchQuery requires a list of dimensions, which we would have to explicitly create at serialization | ||
// time if `dimensions` were a flat list instead of a list of singleton lists. | ||
this.dimensions = dimensionsToLoad.stream() | ||
.map(dimensionDictionary::findByApiName) | ||
.map(Collections::singletonList) | ||
.collect(Collectors.toList()); | ||
|
||
dataSources = physicalTableDictionary.values().stream() | ||
this.dataSources = physicalTableDictionary.values().stream() | ||
.filter(physicalTable -> physicalTable instanceof ConcretePhysicalTable) | ||
.map(physicalTable -> (ConcretePhysicalTable) physicalTable) | ||
.map(TableDataSource::new) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2016 Yahoo Inc. | ||
// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms. | ||
package com.yahoo.bard.webservice.data.config.dimension; | ||
|
||
import com.yahoo.bard.webservice.data.dimension.DimensionField; | ||
|
||
/** | ||
* DimensionField enum. | ||
*/ | ||
public enum DefaultDimensionField implements DimensionField { | ||
ID("Dimension ID"); | ||
|
||
private String description; | ||
private String camelName; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param description Description of this field | ||
*/ | ||
DefaultDimensionField(String description) { | ||
this.description = description; | ||
this.camelName = name(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return camelName; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return camelName; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
Fili Generic Loader Application | ||
================================== | ||
|
||
This application will automatically configure fili to work with **any** instance of Druid and show the basic metrics and dimensions. This lets you test what it's like using Fili without putting any effort into setting it up. | ||
|
||
In order to set up, this will connect to druid at [http://localhost:8081/druid/coordinator/v1](http://localhost:8081/druid/coordinator/v1). If your set up is different, you'll have to change the `bard__druid_coord` url in `applicationConfig.properties`. | ||
|
||
## Setup and Launching | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should probably mention the default druid endpoint we are expecting somewhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
1. Have a [Druid](http://druid.io/docs/latest/tutorials/quickstart.html) cluster running on your Unix based machine. | ||
|
||
2. Clone this repository to your computer. | ||
```bash | ||
git clone git@github.com:yahoo/fili.git | ||
``` | ||
3. Use Maven to install and launch the Fili Generic example: | ||
|
||
|
||
```bash | ||
cd fili | ||
mvn install | ||
mvn -pl fili-generic-example exec:java | ||
``` | ||
|
||
- Note that if your setup is different you can adjust it by changing the default parameters below | ||
|
||
```bash | ||
mvn -pl fili-generic-example exec:java -Dbard__fili_port=9998 -Dbard__druid_coord=http://localhost:8081/druid/coordinator/v1 | ||
``` | ||
|
||
From another window, run a test query against the default druid data. | ||
|
||
## Example Queries | ||
|
||
Here are some sample queries that you can run to verify your server: | ||
|
||
### Any Server | ||
|
||
- List tables: | ||
|
||
GET http://localhost:9998/v1/tables | ||
|
||
- List dimensions: | ||
|
||
GET http://localhost:9998/v1/dimensions | ||
|
||
- List metrics: | ||
|
||
GET http://localhost:9998/v1/metrics/ | ||
|
||
### Specific to Wikipedia data | ||
|
||
- If everything is working, the query below | ||
```bash | ||
curl "http://localhost:9998/v1/data/wikiticker/day/?metrics=deleted&dateTime=2015-09-12/PT24H" -H "Content-Type: application/json" | python -m json.tool | ||
``` | ||
should show something like: | ||
``` | ||
{ | ||
"rows": [{ | ||
"dateTime": "2015-09-12 00:00:00.000", | ||
"deleted": 394298.0 | ||
}] | ||
} | ||
``` | ||
|
||
- Count of edits by hour for the last 72 hours: | ||
|
||
GET http://localhost:9998/v1/data/wikiticker/day/?metrics=count&dateTime=PT72H/current | ||
Note: this will should be something like the response below unless you have streaming data. | ||
```json | ||
{ | ||
"rows": [], | ||
"meta": { | ||
"missingIntervals": ["2017-03-30 00:00:00.000/2017-04-02 00:00:00.000"] | ||
} | ||
} | ||
``` | ||
|
||
- Show debug info, including the query sent to Druid: | ||
|
||
GET http://localhost:9998/v1/data/wikiticker/day/?format=debug&metrics=count&dateTime=PT72H/current | ||
|
||
## Notable Restrictions | ||
|
||
- Using this is great for testing out fili and druid, but it can't do interesting things with metrics. | ||
- This can only use 1 timegrain even though a datasource in druid *could* have more. | ||
|
||
## Importing and Running in IntelliJ | ||
|
||
1. In IntelliJ, go to `File -> Open` | ||
2. Select the `pom.xml` file at the root of the project | ||
3. Run `GenericMain` which can be found in `fili-generic-example` (e.g. right click and choose run) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we update the javadoc on the other constructor to indicate what it's doing, and call out what it's doing differently than this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍