Commit 133d4005 authored by mohammad.salama's avatar mohammad.salama

GRPC Working - Not Integrated with Coodinator - Coordinator Search is Fine

parent 70965093
This diff is collapsed.
......@@ -131,3 +131,27 @@
2024-01-27 12:10:30,056 INFO org.AutoHealerAndClusterSearch.AutoHealerAndClusterSearch.Coordinator [main-EventThread] Server started on port 2354
2024-01-27 12:10:35,732 INFO org.AutoHealerAndClusterSearch.AutoHealerAndClusterSearch.TransientWorker [main] Coordinator connected: /127.0.0.1
2024-01-27 12:10:51,522 WARN org.AutoHealerAndClusterSearch.AutoHealerAndClusterSearch.Coordinator [Thread-4] No Nodes Are Working , Search Cannot Be Done
2024-01-27 19:00:09,903 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Starting Main using Java 17.0.5 on M-Salameh with PID 2444 (D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search\target\classes started by M_Salameh in D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search)
2024-01-27 19:00:09,905 DEBUG org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Running with Spring Boot v2.6.8, Spring v5.3.20
2024-01-27 19:00:09,907 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] No active profile set, falling back to 1 default profile: "default"
2024-01-27 19:00:11,779 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Started Main in 2.576 seconds (JVM running for 3.489)
2024-01-29 09:20:28,446 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Starting Main using Java 17.0.5 on M-Salameh with PID 16012 (D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search\target\classes started by M_Salameh in D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search)
2024-01-29 09:20:28,450 DEBUG org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Running with Spring Boot v2.6.8, Spring v5.3.20
2024-01-29 09:20:28,452 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] No active profile set, falling back to 1 default profile: "default"
2024-01-29 09:20:30,684 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Started Main in 2.984 seconds (JVM running for 4.189)
2024-01-29 09:24:42,946 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Starting Main using Java 17.0.5 on M-Salameh with PID 5264 (D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search\target\classes started by M_Salameh in D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search)
2024-01-29 09:24:42,949 DEBUG org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Running with Spring Boot v2.6.8, Spring v5.3.20
2024-01-29 09:24:42,952 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] No active profile set, falling back to 1 default profile: "default"
2024-01-29 09:24:45,323 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Started Main in 3.056 seconds (JVM running for 4.142)
2024-01-29 09:25:14,697 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Starting Main using Java 17.0.5 on M-Salameh with PID 7988 (D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search\target\classes started by M_Salameh in D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search)
2024-01-29 09:25:14,701 DEBUG org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Running with Spring Boot v2.6.8, Spring v5.3.20
2024-01-29 09:25:14,703 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] No active profile set, falling back to 1 default profile: "default"
2024-01-29 09:25:17,240 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Started Main in 3.236 seconds (JVM running for 4.153)
2024-01-29 09:43:09,535 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Starting Main using Java 17.0.5 on M-Salameh with PID 13280 (D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search\target\classes started by M_Salameh in D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search)
2024-01-29 09:43:09,539 DEBUG org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Running with Spring Boot v2.6.8, Spring v5.3.20
2024-01-29 09:43:09,540 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] No active profile set, falling back to 1 default profile: "default"
2024-01-29 09:43:11,919 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Started Main in 3.086 seconds (JVM running for 4.044)
2024-01-29 09:44:50,403 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Starting Main using Java 17.0.5 on M-Salameh with PID 840 (D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search\target\classes started by M_Salameh in D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search)
2024-01-29 09:44:50,406 DEBUG org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Running with Spring Boot v2.6.8, Spring v5.3.20
2024-01-29 09:44:50,408 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] No active profile set, falling back to 1 default profile: "default"
2024-01-29 09:44:52,777 INFO org.AutoHealerAndClusterSearch.GRPCConnection.Main [main] Started Main in 3.099 seconds (JVM running for 4.058)
package GRPCConnection.GRPCClient;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import org.AutoHealerAndClusterSearch.SearchReply;
import org.AutoHealerAndClusterSearch.SearchRequest;
import org.AutoHealerAndClusterSearch.SearchServiceGrpc;
import java.util.List;
/**
* the client here will be the web server
* configure it later
* */
public class GRPCClient
{
public static void main(String[] args)
{
ManagedChannel channel = ManagedChannelBuilder.
forAddress("localhost" , 6565).
usePlaintext().build();
SearchServiceGrpc.SearchServiceBlockingStub stub = SearchServiceGrpc.newBlockingStub(channel);
SearchRequest request = SearchRequest.newBuilder().setQuery("Hello There !!").build();
SearchReply reply = stub.search(request);
List<String> stringList = reply.getFilesList();
for (String s: stringList)
{
System.out.println(s);
}
}
}
package org.AutoHealerAndClusterSearch.GRPCConnection.GRPCServer;
package GRPCConnection.GRPCServer;
import io.grpc.stub.StreamObserver;
import org.AutoHealerAndClusterSearch.AutoHealerAndClusterSearch.Coordinator;
......@@ -10,10 +10,10 @@ import org.lognet.springboot.grpc.GRpcService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
/**
* the server of GRPC is the coordinator
......@@ -24,30 +24,32 @@ import java.util.concurrent.ExecutionException;
public class GRPCServer extends SearchServiceGrpc.SearchServiceImplBase
{
private Coordinator coordinator;
public GRPCServer(Coordinator coordinator)
/* public GRPCServer(Coordinator coordinator)
{
this.coordinator = coordinator;
}
Logger logger = LoggerFactory.getLogger(GRPCServer.class);
}*/
//Logger logger = LoggerFactory.getLogger(GRPCServer.class);
@Override
public void search(SearchRequest request, StreamObserver<SearchReply> responseObserver)
{
logger.info("Request Has Arrived , Query is :" + request.getQuery());
//logger.info("Request Has Arrived , Query is :" + request.getQuery());
List<String> ans = new ArrayList<>();
try
String x = request.getQuery();
ans.add("Sorry Something Went Wrong " + x);
/*try
{
ans = coordinator.search(request.getQuery());
}
catch (IOException | InterruptedException | KeeperException | ExecutionException e)
{
logger.error("Error In GRPC While Getting answers for Query");
ans.add("Sorry Something Went Wrong");
//throw new RuntimeException(e);
}
}*/
SearchReply reply = SearchReply.newBuilder().addAllFiles(ans).build();
responseObserver.onNext(reply);
......
package org.AutoHealerAndClusterSearch.GRPCConnection;
package GRPCConnection;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......
package WebSide;
public class WebClient
{
}
package WebSide;
public class WebServer {
}
package org.AutoHealerAndClusterSearch.AutoHealerAndClusterSearch;
import org.AutoHealerAndClusterSearch.GRPCConnection.GRPCServer.GRPCServer;
import org.apache.zookeeper.*;
import org.apache.zookeeper.data.Stat;
import org.slf4j.Logger;
......
package org.AutoHealerAndClusterSearch.GRPCConnection.GRPCClient;
/**
* the client here will be the web server
* configure it later
* */
public class GRPCClient
{
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment