Skip to content
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

Micronaut #22

Merged
merged 8 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
org.gradle.jvmargs=-Djavax.xml.accessExternalSchema=all
luceneVersion=8.3.0
mongoDriverVersion=3.11.0
mongoDriverVersion=3.12.0
grpcVersion=1.23.0
protobufVersion=3.9.0
protobufVersion=3.9.0
micronautVersion=1.2.8
2 changes: 1 addition & 1 deletion zulia-common/src/main/java/io/zulia/ZuliaConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public interface ZuliaConstants {
String FIELDS_URL = "fields";
String TERMS_URL = "terms";
String INDEX_URL = "index";
String INDEXES_URL = "indexes";
String INDEXES_URL = "/indexes";
String NODES_URL = "nodes";
String STATS_URL = "stats";

Expand Down
15 changes: 15 additions & 0 deletions zulia-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ description = "Zulia Server"
val luceneVersion: String by project
val mongoDriverVersion: String by project
val protobufVersion: String by project
val micronautVersion: String by project

defaultTasks("build", "installDist")

Expand All @@ -34,6 +35,20 @@ dependencies {
api("com.cedarsoftware:json-io:4.10.1")

api("org.mongodb:mongodb-driver-sync:$mongoDriverVersion")

implementation("io.reactivex.rxjava2:rxjava:2.2.0")

annotationProcessor("io.micronaut:micronaut-inject-java:$micronautVersion")
implementation("io.micronaut:micronaut-http-client:$micronautVersion")
implementation("io.micronaut:micronaut-http-server-netty:$micronautVersion")
implementation("io.micronaut:micronaut-inject:$micronautVersion")
implementation("io.micronaut:micronaut-runtime:$micronautVersion")

compileOnly("io.micronaut:micronaut-inject-java:$micronautVersion")
testCompile("junit:junit:4.12")

implementation("javax.annotation:javax.annotation-api:1.3.2")
annotationProcessor("javax.annotation:javax.annotation-api:1.3.2")
}

val zuliaScriptTask = tasks.getByName<CreateStartScripts>("startScripts")
Expand Down
3 changes: 3 additions & 0 deletions zulia-server/src/main/java/io/zulia/server/cmd/ZuliaD.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.zulia.server.node.ZuliaNode;
import io.zulia.server.util.MongoProvider;
import io.zulia.server.util.ServerNameHelper;
import io.zulia.server.util.ZuliaNodeProvider;
import org.apache.lucene.facet.FacetsConfig;
import org.apache.lucene.search.BooleanQuery;

Expand Down Expand Up @@ -181,6 +182,8 @@ public static void main(String[] args) {
displayNodes(nodeService, "Registered nodes:");

ZuliaNode zuliaNode = new ZuliaNode(zuliaConfig, nodeService);

ZuliaNodeProvider.setZuliaNode(zuliaNode);
zuliaNode.start();
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import io.zulia.server.config.cluster.MongoAuth;
import io.zulia.server.config.cluster.MongoServer;

import javax.inject.Singleton;
import java.util.Collections;
import java.util.List;

@Singleton
public class ZuliaConfig {

private String dataPath = "data";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import org.bson.Document;
import org.bson.conversions.Bson;

import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Singleton
public class MongoNodeService implements NodeService {

private static final String NODES = "nodes";
Expand All @@ -22,7 +24,7 @@ public class MongoNodeService implements NodeService {
private static final String REST_PORT = "restPort";
private static final String HEARTBEAT = "heartbeat";

private final MongoClient mongoClient;
private MongoClient mongoClient;
private final String clusterName;

public MongoNodeService(MongoClient mongoClient, String clusterName) {
Expand All @@ -35,7 +37,6 @@ public MongoNodeService(MongoClient mongoClient, String clusterName) {
}

private MongoCollection<Document> getCollection() {
//return mongoClient.getDatabase(clusterName).getCollection(NODES).withWriteConcern(WriteConcern.MAJORITY);
return mongoClient.getDatabase(clusterName).getCollection(NODES);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ public InputStream getAssociatedDocumentStream(String indexName, String uniqueId
return i.getAssociatedDocumentStream(uniqueId, fileName);
}

public void storeAssociatedDocument(String indexName, String uniqueId, String fileName, InputStream is, Document metadata)
throws Exception {
public void storeAssociatedDocument(String indexName, String uniqueId, String fileName, InputStream is, Document metadata) throws Exception {
ZuliaIndex i = getIndexFromName(indexName);
long timestamp = System.currentTimeMillis();
i.storeAssociatedDocument(uniqueId, fileName, is, timestamp, metadata);
Expand Down
13 changes: 6 additions & 7 deletions zulia-server/src/main/java/io/zulia/server/node/ZuliaNode.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.zulia.server.node;

import io.micronaut.runtime.Micronaut;
import io.zulia.server.config.NodeService;
import io.zulia.server.config.ZuliaConfig;
import io.zulia.server.connection.server.ZuliaServiceServer;
import io.zulia.server.index.ZuliaIndexManager;
import io.zulia.server.rest.ZuliaRESTServiceManager;
import io.zulia.server.rest.ZuliaRESTService;

import java.util.Collection;
import java.util.Timer;
Expand All @@ -15,7 +16,6 @@
public class ZuliaNode {

private final ZuliaIndexManager indexManager;
private final ZuliaRESTServiceManager restServiceManager;

private final ZuliaServiceServer zuliaServiceServer;

Expand All @@ -30,7 +30,6 @@ public ZuliaNode(ZuliaConfig zuliaConfig, NodeService nodeService) throws Except
this.zuliaConfig = zuliaConfig;
this.nodeService = nodeService;
this.indexManager = new ZuliaIndexManager(zuliaConfig, nodeService);
this.restServiceManager = new ZuliaRESTServiceManager(zuliaConfig, indexManager);

this.zuliaServiceServer = new ZuliaServiceServer(zuliaConfig, indexManager);

Expand Down Expand Up @@ -65,19 +64,16 @@ protected void handleNodeAdded(Collection<Node> currentOtherNodesActive, Node ne
membershipTimer.scheduleAtFixedRate(membershipTask, 1000, 1000);

indexManager.init();
restServiceManager.start();
zuliaServiceServer.start();
Micronaut.run(ZuliaRESTService.class);
LOG.info(getLogPrefix() + "started");

}



public void shutdown() {
LOG.info(getLogPrefix() + "stopping");
membershipTimer.cancel();
nodeService.removeHeartbeat(zuliaConfig.getServerAddress(), zuliaConfig.getServicePort());
restServiceManager.shutdown();
zuliaServiceServer.shutdown();
indexManager.shutdown();
LOG.info(getLogPrefix() + "stopped");
Expand All @@ -96,4 +92,7 @@ private String getLogPrefix() {
return zuliaConfig.getServerAddress() + ":" + zuliaConfig.getServicePort() + " ";
}

public ZuliaIndexManager getIndexManager() {
return indexManager;
}
}

This file was deleted.

76 changes: 0 additions & 76 deletions zulia-server/src/main/java/io/zulia/server/rest/FetchResource.java

This file was deleted.

Loading