Skip to content

Commit 078e516

Browse files
authored
Alok protobuf make clientlib module (#75)
* make clientlib module * gradle fixes for compilation * gradle fixes for compilation * gradle changes * rename org.apache.platypus to com.yelp.platypus * fix groupId in clientlib build.gradle * Revert "rename org.apache.platypus to com.yelp.platypus" This reverts commit a1640e8. * rename org.apache.platypus to com.yelp.nrtsearch * fix publication groupID * Change all traces of "platypus" (except for repo names) to "nrtSearch" * fix unfound java src in clientlib error * fixes for building grpc-gateway * fixes for building grpc-gateway
1 parent 48733b3 commit 078e516

File tree

121 files changed

+1375
-1117
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+1375
-1117
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,5 @@ replica_state/
4444
serverPrimary/
4545
serverSecondary/
4646
server1RootDirName1/
47+
primary_index_base/
48+
replica_index_base/

NOTICE

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ at:
2121
* https://github.com/mikemccand/luceneserver/blob/master/src/java/org/apache/lucene/server/Connection.java#L3 (Apache License 2.0)
2222
* HOMEPAGE:
2323
* https://github.com/mikemccand/luceneserver
24-
* LOCATION_IN_PLATYPUS:
25-
* org.apache.platypus.server.luceneserver
24+
* LOCATION_IN_NRTSEARCH:
25+
* com.yelp.nrtsearch.server.luceneserver

README.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Platypus
1+
# nrtSearch
22
A high performance gRPC server on top of [Apache Lucene](http://lucene.apache.org/) version 8.x source, exposing lucene's
33
core functionality over a simple gRPC based API.
44

@@ -17,8 +17,8 @@ Fields must first be registered with the *registerFields* command, where you exp
1717
There is no transaction log, so you must call *commit* yourself periodically to make recent changes durable on disk. This means that if a node crashes, all indexed documents since the last commit are lost.
1818

1919
# Indexing a stream of documents
20-
platypus supports client side gRPC streaming for its *addDocuments* endpoint. This means that the server API accepts a stream of documents . The client can choose to stream the documents however it wishes.
21-
The example platypus client implemented here reads a CSV file and streams documents from it over to the server. The server can index chunks of documents the size of which is configurable as the client
20+
nrtSearch supports client side gRPC streaming for its *addDocuments* endpoint. This means that the server API accepts a stream of documents . The client can choose to stream the documents however it wishes.
21+
The example nrtSearch client implemented here reads a CSV file and streams documents from it over to the server. The server can index chunks of documents the size of which is configurable as the client
2222
continues to send more documents over its stream. gRPC enables this with minimal application code and yields higher performance compared to JSON. TODO[citation needed]: Add performance numbers of stream based indexing for some datasets.
2323

2424
# Near-real-time-replication
@@ -48,20 +48,20 @@ Note: This code has been tested on *Java13*
4848
# Run Server
4949

5050
```
51-
./build/install/platypus/bin/lucene-server
51+
./build/install/nrtsearch/bin/lucene-server
5252
```
5353

5454
# Example to run some basic client commands
5555
## Create Index
5656

5757
```
58-
./build/install/platypus/bin/lucene-client createIndex --indexName testIdx --rootDir testIdx
58+
./build/install/nrtsearch/bin/lucene-client createIndex --indexName testIdx --rootDir testIdx
5959
```
6060

6161
## Update Settings
6262

6363
```
64-
./build/install/platypus/bin/lucene-client settings -f settings.json
64+
./build/install/nrtsearch/bin/lucene-client settings -f settings.json
6565
cat settings.json
6666
{ "indexName": "testIdx",
6767
"indexVerbose": false,
@@ -76,7 +76,7 @@ cat settings.json
7676
## Start Index
7777

7878
```
79-
./build/install/platypus/bin/lucene-client startIndex -f startIndex.json
79+
./build/install/nrtsearch/bin/lucene-client startIndex -f startIndex.json
8080
cat startIndex.json
8181
{
8282
"indexName" : "testIdx"
@@ -86,7 +86,7 @@ cat startIndex.json
8686
## RegisterFields
8787

8888
```
89-
./build/install/platypus/bin/lucene-client registerFields -f registerFields.json
89+
./build/install/nrtsearch/bin/lucene-client registerFields -f registerFields.json
9090
cat registerFields.json
9191
{ "indexName": "testIdx",
9292
"field":
@@ -100,7 +100,7 @@ cat registerFields.json
100100
## Add Documents
101101

102102
```
103-
./build/install/platypus/bin/lucene-client addDocuments -i testIdx -f docs.csv
103+
./build/install/nrtsearch/bin/lucene-client addDocuments -i testIdx -f docs.csv
104104
cat docs.csv
105105
doc_id,vendor_name,license_no
106106
0,first vendor,100;200
@@ -110,7 +110,7 @@ doc_id,vendor_name,license_no
110110
## Search
111111

112112
```
113-
./build/install/platypus/bin/lucene-client search -f search.json
113+
./build/install/nrtsearch/bin/lucene-client search -f search.json
114114
cat search.json
115115
{
116116
"indexName": "testIdx",
@@ -138,11 +138,11 @@ This should create a src/main/docs/index.html file that can be seen in your loca
138138
This tool indexes yelp reviews available at [Yelp dataset challenge](https://www.yelp.com/dataset/challenge). It runs a default version with only 1k reviews of the `reviews.json` or you could download the yelp dataset and place the review.json in the user.home dir and the tool will use that instead. The complete review.json should have close to 7Million reviews. The tool runs multi-threaded indexing and a search thread in parallel reporting the `totalHits`. Command to run this specific test:
139139

140140
```
141-
./gradlew clean && ./gradlew installDist && ./gradlew test -PincludePerfTests=* --tests "org.apache.platypus.server.YelpReviewsTest.runYelpReviews" --info
141+
./gradlew clean && ./gradlew installDist && ./gradlew test -PincludePerfTests=* --tests "com.yelp.nrtsearch.server.YelpReviewsTest.runYelpReviews" --info
142142
```
143143

144144
# Suggestions
145145

146-
This test indexes businesses, creates an Infix Suggester and fetches suggestions. It requires a host, a port and a writeable directory in a standalone Platypus server.
146+
This test indexes businesses, creates an Infix Suggester and fetches suggestions. It requires a host, a port and a writeable directory in a standalone nrtSearch server.
147147

148-
```./gradlew test -DsuggestTmp=remoteServerDir -DsuggestHost=yourStandaloneServerHost -DsuggestPort=yourStandaloneServerHost --tests "org.apache.platypus.server.YelpSuggestTest"```
148+
```./gradlew test -DsuggestTmp=remoteServerDir -DsuggestHost=yourStandaloneServerHost -DsuggestPort=yourStandaloneServerHost --tests "com.yelp.nrtsearch.server.YelpSuggestTest"```

build.gradle

+6-31
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
plugins {
22
// Provide convenience executables for trying out the examples.
33
id 'application'
4-
// ASSUMES GRADLE 2.12 OR HIGHER. Use plugin version 0.7.5 with earlier gradle versions
5-
id 'com.google.protobuf' version '0.8.8'
64
// Generate IntelliJ IDEA's .idea & .iml project files
75
id 'idea'
86
}
@@ -22,9 +20,6 @@ targetCompatibility = 1.12
2220

2321
// Feel free to delete the comment at the next line. It is just for safely
2422
// updating the version in our release process.
25-
def grpcVersion = '1.26.0' // CURRENT_GRPC_VERSION
26-
def protobufVersion = '3.9.0'
27-
def protocVersion = protobufVersion
2823
def luceneVersion = '8.2.0'
2924
def slf4jVersion = '2.0.0-alpha0'
3025
def gsonVersion = '2.8.5'
@@ -39,17 +34,12 @@ def prometheusVersion = '0.3.0'
3934
def prometheusClientVersion = '0.8.0'
4035

4136
dependencies {
42-
//grpc deps
43-
implementation "io.grpc:grpc-protobuf:${grpcVersion}"
44-
implementation "io.grpc:grpc-stub:${grpcVersion}"
4537

4638
//prometheus (metrics) deps
4739
implementation "me.dinowernli:java-grpc-prometheus:${prometheusVersion}"
48-
implementation "io.grpc:grpc-okhttp:${grpcVersion}"
4940
implementation "io.prometheus:simpleclient_servlet:${prometheusClientVersion}"
5041

5142
//
52-
implementation "javax.annotation:javax.annotation-api:1.2"
5343
implementation "org.slf4j:slf4j-api:${slf4jVersion}"
5444
implementation "org.slf4j:slf4j-jdk14:2.0.0-alpha1"
5545
implementation "com.google.code.gson:gson:${gsonVersion}"
@@ -75,57 +65,42 @@ dependencies {
7565
implementation "org.apache.lucene:lucene-grouping:${luceneVersion}"
7666
implementation "org.apache.lucene:lucene-queries:${luceneVersion}"
7767

78-
// examples/advanced need this for JsonFormat
79-
implementation "com.google.protobuf:protobuf-java-util:${protobufVersion}"
80-
8168
//cli deps
8269
implementation 'info.picocli:picocli:4.0.4'
8370
implementation 'org.apache.commons:commons-csv:1.7'
8471

85-
runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}"
86-
87-
//test deps
88-
testImplementation "io.grpc:grpc-testing:${grpcVersion}"
8972
testImplementation "junit:junit:4.12"
9073
testImplementation "org.mockito:mockito-core:2.25.1"
9174
testImplementation "org.apache.lucene:lucene-test-framework:${luceneVersion}"
9275
testImplementation "org.locationtech.spatial4j:spatial4j:${spatial4jVersion}"
9376
testImplementation "io.findify:s3mock_2.12:${s3mockVersion}"
9477

95-
78+
compile project(':clientlib')
9679
}
9780

98-
protobuf {
99-
protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" }
100-
plugins {
101-
grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
102-
}
103-
generateProtoTasks {
104-
all()*.plugins { grpc {} }
105-
}
106-
}
81+
10782

10883
// Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code.
10984
sourceSets {
11085
main {
11186
java {
112-
srcDirs 'build/generated/source/proto/main/grpc'
113-
srcDirs 'build/generated/source/proto/main/java'
87+
srcDirs 'clientlib/build/generated/source/proto/main/grpc'
88+
srcDirs 'clientlib/build/generated/source/proto/main/java'
11489
}
11590
}
11691
}
11792

11893
startScripts.enabled = false
11994

12095
task luceneServer(type: CreateStartScripts) {
121-
mainClassName = 'org.apache.platypus.server.grpc.LuceneServer'
96+
mainClassName = 'com.yelp.nrtsearch.server.grpc.LuceneServer'
12297
applicationName = 'lucene-server'
12398
outputDir = new File(project.buildDir, 'tmp')
12499
classpath = startScripts.classpath
125100
}
126101

127102
task luceneServerClient(type: CreateStartScripts) {
128-
mainClassName = 'org.apache.platypus.server.grpc.LuceneServerClient'
103+
mainClassName = 'com.yelp.nrtsearch.server.grpc.LuceneServerClient'
129104
applicationName = 'lucene-client'
130105
outputDir = new File(project.buildDir, 'tmp')
131106
classpath = startScripts.classpath

build_grpc_gateway.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
docker build -t grpc-gateway -f grpc-gateway/Dockerfile .
22
docker run grpc-gateway
3-
docker cp $(docker ps -alq):/code/output/. ./grpc-gateway/
4-
docker cp $(docker ps -alq):/code/bin/. ./build/install/platypus/bin
3+
docker cp $(docker ps -alq):/code/output/yelp/nrtsearch/. ./grpc-gateway/
4+
docker cp $(docker ps -alq):/code/bin/. ./build/install/nrtsearch/bin

clientlib/build.gradle

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
plugins {
2+
// Provide convenience executables for trying out the examples.
3+
id 'application'
4+
// ASSUMES GRADLE 2.12 OR HIGHER. Use plugin version 0.7.5 with earlier gradle versions
5+
id 'com.google.protobuf' version '0.8.8'
6+
// Generate IntelliJ IDEA's .idea & .iml project files
7+
id 'idea'
8+
// Publish clientlib to maven central
9+
id 'maven-publish'
10+
}
11+
12+
repositories {
13+
maven { // The google mirror is less flaky than mavenCentral()
14+
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
15+
}
16+
mavenLocal()
17+
}
18+
19+
sourceCompatibility = 1.12
20+
targetCompatibility = 1.12
21+
startScripts.enabled = false
22+
23+
def grpcVersion = '1.26.0' // CURRENT_GRPC_VERSION
24+
def protobufVersion = '3.11.1'
25+
def protocVersion = protobufVersion
26+
27+
dependencies {
28+
//grpc deps
29+
compile "io.grpc:grpc-protobuf:${grpcVersion}"
30+
implementation "io.grpc:grpc-stub:${grpcVersion}"
31+
implementation "io.grpc:grpc-okhttp:${grpcVersion}"
32+
implementation "javax.annotation:javax.annotation-api:1.2"
33+
34+
// examples/advanced need this for JsonFormat
35+
compile "com.google.protobuf:protobuf-java-util:${protobufVersion}"
36+
37+
runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}"
38+
39+
//test deps
40+
compile "io.grpc:grpc-testing:${grpcVersion}"
41+
}
42+
43+
sourceSets {
44+
all {
45+
proto {
46+
srcDirs 'proto'
47+
}
48+
}
49+
}
50+
51+
protobuf {
52+
protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" }
53+
plugins {
54+
grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
55+
}
56+
generateProtoTasks {
57+
all()*.plugins { grpc {} }
58+
}
59+
}
60+
61+
publishing {
62+
publications {
63+
maven(MavenPublication) {
64+
groupId = 'com.yelp.nrtsearch'
65+
artifactId = 'clientlib'
66+
version = '0.1'
67+
}
68+
}
69+
}
70+
71+
test {
72+
// Add tests when there's java code in this module
73+
// Until then, exclude everything to allow
74+
// build to run
75+
exclude '**/*'
76+
}

src/main/proto/analysis.proto clientlib/proto/yelp/nrtsearch/analysis.proto

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
syntax = "proto3";
33

44
option java_multiple_files = true;
5-
option java_package = "org.apache.platypus.server.grpc";
5+
option java_package = "com.yelp.nrtsearch.server.grpc";
66
option java_outer_classname = "AnalysisProto";
77
option objc_class_prefix = "HLW";
88

src/main/proto/luceneserver.proto clientlib/proto/yelp/nrtsearch/luceneserver.proto

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
/* Description of Platypus Service APIs and message types */
1+
/* Description of NRTSearch Service APIs and message types */
22
syntax = "proto3";
33

4-
import "search.proto";
5-
import "analysis.proto";
4+
import "yelp/nrtsearch/search.proto";
5+
import "yelp/nrtsearch/analysis.proto";
66
import "google/api/annotations.proto";
77

88

99
option java_multiple_files = true;
10-
option java_package = "org.apache.platypus.server.grpc";
10+
option java_package = "com.yelp.nrtsearch.server.grpc";
1111
option java_outer_classname = "LuceneServerProto";
1212
option objc_class_prefix = "HLW";
1313

src/main/proto/search.proto clientlib/proto/yelp/nrtsearch/search.proto

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
syntax = "proto3";
33

44
import "google/type/latlng.proto";
5-
import "analysis.proto";
5+
import "yelp/nrtsearch/analysis.proto";
66

77
option java_multiple_files = true;
8-
option java_package = "org.apache.platypus.server.grpc";
8+
option java_package = "com.yelp.nrtsearch.server.grpc";
99
option java_outer_classname = "SearchResponseProto";
1010
option objc_class_prefix = "HLW";
1111

grpc-gateway/Dockerfile

+44-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,50 @@ RUN go get -u \
3737
github.com/golang/protobuf/protoc-gen-go \
3838
google.golang.org/grpc
3939

40+
ENV PROTO_PATH=/code/clientlib/proto
41+
ENV PROTO_BUILD_PATH=/code/clientlib/build
42+
4043
#run protoc plugin for protoc-gen-go
41-
RUN protoc -I/code/src/main/proto -I/code/build/extracted-protos/main -I/code/build/extracted-include-protos/main --plugin=protoc-gen-go=$GOPATH/bin/protoc-gen-go --go_out=plugins=grpc:$OUTPATH /code/src/main/proto/analysis.proto /code/src/main/proto/luceneserver.proto /code/src/main/proto/search.proto
42-
RUN protoc -I/code/src/main/proto -I/code/build/extracted-protos/main -I/code/build/extracted-include-protos/main --plugin=protoc-gen-grpc-gateway=$GOPATH/bin/protoc-gen-grpc-gateway --grpc-gateway_out=logtostderr=true:$OUTPATH /code/src/main/proto/analysis.proto /code/src/main/proto/luceneserver.proto /code/src/main/proto/search.proto
43-
RUN protoc -I/code/src/main/proto -I/code/build/extracted-protos/main -I/code/build/extracted-include-protos/main --plugin=protoc-gen-swagger=$GOPATH/bin/protoc-gen-swagger --swagger_out=logtostderr=true:$OUTPATH /code/src/main/proto/analysis.proto /code/src/main/proto/luceneserver.proto /code/src/main/proto/search.proto
44+
RUN protoc \
45+
-I $PROTO_PATH \
46+
-I $PROTO_BUILD_PATH/extracted-protos/main \
47+
-I $PROTO_BUILD_PATH/extracted-include-protos/main \
48+
--plugin=protoc-gen-go=$GOPATH/bin/protoc-gen-go \
49+
--go_out=plugins=grpc:$OUTPATH \
50+
$PROTO_PATH/yelp/nrtsearch/analysis.proto \
51+
$PROTO_PATH/yelp/nrtsearch/luceneserver.proto \
52+
$PROTO_PATH/yelp/nrtsearch/search.proto
53+
54+
RUN protoc \
55+
-I $PROTO_PATH \
56+
-I $PROTO_BUILD_PATH/extracted-protos/main \
57+
-I $PROTO_BUILD_PATH/extracted-include-protos/main \
58+
--plugin=protoc-gen-grpc-gateway=$GOPATH/bin/protoc-gen-grpc-gateway \
59+
--grpc-gateway_out=logtostderr=true:$OUTPATH \
60+
$PROTO_PATH/yelp/nrtsearch/analysis.proto \
61+
$PROTO_PATH/yelp/nrtsearch/luceneserver.proto \
62+
$PROTO_PATH/yelp/nrtsearch/search.proto
63+
64+
RUN protoc \
65+
-I $PROTO_PATH \
66+
-I $PROTO_BUILD_PATH/extracted-protos/main \
67+
-I $PROTO_BUILD_PATH/extracted-include-protos/main \
68+
--plugin=protoc-gen-swagger=$GOPATH/bin/protoc-gen-swagger \
69+
--swagger_out=logtostderr=true:$OUTPATH \
70+
$PROTO_PATH/yelp/nrtsearch/analysis.proto \
71+
$PROTO_PATH/yelp/nrtsearch/luceneserver.proto \
72+
$PROTO_PATH/yelp/nrtsearch/search.proto
73+
74+
RUN cp $OUTPATH/yelp/nrtsearch/* grpc-gateway/
75+
4476
# build go executables for various platforms
45-
RUN for GOOS in darwin linux windows; do for GOARCH in 386 amd64; do echo "Building $GOOS-$GOARCH"; export GOOS=$GOOS; export GOARCH=$GOARCH; go build -o bin/http_wrapper-$GOOS-$GOARCH http_wrapper.go; done; done
77+
RUN for GOOS in darwin linux windows; do \
78+
for GOARCH in 386 amd64; do \
79+
echo "Building $GOOS-$GOARCH"; \
80+
export GOOS=$GOOS; \
81+
export GOARCH=$GOARCH; \
82+
go build -o bin/http_wrapper-$GOOS-$GOARCH http_wrapper.go; \
83+
done; \
84+
done
85+
4686
CMD /bin/sh

0 commit comments

Comments
 (0)