Commit 8a53ba69 authored by mohammad.salama's avatar mohammad.salama

Coordinator Election nd Auto-Healing - Getting Term Frequency in each file ,...

Coordinator Election nd Auto-Healing - Getting Term Frequency in each file , some excpetions where handled
parent ee2905c2
...@@ -11,14 +11,12 @@ ...@@ -11,14 +11,12 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="b8bcd35c-99f3-44c8-a866-59f81c3c8bd0" name="Changes" comment=""> <list default="true" id="b8bcd35c-99f3-44c8-a866-59f81c3c8bd0" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Distributed-Search.jar" beforeDir="false" afterPath="$PROJECT_DIR$/Distributed-Search.jar" afterDir="false" />
<change beforePath="$PROJECT_DIR$/logs/app.log" beforeDir="false" afterPath="$PROJECT_DIR$/logs/app.log" afterDir="false" /> <change beforePath="$PROJECT_DIR$/logs/app.log" beforeDir="false" afterPath="$PROJECT_DIR$/logs/app.log" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/artifacts/Distributed_Search_jar/Distributed-Search.jar" beforeDir="false" afterPath="$PROJECT_DIR$/out/artifacts/Distributed_Search_jar/Distributed-Search.jar" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/AutoHealerAndClusterSearch/Application.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/AutoHealerAndClusterSearch/Application.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/AutoHealerAndClusterSearch/Application.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/AutoHealerAndClusterSearch/Application.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/AutoHealerAndClusterSearch/Coordinator.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/AutoHealerAndClusterSearch/Coordinator.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/AutoHealerAndClusterSearch/Coordinator.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/AutoHealerAndClusterSearch/Coordinator.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/AutoHealerAndClusterSearch/TransientWorker.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/AutoHealerAndClusterSearch/TransientWorker.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/ObjectExchangeInCluster/FileWordPair.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ObjectExchangeInCluster/FileWordPair.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/generalTesting/test.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/generalTesting/test.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/AutoHealerAndClusterSearch/Coordinator.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/AutoHealerAndClusterSearch/Coordinator.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/target/classes/AutoHealerAndClusterSearch/Coordinator.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/AutoHealerAndClusterSearch/Coordinator.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/AutoHealerAndClusterSearch/TransientWorker.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/AutoHealerAndClusterSearch/TransientWorker.class" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
...@@ -53,19 +51,19 @@ ...@@ -53,19 +51,19 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"RunOnceActivity.OpenProjectViewOnStart": "true", &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"SHARE_PROJECT_CONFIGURATION_FILES": "true", &quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
"jdk.selected.JAVA_MODULE": "17 (2)", &quot;jdk.selected.JAVA_MODULE&quot;: &quot;17 (2)&quot;,
"last_opened_file_path": "D:/HIAST/FIY/FS/Parallel Programming/Lab/2/pp-02-executorservice-master", &quot;last_opened_file_path&quot;: &quot;D:/HIAST/FIY/FS/Parallel Programming/Lab/2/pp-02-executorservice-master&quot;,
"project.structure.last.edited": "Artifacts", &quot;project.structure.last.edited&quot;: &quot;Artifacts&quot;,
"project.structure.proportion": "0.15", &quot;project.structure.proportion&quot;: &quot;0.15&quot;,
"project.structure.side.proportion": "0.2", &quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
"settings.editor.selected.configurable": "reference.settings.project.maven.repository.indices" &quot;settings.editor.selected.configurable&quot;: &quot;reference.settings.project.maven.repository.indices&quot;
} }
}]]></component> }</component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search\src\main\java\GRPC" /> <recent name="D:\HIAST\FIY\FS\Distributed Systems\Lab\8\Distributed-Search\src\main\java\GRPC" />
...@@ -77,7 +75,7 @@ ...@@ -77,7 +75,7 @@
<recent name="" /> <recent name="" />
</key> </key>
</component> </component>
<component name="RunManager" selected="Application.n4"> <component name="RunManager" selected="Application.n1">
<configuration name="n1" type="Application" factoryName="Application"> <configuration name="n1" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="AutoHealerAndClusterSearch.Application" /> <option name="MAIN_CLASS_NAME" value="AutoHealerAndClusterSearch.Application" />
<module name="Distributed-Search" /> <module name="Distributed-Search" />
......
No preview for this file type
the calculation of idf is not done yet!
we have now each word in query and its appearnce frequency in each file.
some more calculation should be done to get idf and other things
to run Distributed-Search: to run Distributed-Search:
java -jar Distributed-Search.jar <ip:port> java -jar Distributed-Search.jar <ip:port>
......
This diff is collapsed.
...@@ -22,16 +22,16 @@ public class Application implements Watcher ...@@ -22,16 +22,16 @@ public class Application implements Watcher
public static void main(String[] args) throws IOException, InterruptedException, KeeperException { public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
/*String IP = args.length == 1 ? args[0] : "127.0.0.1:55451"; String IP = args.length == 1 ? args[0] : "127.0.0.1:55451";
int port = Integer.parseInt(IP.split(":")[1]);*/ int port = Integer.parseInt(IP.split(":")[1]);
Scanner scanner = new Scanner(System.in); /* Scanner scanner = new Scanner(System.in);
System.out.println("Enter Port !!"); System.out.println("Enter Port !!");
String IP = "127.0.0.1"; String IP = "127.0.0.1";
int port = scanner.nextInt(); int port = scanner.nextInt();
System.out.println("IP is : " + IP ); System.out.println("IP is : " + IP );
System.out.println("Port is : " + port); System.out.println("Port is : " + port);*/
Application application = new Application(); Application application = new Application();
ZooKeeper zooKeeper = application.connectToZookeeper(); ZooKeeper zooKeeper = application.connectToZookeeper();
......
...@@ -42,7 +42,7 @@ public class Coordinator ...@@ -42,7 +42,7 @@ public class Coordinator
public void start() throws IOException, InterruptedException, KeeperException public void start() throws IOException, InterruptedException, KeeperException
{ {
ServerSocket serverSocket = new ServerSocket(COORDINATOR_PORT); //ServerSocket serverSocket = new ServerSocket(COORDINATOR_PORT);
System.out.println("Server started on port " + COORDINATOR_PORT); System.out.println("Server started on port " + COORDINATOR_PORT);
logger.info("Server started on port " + COORDINATOR_PORT); logger.info("Server started on port " + COORDINATOR_PORT);
...@@ -81,6 +81,7 @@ public class Coordinator ...@@ -81,6 +81,7 @@ public class Coordinator
private void printResponsr(SearchQueryResponse searchQueryResponseMap) private void printResponsr(SearchQueryResponse searchQueryResponseMap)
{ {
if (searchQueryResponseMap == null)return;
} }
private SearchQueryResponse sendRequestToNode(SearchQueryRequest searchQueryRequest, String ipAddress) private SearchQueryResponse sendRequestToNode(SearchQueryRequest searchQueryRequest, String ipAddress)
...@@ -127,6 +128,11 @@ public class Coordinator ...@@ -127,6 +128,11 @@ public class Coordinator
try try
{ {
List<SearchQueryResponse> respons = spreadQuery(query); List<SearchQueryResponse> respons = spreadQuery(query);
if (respons == null)
{
System.out.println("No Nodes Are Working , Search Cannot Be Done");
logger.warn("No Nodes Are Working , Search Cannot Be Done");
}
processResultsAndPrepareAnswer(respons); processResultsAndPrepareAnswer(respons);
} }
catch (IOException | InterruptedException | KeeperException e) catch (IOException | InterruptedException | KeeperException e)
...@@ -152,6 +158,7 @@ public class Coordinator ...@@ -152,6 +158,7 @@ public class Coordinator
* */ * */
private void processResultsAndPrepareAnswer(List<SearchQueryResponse> respons) private void processResultsAndPrepareAnswer(List<SearchQueryResponse> respons)
{ {
if (respons == null) return;
for (SearchQueryResponse searchQueryResponse : respons) for (SearchQueryResponse searchQueryResponse : respons)
{ {
Map<String, List<FileWordPair>> treeMap = searchQueryResponse.getWordFrequencies(); Map<String, List<FileWordPair>> treeMap = searchQueryResponse.getWordFrequencies();
...@@ -191,6 +198,10 @@ public class Coordinator ...@@ -191,6 +198,10 @@ public class Coordinator
{ {
List<String> physicalZnodes = zooKeeper.getChildren(PHYSICAL_ZNODES_PATH, false); List<String> physicalZnodes = zooKeeper.getChildren(PHYSICAL_ZNODES_PATH, false);
if (physicalZnodes.isEmpty())
{
return null;
}
int totalFilesNumber = countFilesInDirectory(); int totalFilesNumber = countFilesInDirectory();
System.out.println("Files Number = " + totalFilesNumber); System.out.println("Files Number = " + totalFilesNumber);
......
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