diff --git a/Wc b/Wc index 39b695f56e837a420befc3d41d00cc4a68a0e147..15698478922ff0906eaced616ba3352c376927dc 100755 Binary files a/Wc and b/Wc differ diff --git a/mappers/wc.cpp b/mappers/wc.cpp index 81a006c25cac42a56f009ed515701641b156cd1c..dd2307ba0bdec8f2a21ca4038978a7df05e5bd7e 100644 --- a/mappers/wc.cpp +++ b/mappers/wc.cpp @@ -6,6 +6,10 @@ int main(int argc, char **argv) { std::string delim = " "; while (std::getline(file, str)) { + for (int i = 0; i < str.size(); i++) { + if (str[i] == '.' || str[i] == ',' || str[i] == '?' || str[i] == ';' || str[i] == '!') str[i] = ' '; + str[i] = tolower(str[i]); + } std::vector<std::string> temp = splitString(str, delim); for (auto &e : temp) std::cout << e << "," << "1" << std::endl; } diff --git a/src/Node.cpp b/src/Node.cpp index 5efec0267887973febf393026d292ff5091cbae8..71e98e01b99e62ba79a039f751d27c71ce952f4b 100644 --- a/src/Node.cpp +++ b/src/Node.cpp @@ -908,19 +908,22 @@ void Node::handleTcpMessage() close(dataPipe[0]);close(dataPipe[1]); //go thorugh and process things from datapipe //if processing success, send out TCP MAPLEACK - string match = "tmp-" + sdfsPre; + string match = "tmp-"; int matchLen = match.size(); struct dirent *entry = nullptr; DIR *dp = nullptr; if ((dp = opendir(".")) == nullptr) { cout << "tmp directory error " << match << endl; break; } while ((entry = readdir(dp))){ - cout << "[FILES] found " << entry->d_name << " looking to match " << to_string(matchLen) << " chars from " << match << endl; + //cout << "[FILES] found " << entry->d_name << " looking to match " << to_string(matchLen) << " chars from " << match << endl; if (strncmp(entry->d_name, match.c_str(), matchLen) == 0){ string searcher(entry->d_name); - string target = searcher.substr(4); - cout << "[CHUNKACK] found " << entry->d_name << endl; + string target = searcher.substr(4); //get rid of tmp for official keys + //cout << "[CHUNKACK] found " << entry->d_name << endl; + + //TODO: add prefix here Messages outMsg(DNS, nodeInformation.ip + "::" + to_string(hashRingPosition) + "::" + target + "::" + entry->d_name + "::" + to_string(-1) + "::" + to_string(-1) + "::" + target + "::" + "0"); - cout << "[PUT] Got localfilename: " << entry->d_name << " with sdfsfilename: " << target << endl; + + //cout << "[PUT] Got localfilename: " << entry->d_name << " with sdfsfilename: " << target << endl; tcpServent->sendMessage(leaderIP, TCPPORT, outMsg.toString()); } } @@ -1043,7 +1046,7 @@ void Node::handleTcpMessage() // update fileList, client itself is one of the replicas updateFileList(sdfsfilename, nodePosition); fileSizes[sdfsfilename] = make_tuple(size, lines); - hashRing->debugHashRing(); + //hashRing->debugHashRing(); int closestNode = hashRing->locateClosestNode(sdfsfilename); int pred = hashRing->getPredecessor(closestNode); int succ = hashRing->getSuccessor(closestNode); diff --git a/src/TcpSocket.cpp b/src/TcpSocket.cpp index 277bd031719cb61158e36cc3fd1e68de2e7f8bde..fa9c6c26ed6456ff70c05e0cd41fbd75bf7e40a7 100644 --- a/src/TcpSocket.cpp +++ b/src/TcpSocket.cpp @@ -233,9 +233,9 @@ int TcpSocket::messageHandler(int sockfd, string payloadMessage, string returnIP localfilename = sdfsfilename+"_"+to_string(fileTimestamp); if (overwriteFilename.compare("") != 0) { localfilename = overwriteFilename; - cout << "it's GET with filename " << overwriteFilename << endl; + //cout << "it's GET with filename " << overwriteFilename << endl; } - cout << "backup filename " << localfilename << endl; + //cout << "backup filename " << localfilename << endl; } else { //exec, read, start, tmp, prefix localfilename = fields[3]; //tempfile to read from @@ -263,11 +263,11 @@ int TcpSocket::messageHandler(int sockfd, string payloadMessage, string returnIP cout << "we have " << to_string(byteReceived) << " bytes from this connection" << endl; fclose(fp); - FileObject f(localfilename); - if(incomingChecksum.compare(f.checksum) != 0 && incomingChecksum.compare("") != 0){ - cout << "[ERROR] FILE CORRUPTED" << endl; + //FileObject f(localfilename); + //if(incomingChecksum.compare(f.checksum) != 0 && incomingChecksum.compare("") != 0){ + // cout << "[ERROR] FILE CORRUPTED" << endl; // TODO: Handel file corruption here - } else { + //} else { if (start != -1){ //IP, exec, start, temp, actual file Messages putack(CHUNKACK, returnIP + "::" + sdfsfilename + "::" + to_string(start) + "::" + localfilename + "::" + remoteLocalname); @@ -276,7 +276,7 @@ int TcpSocket::messageHandler(int sockfd, string payloadMessage, string returnIP Messages putack(PUTACK, returnIP + "::" + sdfsfilename + "::" + localfilename+"::"+remoteLocalname); regMessages.push(putack.toString()); } - } + //} break; } case DNSANS: diff --git a/src/Utils.cpp b/src/Utils.cpp index 5c7cd89d6ec10795389807584b14ad83eae55a45..2c06f2c00a5675dd5f12b51b9ef33eb1093fdc43 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -63,11 +63,11 @@ void handlePipe(int file) { std::string key(strtok(str, delim)); std::string val(strtok(NULL, delim)); string keyFile = "tmp-" + key; - string write = key + "," + val + "\n"; + string write = key + "," + val; tmp = fopen(keyFile.c_str(), "ab"); fwrite(write.c_str(),sizeof(char),write.size(),tmp); fclose(tmp); - cout << "[PIPE] " << key << " to " << keyFile << endl; + //cout << "[PIPE] " << key << " to " << keyFile << endl; } fclose (stream); }