-
Notifications
You must be signed in to change notification settings - Fork 51
Integration of ElasticSearch v1.0 (GROUND - 6) #68
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
base: master
Are you sure you want to change the base?
Changes from 24 commits
c8a80a7
acb9a99
c1b319f
720ffdf
ac25c16
47257da
a87ea7f
03b2f8e
553d079
ef72d5d
2e709e5
3bc5466
73c86d9
f22645c
8ffb0fe
357b429
450bcf0
77511ce
aa50b59
0e1b747
1dac8ec
e788608
1253014
b150228
a639cc0
a6b25a1
cb6dcc0
2f33f01
2e79918
bc7dc23
a881dc1
648c970
fd1c51f
39656a3
4d7473c
7b10afb
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 |
|---|---|---|
|
|
@@ -14,14 +14,7 @@ | |
|
|
||
| package edu.berkeley.ground; | ||
|
|
||
| import edu.berkeley.ground.dao.models.EdgeFactory; | ||
| import edu.berkeley.ground.dao.models.EdgeVersionFactory; | ||
| import edu.berkeley.ground.dao.models.GraphFactory; | ||
| import edu.berkeley.ground.dao.models.GraphVersionFactory; | ||
| import edu.berkeley.ground.dao.models.NodeFactory; | ||
| import edu.berkeley.ground.dao.models.NodeVersionFactory; | ||
| import edu.berkeley.ground.dao.models.StructureFactory; | ||
| import edu.berkeley.ground.dao.models.StructureVersionFactory; | ||
| import edu.berkeley.ground.dao.models.*; | ||
|
Member
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. We're using the Google Java style guide which specifies no |
||
| import edu.berkeley.ground.dao.usage.LineageEdgeFactory; | ||
| import edu.berkeley.ground.dao.usage.LineageEdgeVersionFactory; | ||
| import edu.berkeley.ground.dao.usage.LineageGraphFactory; | ||
|
|
@@ -37,6 +30,7 @@ | |
| import edu.berkeley.ground.resources.LineageGraphsResource; | ||
| import edu.berkeley.ground.resources.NodesResource; | ||
| import edu.berkeley.ground.resources.StructuresResource; | ||
| import edu.berkeley.ground.resources.TagsResource; | ||
| import edu.berkeley.ground.util.CassandraFactories; | ||
| import edu.berkeley.ground.util.FactoryGenerator; | ||
| import edu.berkeley.ground.util.Neo4jFactories; | ||
|
|
@@ -60,9 +54,11 @@ public class GroundServer extends Application<GroundServerConfiguration> { | |
| private StructureVersionFactory structureVersionFactory; | ||
| private LineageGraphFactory lineageGraphFactory; | ||
| private LineageGraphVersionFactory lineageGraphVersionFactory; | ||
| private TagFactory tagFactory; | ||
|
|
||
| public static void main(String[] args) throws Exception { | ||
| new GroundServer().run(args); | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -135,16 +131,17 @@ public void run(GroundServerConfiguration configuration, Environment environment | |
| this.structureVersionFactory, | ||
| dbClient); | ||
| final LineageGraphsResource lineageGraphsResource = new LineageGraphsResource( | ||
| this.lineageGraphFactory, | ||
| this.lineageGraphVersionFactory, | ||
| dbClient); | ||
| this.lineageGraphFactory, this.lineageGraphVersionFactory, dbClient); | ||
| final TagsResource tagsResource = new TagsResource(this.tagFactory); | ||
|
|
||
|
|
||
| environment.jersey().register(edgesResource); | ||
| environment.jersey().register(graphsResource); | ||
| environment.jersey().register(lineageEdgesResource); | ||
| environment.jersey().register(nodesResource); | ||
| environment.jersey().register(structuresResource); | ||
| environment.jersey().register(lineageGraphsResource); | ||
| environment.jersey().register(tagsResource); | ||
| } | ||
|
|
||
| private void setPostgresFactories(PostgresClient postgresClient, int machineId, int numMachines) { | ||
|
|
@@ -174,5 +171,6 @@ private void setFactories(FactoryGenerator factoryGenerator) { | |
| structureVersionFactory = factoryGenerator.getStructureVersionFactory(); | ||
| lineageGraphFactory = factoryGenerator.getLineageGraphFactory(); | ||
| lineageGraphVersionFactory = factoryGenerator.getLineageGraphVersionFactory(); | ||
| tagFactory = factoryGenerator.getTagFactory(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,4 +28,5 @@ public abstract class TagFactory { | |
| public abstract List<Long> getVersionIdsByTag(String tag) throws GroundException; | ||
|
|
||
| public abstract List<Long> getItemIdsByTag(String tag) throws GroundException; | ||
|
|
||
|
Member
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. Please remove unnecessary whitespace. |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
|
|
||
| package edu.berkeley.ground.dao.models.cassandra; | ||
|
|
||
|
|
||
| import edu.berkeley.ground.dao.models.TagFactory; | ||
| import edu.berkeley.ground.db.CassandraClient; | ||
| import edu.berkeley.ground.db.CassandraResults; | ||
|
|
@@ -23,6 +24,7 @@ | |
| import edu.berkeley.ground.exceptions.GroundException; | ||
| import edu.berkeley.ground.model.models.Tag; | ||
| import edu.berkeley.ground.model.versions.GroundType; | ||
| import edu.berkeley.ground.util.ElasticSearch; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
|
|
@@ -76,16 +78,17 @@ private Map<String, Tag> retrieveFromDatabaseById(long id, String keyPrefix) | |
| return result; | ||
| } | ||
|
|
||
| @Override | ||
| public List<Long> getVersionIdsByTag(String tag) throws GroundException { | ||
| return this.getIdsByTag(tag, "rich_version"); | ||
| return ElasticSearch.getSearchResponse("rich_version", tag); | ||
|
Member
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. We should probably have a configuration option that allows people to turn on / off ElasticSearch use. Let's add a field to the config and pass it through to the |
||
| } | ||
|
|
||
| @Override | ||
| public List<Long> getItemIdsByTag(String tag) throws GroundException { | ||
| return this.getIdsByTag(tag, "item"); | ||
| return ElasticSearch.getSearchResponse("item", tag); | ||
|
|
||
| } | ||
|
|
||
|
|
||
|
|
||
| private List<Long> getIdsByTag(String tag, String keyPrefix) throws GroundException { | ||
| List<Long> result = new ArrayList<>(); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package edu.berkeley.ground.resources; | ||
|
|
||
| import com.codahale.metrics.annotation.Timed; | ||
| import edu.berkeley.ground.dao.models.TagFactory; | ||
| import edu.berkeley.ground.exceptions.GroundException; | ||
| import edu.berkeley.ground.model.models.Tag; | ||
| import io.swagger.annotations.Api; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import javax.ws.rs.*; | ||
| import javax.ws.rs.core.MediaType; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
|
|
||
| @Path("/tags") | ||
| @Api(value = "/tags", description = "Interact with tags") | ||
| @Produces(MediaType.APPLICATION_JSON) | ||
| @Consumes(MediaType.APPLICATION_JSON) | ||
| public class TagsResource { | ||
| private static final Logger LOGGER = LoggerFactory.getLogger(NodesResource.class); | ||
|
|
||
| private final TagFactory tagFactory; | ||
| public TagsResource(TagFactory tagFactory) { | ||
| this.tagFactory = tagFactory; | ||
|
|
||
| } | ||
|
|
||
| @GET | ||
| @Timed | ||
| @Path("/versions/{id}") | ||
| public Map<String, Tag> retrieveFromDatabaseByVersionId(@PathParam("id") long id) throws GroundException { | ||
| LOGGER.info("Retrieving version with id: " + id + "."); | ||
| return this.tagFactory.retrieveFromDatabaseByVersionId(id); | ||
| } | ||
|
|
||
| @GET | ||
| @Timed | ||
| @Path("/items/{id}") | ||
| public Map<String, Tag> retrieveFromDatabaseByItemId(@PathParam("id") long id) throws GroundException { | ||
| LOGGER.info("Retrieving item with id: " + id + "."); | ||
| return this.tagFactory.retrieveFromDatabaseByItemId(id); | ||
| } | ||
|
|
||
| @GET | ||
| @Timed | ||
| @Path("/versions/{*name}") | ||
|
Member
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. Is there a reason there's a |
||
| public List<Long> getVersionIdsByTag(@PathParam("*name") String tag) throws GroundException { | ||
| LOGGER.info("Retrieving all version ids with tag: " + tag + "."); | ||
| return this.tagFactory.getVersionIdsByTag(tag); | ||
| } | ||
|
|
||
| @GET | ||
| @Timed | ||
| @Path("/items/{*name}") | ||
| public List<Long> getItemIdsByTag(@PathParam("*name") String tag) throws GroundException { | ||
| LOGGER.info("Retrieving all item ids with tag: " + tag + "."); | ||
| return this.tagFactory.getItemIdsByTag(tag); | ||
| } | ||
|
|
||
|
Member
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. Whitespace. |
||
|
|
||
|
|
||
|
|
||
| } | ||
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.
The version should be a variable in the properties field of the POM.