Informatics 117 : Team Optimize Prime
- Brenda La
- David Pham
- Eric Chou
- Jose Gomez
- Sheila Truong
$ go get -u github.com/govend/govend # make sure govend is installed
$ git clone https://github.com/blics18/SendGrid.git # grab all the code from github
$ govend -v # download all the dependencies in the vendor.yml file
healthBF
check the status of the serverpopulateBF
add data into the Bloom FiltercheckBF
check if data exists in the Bloom FilterclearBF
clear the Bloom Filter
- healthBF
curl localhost:1234/healthBF
- populateBF
curl localhost:1234/populateBF -d "[{\"UserID\": 123, \"Email\": [\"[email protected]\"]}]"
- checkBF
curl localhost:1234/checkBF -d "{\"UserID\": 123, \"Email\": [\"[email protected]\"]}"
- clearBF
curl localhost:1234/clearBF
BLOOM_SIZE
size of the Bloom FilterBLOOM_PORT
port that the server will run onBLOOM_NUM_USERS
number of users that will be generatedBLOOM_NUM_EMAILS
up to this number of emails that each user will haveBLOOM_NUM_HASH_FUNCTIONS
number of hash functionsBLOOM_NUM_TABLES
is NOT configurable, because createTables.sql is hard coded to create only 5 tables.
-
client.go
- Populate() - grabs data from MySQL, packages it as a JSON, and sends it to populateBF endpoint
- Clear() - calls clearBF endpoint to clear the bloom filter
- Check() - passes userid and list of emails to checkBF endpoint; calls checkBF to check if an input exists in the bloom filter
-
runClient.go
the client "main", and what we used to demo. Calls on all relevant endpoints (health, populate, check) -
server.go
- healthBF() - checks to see if the server is up and running
- populateBF() - retreives the JSON data, parses it, and populates the bloom filter with it
- checkBF() - retreives the JSON data, parses it, and checks the data against the bloom filter. Also cross checks against the MySQL database if the data exists within the bloom filter
- clearBF() - clears the bloom filter
-
createTables.sql
SQL file that creates the database and tables -
database.go
creates and inserts randomly-generated data into the MySQL database -
server_test.go
unit testing -
benchmark_test.go
benchmarking for each endpoint except healthBF -
generateEmail.go
generates random userIDs and emails -
data.txt
file with randomly generated data (filled with suppression data and NON-suppresion data)
- Change into directory of
server_test.go
- In the terminal, type
go test
- Change into directory of
benchmark_test.go
- In the terminal, type
go test -run=XXX -bench=name_of_function()
- Make sure that Docker is downloaded and running
- Set up Graphite in docker:
docker run -d\
--name graphite\
--restart=always\
-p 80:80\
-p 2003-2004:2003-2004\
-p 2023-2024:2023-2024\
-p 8125:8125/udp\
-p 8126:8126\
hopsoft/graphite-statsd
- Run server.go, and test using curl commands
- Go to
localhost
in any browser to check and configure the metrics
- Create the docker container:
docker run -v $(pwd)/createTables.sql:/root/createTables.sql --name bfmysql -it -d -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -p 3306:3306 percona
- Run this command on the container:
docker exec -it bfmysql /bin/bash
- Change directories to where the .sql file is stored:
cd /root
- Run the file that creates the schema with
mysql < createTables.sql
- Hits: Number of ACCURATE predictions. This has nothing to do if the value is in the Bloom Filter or not.
- Misses: Number of INACCURATE predictions. This has nothing to do if the value is in the Bloom Filter or not.