Distributed Searching
1. Getting Started
- Firstly, download the data from here
- Extract the data; you should have the following directory structure
code/ server.go slave.go client.go data/ passwords.txt
- Run
split.go
like so:All options are given belowgo run split.go
Doing so will split the data into chunks and will save in-fileName string filename to make chunks of (default "../data/passwords.txt") -outDir string directory to save chunks in (default "../data/chunks/") -totalChunks int number of equal chunks to divide the file in (default 4)
chunks/
subdirectory inside thedata/
; you should now have the following directory structurecode/ server.go ... data/ passwords.txt chunks/ 1.txt 2.txt ...
2. Usage
- Firstly, run server like so:
All options are given below
go run server.go
-numChunks int total number of chunks (must be numbered from 1-numChunks inclusive) (default 4) -portClients string port number for clients connection (default "3001") -portSlaves string port number for slaves connection (default "3000") -timeout int time threshold (in seconds) for heartbeat from slaves (default 3)
- Afterwards, run slave(s) like so:
All options are given below
go run slave.go
-chunkIds string identifiers of chunk a slave is hosting (default "1 2 3") -dataDir string data folder containing all chunks (default "../../data/chunks") -heartbeatFreq int time (in seconds) after which to send periodic heartbeat (default 2) -serverAddress string IP and port of server (default "127.0.0.1:3000")
- Lastly, run client(s) for queries, like so:
All options are given below
go run client.go
-bufferSize int buffer size of buffer to store incoming messages in (default 10) -serverAddress string IP and port of server (default "127.0.0.1:3001") -toFind string string to search from the server (default "helloworld")