From 0fb15b8340444da6493a7785c78efea93117b435 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Mon, 5 Oct 2020 22:24:26 -0500 Subject: Remove bad file --- P1/clean.sh | 2 -- P1/run.sh | 2 -- P1/solutionexe/mapper.good | Bin 38848 -> 0 bytes P1/solutionexe/mapreduce.good | Bin 32632 -> 0 bytes P1/solutionexe/reducer.good | Bin 33848 -> 0 bytes 5 files changed, 4 deletions(-) delete mode 100755 P1/clean.sh delete mode 100755 P1/run.sh delete mode 100755 P1/solutionexe/mapper.good delete mode 100755 P1/solutionexe/mapreduce.good delete mode 100755 P1/solutionexe/reducer.good diff --git a/P1/clean.sh b/P1/clean.sh deleted file mode 100755 index 9261690..0000000 --- a/P1/clean.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -cd solutionexe/ && make clean && cd .. && make clean diff --git a/P1/run.sh b/P1/run.sh deleted file mode 100755 index 6b901ae..0000000 --- a/P1/run.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -make && cp mapper solutionexe/mapper && cp mapreduce solutionexe/mapreduce && cd solutionexe/ && make run && cp mapper.good mapper && cp mapreduce.good mapreduce && cd .. diff --git a/P1/solutionexe/mapper.good b/P1/solutionexe/mapper.good deleted file mode 100755 index 63e089d..0000000 Binary files a/P1/solutionexe/mapper.good and /dev/null differ diff --git a/P1/solutionexe/mapreduce.good b/P1/solutionexe/mapreduce.good deleted file mode 100755 index 402e9af..0000000 Binary files a/P1/solutionexe/mapreduce.good and /dev/null differ diff --git a/P1/solutionexe/reducer.good b/P1/solutionexe/reducer.good deleted file mode 100755 index 58e0ec4..0000000 Binary files a/P1/solutionexe/reducer.good and /dev/null differ -- cgit v1.2.3 From 416670578c7135300435eacfba52a91c2b25fee8 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Mon, 5 Oct 2020 22:41:10 -0500 Subject: Add error handler for mappers --- P1/src/mapreduce.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/P1/src/mapreduce.c b/P1/src/mapreduce.c index 9efccf7..2428f75 100644 --- a/P1/src/mapreduce.c +++ b/P1/src/mapreduce.c @@ -11,6 +11,10 @@ int main(int argc, char *argv[]) { // ###### DO NOT REMOVE ###### int nMappers = strtol(argv[1], NULL, 10); int nReducers = strtol(argv[2], NULL, 10); + if (nMappers < nReducers) { + printf("Number of mappers must be greater than or equal to the number of reducers.\n"); + exit(2); + } char *inputFile = argv[3]; // ###### DO NOT REMOVE ###### -- cgit v1.2.3 From 38c4c82aaa32e89c54c3adfb4245217557dd0740 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Mon, 5 Oct 2020 22:54:37 -0500 Subject: Add error handling (Fixing #4 again) --- P1/src/mapreduce.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/P1/src/mapreduce.c b/P1/src/mapreduce.c index 2428f75..19cf937 100644 --- a/P1/src/mapreduce.c +++ b/P1/src/mapreduce.c @@ -38,14 +38,24 @@ int main(int argc, char *argv[]) { char numMap[10]; sprintf(numMap, "%d", i); execl("./mapper", "./mapper", &numMap, NULL); + printf("Mapper execution failed! Make sure \"mapper\" exists in the directory.\n"); + return 4; + } else if (mapperPid == -1) { + printf("Fork failed!\n"); + return 1; } } for (int i = 0; i <= nMappers; i++) { //Hopefully this works - wait(NULL); + int waitError = wait(NULL); + if (waitError == -1) + { + printf("Wait failed!\n"); + return 5; + } } - +printf("Not stuck here.\n"); // ###### DO NOT REMOVE ###### // shuffle sends the word.txt files generated by mapper @@ -57,7 +67,7 @@ int main(int argc, char *argv[]) { } sleep(1); - +printf("Not stuck here.\n"); pid_t reducerPid; for (int i = 1; i <= nReducers; i++) { @@ -66,12 +76,21 @@ int main(int argc, char *argv[]) { char numRed[10]; sprintf(numRed, "%d", i); execl("./reducer", "./reducer", &numRed, NULL); + printf("Reducer execution failed! Make sure \"reducer\" exists in the directory.\n"); + return 3; + } else if (reducerPid == -1) { + printf("Fork failed!\n"); + return 2; } } for (int i = 0; i <= nReducers; i++) { //Maybe this works too? - wait(NULL); + int waitError = wait(NULL); + if (waitError == -1) { + printf("Wait failed!\n"); + return 5; + } } return 0; -- cgit v1.2.3