Moved KorapNode to server/Node
diff --git a/src/main/java/de/ids_mannheim/korap/response/collector/MatchCollectorDB.java b/src/main/java/de/ids_mannheim/korap/response/collector/MatchCollectorDB.java
index dd2c09f..d58b473 100644
--- a/src/main/java/de/ids_mannheim/korap/response/collector/MatchCollectorDB.java
+++ b/src/main/java/de/ids_mannheim/korap/response/collector/MatchCollectorDB.java
@@ -1,5 +1,5 @@
package de.ids_mannheim.korap.response.collector;
-import de.ids_mannheim.korap.KorapNode;
+import de.ids_mannheim.korap.server.Node;
import de.ids_mannheim.korap.response.Match;
import de.ids_mannheim.korap.response.MatchCollector;
import com.fasterxml.jackson.annotation.*;
@@ -15,7 +15,7 @@
public class MatchCollectorDB extends MatchCollector {
// Logger
- private final static Logger log = LoggerFactory.getLogger(KorapNode.class);
+ private final static Logger log = LoggerFactory.getLogger(Node.class);
/*
* Todo: In case there are multiple threads searching,
diff --git a/src/main/java/de/ids_mannheim/korap/KorapNode.java b/src/main/java/de/ids_mannheim/korap/server/Node.java
similarity index 94%
rename from src/main/java/de/ids_mannheim/korap/KorapNode.java
rename to src/main/java/de/ids_mannheim/korap/server/Node.java
index 10a9710..4bf00ea 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapNode.java
+++ b/src/main/java/de/ids_mannheim/korap/server/Node.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap;
+package de.ids_mannheim.korap.server;
import java.util.*;
import java.io.*;
@@ -23,13 +23,13 @@
*
* @author diewald
*/
-public class KorapNode {
+public class Node {
// Base URI the Grizzly HTTP server will listen on
public static String BASE_URI = "http://localhost:8080/";
// Logger
- private final static Logger log = LoggerFactory.getLogger(KorapNode.class);
+ private final static Logger log = LoggerFactory.getLogger(Node.class);
// Index
private static KrillIndex index;
@@ -60,7 +60,7 @@
// Load configuration
try {
InputStream file = new FileInputStream(
- KorapNode.class.getClassLoader()
+ Node.class.getClassLoader()
.getResource("server.properties")
.getFile()
);
@@ -69,8 +69,8 @@
// Node properties
path = prop.getProperty("lucene.indexDir", path);
- name = prop.getProperty("lucene.node.name", name);
- BASE_URI = prop.getProperty("lucene.node.baseURI", BASE_URI);
+ name = prop.getProperty("lucene.server.name", name);
+ BASE_URI = prop.getProperty("lucene.server.baseURI", BASE_URI);
// Database properties
dbUser = prop.getProperty("lucene.db.user", dbUser);
@@ -86,7 +86,7 @@
// create a resource config that scans for JAX-RS resources and providers
// in de.ids_mannheim.korap.server package
final ResourceConfig rc =
- new ResourceConfig().packages("de.ids_mannheim.korap.node");
+ new ResourceConfig().packages("de.ids_mannheim.korap.server");
// create and start a new instance of grizzly http server
// exposing the Jersey application at BASE_URI
@@ -98,7 +98,7 @@
// create a resource config that scans for JAX-RS resources and providers
// in de.ids_mannheim.korap.server package
final ResourceConfig rc =
- new ResourceConfig().packages("de.ids_mannheim.korap.node");
+ new ResourceConfig().packages("de.ids_mannheim.korap.server");
name = nodeName;
path = indexPath;
diff --git a/src/main/java/de/ids_mannheim/korap/node/Ping.java b/src/main/java/de/ids_mannheim/korap/server/Ping.java
similarity index 89%
rename from src/main/java/de/ids_mannheim/korap/node/Ping.java
rename to src/main/java/de/ids_mannheim/korap/server/Ping.java
index 8ae1725..ebaba96 100644
--- a/src/main/java/de/ids_mannheim/korap/node/Ping.java
+++ b/src/main/java/de/ids_mannheim/korap/server/Ping.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.node;
+package de.ids_mannheim.korap.server;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
diff --git a/src/main/java/de/ids_mannheim/korap/node/Resource.java b/src/main/java/de/ids_mannheim/korap/server/Resource.java
similarity index 91%
rename from src/main/java/de/ids_mannheim/korap/node/Resource.java
rename to src/main/java/de/ids_mannheim/korap/server/Resource.java
index 3e1c3d2..4af504e 100644
--- a/src/main/java/de/ids_mannheim/korap/node/Resource.java
+++ b/src/main/java/de/ids_mannheim/korap/server/Resource.java
@@ -1,4 +1,4 @@
-package de.ids_mannheim.korap.node;
+package de.ids_mannheim.korap.server;
import java.io.*;
@@ -20,7 +20,7 @@
import javax.ws.rs.ext.WriterInterceptorContext;
import javax.ws.rs.WebApplicationException;
-import de.ids_mannheim.korap.KorapNode;
+import de.ids_mannheim.korap.server.Node;
import de.ids_mannheim.korap.KrillIndex;
import de.ids_mannheim.korap.Krill;
import de.ids_mannheim.korap.KrillCollection;
@@ -60,7 +60,7 @@
private String version;
// Initiate Logger
- private final static Logger log = LoggerFactory.getLogger(KorapNode.class);
+ private final static Logger log = LoggerFactory.getLogger(Node.class);
// This advices the java compiler to ignore all loggings
public static final boolean DEBUG = false;
@@ -89,13 +89,13 @@
@GET
@Produces(MediaType.APPLICATION_JSON)
public String info () {
- KrillIndex index = KorapNode.getIndex();
+ KrillIndex index = Node.getIndex();
KorapResponse kresp = new KorapResponse();
- kresp.setNode(KorapNode.getName());
+ kresp.setNode(Node.getName());
kresp.setName(index.getName());
kresp.setVersion(index.getVersion());
- kresp.setListener(KorapNode.getListener());
+ kresp.setListener(Node.getListener());
long texts = -1;
/*
kresp.addMessage(
@@ -136,10 +136,10 @@
log.trace("Added new document with unique identifier {}", uid);
// Get index
- KrillIndex index = KorapNode.getIndex();
+ KrillIndex index = Node.getIndex();
KorapResponse kresp = new KorapResponse();
- kresp.setNode(KorapNode.getName());
+ kresp.setNode(Node.getName());
if (index == null) {
kresp.addError(601, "Unable to find index");
@@ -180,9 +180,9 @@
public String commit () {
// Get index
- KrillIndex index = KorapNode.getIndex();
+ KrillIndex index = Node.getIndex();
KorapResponse kresp = new KorapResponse();
- kresp.setNode(KorapNode.getName());
+ kresp.setNode(Node.getName());
if (index == null) {
kresp.addError(601, "Unable to find index");
@@ -219,7 +219,7 @@
public String find (String json, @Context UriInfo uri) {
// Get index
- KrillIndex index = KorapNode.getIndex();
+ KrillIndex index = Node.getIndex();
// Search index
if (index != null) {
@@ -246,13 +246,13 @@
return ks.apply(index).toJsonString();
};
KorapResult kr = new KorapResult();
- kr.setNode(KorapNode.getName());
+ kr.setNode(Node.getName());
kr.addError(610, "Missing request parameters", "No unique IDs were given");
return kr.toJsonString();
};
KorapResponse kresp = new KorapResponse();
- kresp.setNode(KorapNode.getName());
+ kresp.setNode(Node.getName());
kresp.setName(index.getName());
kresp.setVersion(index.getVersion());
@@ -276,12 +276,12 @@
@Context UriInfo uri) {
// Get index
- KrillIndex index = KorapNode.getIndex();
+ KrillIndex index = Node.getIndex();
// No index found
if (index == null) {
KorapResponse kresp = new KorapResponse();
- kresp.setNode(KorapNode.getName());
+ kresp.setNode(Node.getName());
kresp.addError(601, "Unable to find index");
return kresp.toJsonString();
};
@@ -289,15 +289,15 @@
// Get the database
try {
MatchCollectorDB mc = new MatchCollectorDB(1000, "Res_" + resultID);
- Connection conn = KorapNode.getDBPool().getConnection();
- mc.setDBPool("mysql", KorapNode.getDBPool(), conn);
+ Connection conn = Node.getDBPool().getConnection();
+ mc.setDBPool("mysql", Node.getDBPool(), conn);
// TODO: Only search in self documents (REPLICATION FTW!)
Krill ks = new Krill(json);
MatchCollector result = index.collect(ks, mc);
- result.setNode(KorapNode.getName());
+ result.setNode(Node.getName());
return result.toJsonString();
}
catch (SQLException e) {
@@ -305,7 +305,7 @@
};
KorapResponse kresp = new KorapResponse();
- kresp.setNode(KorapNode.getName());
+ kresp.setNode(Node.getName());
kresp.setName(index.getName());
kresp.setVersion(index.getVersion());
@@ -334,17 +334,17 @@
public String search (String json) {
// Get index
- KrillIndex index = KorapNode.getIndex();
+ KrillIndex index = Node.getIndex();
// Search index
if (index != null) {
KorapResult kr = new Krill(json).apply(index);
- kr.setNode(KorapNode.getName());
+ kr.setNode(Node.getName());
return kr.toJsonString();
};
KorapResponse kresp = new KorapResponse();
- kresp.setNode(KorapNode.getName());
+ kresp.setNode(Node.getName());
kresp.setName(index.getName());
kresp.setVersion(index.getVersion());
@@ -359,7 +359,7 @@
@Context UriInfo uri) {
// Get index
- KrillIndex index = KorapNode.getIndex();
+ KrillIndex index = Node.getIndex();
// Search index
if (index != null) {
@@ -444,7 +444,7 @@
public String collection (String json) {
// Get index
- KrillIndex index = KorapNode.getIndex();
+ KrillIndex index = Node.getIndex();
if (index == null)
return "{\"documents\" : -1, error\" : \"No index given\" }";