We have set up a cluster of 10 machines. You should use those for all of the lab assignments.
You will write the labs in Google's golang. It is a young language with a language syntax at somewhere between C/C++ and Python. It comes with a very rich standard library, and also language-level support for light-weight but powerful concurrency semantics like go routines and channels.
Here is some key documentation on the language:
While you should be able to find a lot of documents about Go language on the web, especially from the official site. If you know C++ already, here are some hints that might help you bootstrap.
recover. However it is not encouraged to use that for error handling.
foris the only loop keyword.
Here is the story: some cowboy programmer wrote a simple online microblogging service called Tribbler, and leveraging the power of the Web, it becomes quite popular. However, the program runs in one single process; it does not scale, cannot support many concurrent connections, and is vulnerable to machine crashes. Knowing that you are taking the distributed computing system course at UCSD, he asks you for help. You answered his call and started this project.
Your goal is to refactor Tribbler into a distributed system, make it robust and scalable.
The Tribbler project is written in golang and stored in a git repository now. To get started, run these commands in command line:
$ cd # go to your home directory $ mkdir -p gopath/src # the path you use for storing golang src $ cd gopath/src $ git clone /classes/cse223b/sp14/labs/trib -b lab1 $ git clone /classes/cse223b/sp14/labs/triblab -b lab1 $ export GOPATH=~/gopath $ go install ./...
Do some basic testing see if the framework is in good shape:
$ go test ./trib/...
Now The basic Tribbler service should be installed on the system in your home directory. Let's give it a try:
$ ~/gopath/bin/trib-front -init -addr=:rand
The program should show that it serves on a port (which is randomly generated).
Now open your browser and type in the address. For example, if the
machine you logged in was
c08-11.sysnet.ucsd.edu, and Tribbler is
running on port 27944, then open
http://c08-11.sysnet.ucsd.edu:27944. You should see a list of Tribbler users, where you can view their tribs and login as them (with no authentication).
This is how the Tribbler service looks like to the user clients. It is a single Web page the performs AJAX calls (a type of RPC that is widely used in Web 2.0) to the web server behind. The webserver then in turn calls the Tribbler logic functions and returns the results back to the Web page in the browser.
If you find it difficult to access the lab machines outside UCSD campus, you need to setup a UCSD VPN or ssh tunnel.
The source code in the
trib package repository is organized as follow:
tribdefines the common Tribbler interfaces and data structures.
trib/tribtestprovides several basic test cases for the interfaces.
trib/cmd/trib-frontis the web-server launcher that you just run.
trib/cmd/kv-clientis a command line key-value RPC client for quick testing.
trib/cmd/kv-serverruns a key-value service as an RPC server.
trib/cmd/bins-clientis a bin storage service client.
trib/cmd/bins-backis a bin storage service back-end launcher.
trib/cmd/bins-keeperis a bin stroage service keeper launcher.
trib/cmd/bins-mkrcgenerates a bin storage configuration file.
trib/entriesdefines helper several functions on constructing a Tribbler front-end or a back-end.
trib/refis a reference monolithic implementation of the
trib.Serverinterface. All the server logic runs in one single process. It is not scalable and vulnerable to machine crashes.
trib/storecontains an in-memory thread-safe implementation of the
trib.Storeinterface. We will use this as the basic building block for our back-end storage system.
trib/randaddrprovides helper functions that generate a network address with a random port number.
trib/localprovides helper functions that check if an address belongs to the machine that the program is running.
trib/colonprovides helper functions that escape and unescape colons in a string.
trib/wwwcontains the static files (html, css, js, etc.) for the web front-end.
Don't be scared by the number of packages. Most of the packages are
very small. In fact, all Go language files under
trib directory is
less than 2500 lines in total (the beauty of Go!).
Through the entire lab, you do not need to (and should not) modify anything in
trib repository. If you feel that you have to change some code to
complete your lab, please discuss with the TA. You are always welcome to read
the code in
trib repository. If you find any bug and reported it, you might
get some bonus credit.
Your job is to complete the implementation of the
It is in the second repo that we checked out.
It would be a good practice for you to periodically commit your code
into your own
triblab git repo. Only files commited in that repo
will be submitted for grading.
By the end of the labs, you will have a new Tribbler service implementation that is scalable and fault-tolerant.
For convenience, you might set environment variables in your
export GOPATH=$HOME/gopath export PATH=$PATH:$GOPATH/bin
We should have Vim and Emaces installed on the machines. If you need
to install other utility packages, ask the TA. Note that you do not
sudo permissions on any of the machines; any
will be automatically reported, so please don't even try it.
You could also write your code on your own machine if you want to. See Go language's install page for more information. However, you should test your code on the lab machines.
If you feel comfortable with the lab setup now, go forward and read Lab1.
Last updated: Sat Apr 26 19:31:03 -0700 2014 [validate xhtml]