CSE 223B Labs

Programming Language

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.

The Tribbler 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 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.

Getting Started

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.

Source Code Organization

The source code in the trib package is organized as follows:

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

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.

Lab Roadmap

By the end of the labs, you will have an implementation of Tribbler that is scalable and fault-tolerant.

Ready?

If you feel comfortable with the lab setup, continue on to Lab1.


Last updated: 2021-05-18 07:43:47 -0700 [validate xhtml]