Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
D
DS_Project_Part1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ali.saeed
DS_Project_Part1
Commits
23f07acd
Commit
23f07acd
authored
Jan 29, 2024
by
Ali Saeed
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create MyGrpcServer class to implement proto file
parent
f65a6c45
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
MyGrpcServer.java
...rs/src/main/java/Registration_Discovery/MyGrpcServer.java
+34
-0
No files found.
registration-discovery-leader-reelection-cordinator-workers/src/main/java/Registration_Discovery/MyGrpcServer.java
0 → 100644
View file @
23f07acd
package
Registration_Discovery
;
import
io.grpc.stub.StreamObserver
;
import
org.lognet.springboot.grpc.GRpcService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.io.IOException
;
import
java.util.*
;
@GRpcService
public
class
MyGrpcServer
extends
Registration_Discovery
.
SearchServiceGrpc
.
SearchServiceImplBase
{
@Override
public
void
search
(
Registration_Discovery
.
SearchRequest
request
,
StreamObserver
<
Registration_Discovery
.
SearchResponse
>
responseObserver
)
{
String
searchQuery
=
request
.
getQuery
();
TreeMap
<
String
,
Double
>
documentsScores
=
new
TreeMap
<>();
try
{
documentsScores
=
Leader
.
start
(
searchQuery
);
}
catch
(
IOException
|
InterruptedException
e
)
{
System
.
out
.
println
(
"problem in getting Results !!"
);
throw
new
RuntimeException
(
e
);
}
Registration_Discovery
.
SearchResult
searchResult
=
Registration_Discovery
.
SearchResult
.
newBuilder
()
.
putAllResults
(
documentsScores
)
.
build
();
Registration_Discovery
.
SearchResponse
response
=
Registration_Discovery
.
SearchResponse
.
newBuilder
()
.
setSearchResult
(
searchResult
)
.
build
();
responseObserver
.
onNext
(
response
);
responseObserver
.
onCompleted
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment