-
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 15 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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
Fili Wikipedia Example Application | ||
================================== | ||
|
||
This example is an entirely self contained example that provides a Fili application for the | ||
[Druid Wikipedia example](http://druid.io/docs/latest/tutorials/quickstart.html). | ||
|
||
## Setup and Launching | ||
|
||
1. Follow the [Druid instructions](http://druid.io/docs/latest/tutorials/quickstart.html) to bring up a local Druid | ||
cluster 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 Wikipedia example: | ||
|
||
```bash | ||
cd fili | ||
mvn install | ||
mvn -pl fili-wikipedia-example exec:java | ||
``` | ||
From another window, run a test query against the default druid data: | ||
|
||
```bash | ||
curl "http://localhost:9998/v1/data/wikipedia/hour/?metrics=deleted&dateTime=2015-09-12/PT2H" -H "Content-Type: application/json" | python -m json.tool | ||
``` | ||
If everything is working you should see something like: | ||
``` | ||
{ | ||
"rows": [ | ||
{ | ||
"dateTime": "2015-09-12 00:00:00.000", | ||
"deleted": 1761.0 | ||
}, | ||
{ | ||
"dateTime": "2015-09-12 01:00:00.000", | ||
"deleted": 16208.0 | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## Example Queries | ||
|
||
Here are some sample queries that you can run to verify your 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/ | ||
|
||
- Count of edits by hour for the last 72 hours: | ||
|
||
GET http://localhost:9998/v1/data/wikipedia/hour/?metrics=count&dateTime=PT72H/current | ||
|
||
- Show debug info, including the query sent to Druid: | ||
|
||
GET http://localhost:9998/v1/data/wikipedia/hour/?format=debug&metrics=count&dateTime=PT72H/current | ||
|
||
## 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 `WikiMain` which can be found in `fili-wikipedia-example` (e.g. right click and choose run) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<prerequisites> | ||
<maven>3.0</maven> | ||
</prerequisites> | ||
|
||
<parent> | ||
<groupId>com.yahoo.fili</groupId> | ||
<artifactId>fili-parent-pom</artifactId> | ||
<version>0.8-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>fili-generic-example</artifactId> | ||
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 I change the the name |
||
<packaging>war</packaging> | ||
<name>Fili: Generic Example</name> | ||
<description>Fili Wikipedia Example serves as a standalone sample implementation using core Fili services to stand | ||
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. Might need to update the description to be non-wiki, would be nice if we change all the wiki names in the code also. 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. Was there anywhere specific in the code you remember this? I know the package still says wiki 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. The package is the most likely culprit. But you could do a |
||
in front of the Druid wiki tutorial and automatically configure | ||
</description> | ||
|
||
<licenses> | ||
<license> | ||
<name>The Apache Software License, Version 2.0</name> | ||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
<distribution>repo</distribution> | ||
</license> | ||
</licenses> | ||
|
||
<properties> | ||
<maven.deploy.skip>true</maven.deploy.skip> | ||
|
||
<checkstyle.config.location>../checkstyle-style.xml</checkstyle.config.location> | ||
<checkstyle.suppressions.location>../checkstyle-suppressions.xml</checkstyle.suppressions.location> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.yahoo.fili</groupId> | ||
<artifactId>fili</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.yahoo.fili</groupId> | ||
<artifactId>fili-core</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.yahoo.fili</groupId> | ||
<artifactId>fili-core</artifactId> | ||
<type>test-jar</type> | ||
</dependency> | ||
|
||
<!-- Servlet API --> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
</dependency> | ||
|
||
<!-- Jersey --> | ||
<dependency> | ||
<groupId>org.glassfish.jersey.containers</groupId> | ||
<artifactId>jersey-container-servlet</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish.jersey.core</groupId> | ||
<artifactId>jersey-common</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish.jersey.core</groupId> | ||
<artifactId>jersey-server</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
</dependency> | ||
|
||
<!-- Test --> | ||
<dependency> | ||
<groupId>org.glassfish.jersey.test-framework</groupId> | ||
<artifactId>jersey-test-framework-core</artifactId> | ||
</dependency> | ||
|
||
<!-- Jersey Test 'grizzly' container --> | ||
<dependency> | ||
<groupId>org.glassfish.jersey.test-framework.providers</groupId> | ||
<artifactId>jersey-test-framework-provider-grizzly2</artifactId> | ||
</dependency> | ||
|
||
<!-- Jetty Servlet Support --> | ||
<dependency> | ||
<groupId>org.eclipse.jetty</groupId> | ||
<artifactId>jetty-servlet</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-antrun-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>1</id> | ||
<phase>prepare-package</phase> | ||
<goals> | ||
<goal>run</goal> | ||
</goals> | ||
<configuration> | ||
<target> | ||
<exec executable="/bin/sh"> | ||
<env key="BUILD_NUMBER" value="${project.build}" /> | ||
<arg value="-c" /> | ||
<arg | ||
value="echo ${project.version}.${BUILD_NUMBER:=0} | sed -e s/-SNAPSHOT//g > target/buildVersion" /> | ||
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. Try move the ending 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. 👍 |
||
</exec> | ||
</target> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-checkstyle-plugin</artifactId> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<version>1.1</version> | ||
<executions> | ||
<execution><goals><goal>java</goal></goals></execution> | ||
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. Indent each of the level would be nice. 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. 👍 |
||
</executions> | ||
<configuration> | ||
<mainClass>com.yahoo.wiki.webservice.application.WikiMain</mainClass> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 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.wiki.webservice.application; | ||
|
||
import com.yahoo.bard.webservice.data.config.dimension.DimensionConfig; | ||
import com.yahoo.bard.webservice.data.config.metric.MetricLoader; | ||
import com.yahoo.bard.webservice.data.config.table.TableLoader; | ||
import com.yahoo.bard.webservice.druid.client.DruidWebService; | ||
import com.yahoo.wiki.webservice.data.config.auto.ConfigLoader; | ||
import com.yahoo.wiki.webservice.data.config.auto.StaticWikiConfigLoader; | ||
import com.yahoo.wiki.webservice.data.config.dimension.GenericDimensions; | ||
import com.yahoo.wiki.webservice.data.config.metric.GenericMetricLoader; | ||
import com.yahoo.wiki.webservice.data.config.table.GenericTableLoader; | ||
|
||
import java.util.LinkedHashSet; | ||
|
||
/** | ||
* Created by kevin on 3/7/2017. | ||
*/ | ||
public class GenericBinder { | ||
private static GenericBinder genericBinder; | ||
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. I'm not sure this should be called Binder in that it does not implement org.glassfish.hk2.utilities.Binder which is the sense of Binder used in the AbstractBinderFactory. 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. Also, class javadoc. 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 I just remove GenericBinder? It seemed appropriate at the time but looking back it doesn't seem very necessary |
||
private 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. This class has no longer has unused private fields |
||
private ConfigLoader configLoader; | ||
|
||
private GenericBinder() { | ||
configLoader = new StaticWikiConfigLoader(); | ||
//druidWebService = null; //TODO how to initialize with actual 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. I may be missing some context here. Why is this using the hard-coding StaticWikiConfigLoader? 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 was before I found out how to get a reference to a DruidWebService from GenericBinderFactory (it's been removed now) |
||
//configLoader = new DruidNavigator(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. Make it a constructor parameter. Inject that when you construct the binder below in the binder factory. |
||
|
||
public static GenericBinder getInstance() { | ||
if (genericBinder == null) { | ||
genericBinder = new GenericBinder(); | ||
} | ||
return genericBinder; | ||
} | ||
|
||
public TableLoader buildTableLoader() { | ||
return new GenericTableLoader(configLoader); | ||
} | ||
|
||
public LinkedHashSet<DimensionConfig> buildDimensionConfigurations() { | ||
return new LinkedHashSet<>(new GenericDimensions(configLoader).getAllDimensionConfigurations()); | ||
} | ||
|
||
public MetricLoader buildMetricLoader() { | ||
return new GenericMetricLoader(configLoader); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// 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.wiki.webservice.application; | ||
|
||
import com.yahoo.bard.webservice.application.AbstractBinderFactory; | ||
import com.yahoo.bard.webservice.data.config.dimension.DimensionConfig; | ||
import com.yahoo.bard.webservice.data.config.metric.MetricLoader; | ||
import com.yahoo.bard.webservice.data.config.table.TableLoader; | ||
|
||
import java.util.LinkedHashSet; | ||
|
||
/** | ||
* Wiki specialization of the Abstract Binder factory, applying Wiki configuration objects. | ||
*/ | ||
public class WikiBinderFactory extends AbstractBinderFactory { | ||
|
||
@Override | ||
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. Rather than have the static instance held in GenericBinder, you could hold the static instance here and have GenericBinder be more static. e.g. GenericBinder genericBinder; getGenericBinder() { protected MetricLoader getMetricLoader() { |
||
protected MetricLoader getMetricLoader() { | ||
return GenericBinder.getInstance().buildMetricLoader(); | ||
} | ||
|
||
@Override | ||
protected LinkedHashSet<DimensionConfig> getDimensionConfigurations() { | ||
return GenericBinder.getInstance().buildDimensionConfigurations(); | ||
} | ||
|
||
@Override | ||
protected TableLoader getTableLoader() { | ||
return GenericBinder.getInstance().buildTableLoader(); | ||
} | ||
} |
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.
Should probably mention the default druid endpoint we are expecting somewhere.
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.
👍