You will write the labs in Google's golang. It is a young language with a syntax somewhere between C/C++ and Python. It comes with a very rich standard library, and language-level support for light-weight but powerful concurrency semantics with go routines and channels.
Here is some key documentation on the language:
You should be able to find a lot of documents about the Go language on the web, especially from the official site. We highly recommend the official Go tutorial (or "Tour") linked above.
panic
and recover
. However panic
should only be used in dire cases. Error handling should be done with returned Error
structs.for
is the only looping mechanism.range
keyword.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 a single process on a single machine; 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 are starting work on this project.
Your goal is to refactor Tribbler into a distributed system, making it more robust and scalable.
We will be using Github Classroom to distribute assignments and manage submissions. We will send out invitation links for each individual lab through Piazza/Canvas. Once you access these links, a GitHub repository containing Tribbler starter code will be created for you. It comes with necessary instructions on how to setup environment before you start, and submit your work when you are done.
Once you download your first lab (and before you start working on it), you can run the basic version of Tribbler. The Tribbler project is written in golang. To get started, run these commands from the command line:
$ cd # go to your assignment directory
$ export GOPATH=$(pwd)
$ go install ./...
You can do some basic testing to see if the framework is in good shape:
$ go test ./src/trib/...
The basic Tribbler service should now be installed on the system from your home directory. Let's give it a try:
$ ./bin/trib-front -init -addr=:rand
The program should show the port it is running on (it uses a randomly generated port).
Open your browser and type in the address: http://<host-name>:<port>
. For example, if you are using your local machine, and Tribbler is running on port 27944, then open http://localhost:27944
. If you are using AWS EC2 machine, you can use its public DNS name as host name (make sure to allow traffic on this port to your instance). You should see a list of Tribbler users. You can view their tribs and login as them (with no authentication).
This is how Tribbler looks to users. It is a single web page that performs AJAX calls (a type of web-based RPC) to the back-end web server. The webserver then in turn calls the Tribbler logic functions and returns the results back to the Web page in the browser.
The source code in the trib
package is organized as follows:
trib
defines the common Tribbler interfaces and data structures.trib/tribtest
provides several basic test cases for the interfaces.trib/cmd/trib-front
is the web-server launcher that you run.trib/cmd/kv-client
is a command line key-value RPC client for quick testing.trib/cmd/kv-server
runs a key-value service as an RPC server.trib/cmd/bins-client
is a bin storage service client.trib/cmd/bins-back
is a bin storage service back-end launcher.trib/cmd/bins-keeper
is a bin stroage service keeper launcher.trib/cmd/bins-mkrc
generates a bin storage configuration file.trib/entries
defines several helper functions for constructing a Tribbler front-end or a back-end.trib/ref
is a reference monolithic implementation of the trib.Server
interface. All the server logic runs in one single process. It is not scalable and is vulnerable to machine crashes.trib/store
contains an in-memory thread-safe implementation of the trib.Store
interface. We will use this as the basic building block for our back-end storage system.trib/randaddr
provides helper functions that generate a network address with a random port number.trib/local
provides helper functions that check if an address belongs to the machine that the program is running.trib/colon
provides helper functions that escape and unescape colons in a string.trib/www
contains 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, and you don't have to interact with all of them at once. All Go language files under the trib
directory are less than 2500 lines in total (the beauty of Go!), so these packages aren't huge and intimidating.
Through the entire lab, you do not need to (and should not) modify anything in the trib
directory. If you feel that you have to change some code to complete your lab, please first discuss it with the TA. You are always welcome to read the code in the trib
directory. If you find a bug and report it, you might get some bonus credit.
Your job is to complete the implementation of the triblab
package. It is in the second directory under src
directory.
It would be good practice for you to periodically commit your code to your git repo.
By the end of the labs, you will have an implementation of Tribbler that is scalable and fault-tolerant.
If you feel comfortable with the lab setup, continue on to Lab1.
Last updated: 2021-05-18 07:43:47 -0700 [validate xhtml]