# Assignment 2: Chandy-Lamport Distributed Snapshots

Introduction

In this assignment you will implement the Chandy-Lamport algorithm for distributed snapshots. Your snapshot algorithm will be implemented on top of a token passing system, similar to the ones presented in slides and in the Chandy-Lamport paper. The algorithm makes the following assumptions:

Software

You will find the code under this directory. The code is organized as follows:

Of these files, you only need to turn in server.go and simulator.go, i.e., your commit could only contain changes to these two files. However, some other files also contain information that will be useful for your implementation or debugging, such as the debug flag in common.go and the thread-safe map in syncmap.go. However, you do not have to use the provided SyncMap if you would prefer to implement its functionality yourself. Your task is to implement the functions that say TODO: IMPLEMENT ME, adding fields to the surrounding classes if necessary.

Testing

Our grading uses the tests in snapshot_test.go provided to you. Test cases can be found in test_data/. To test the correctness of your code, simply run the following command:

  $ cd 586/assignment2/
  $ export GOPATH="$PWD"
  $ cd src/
  $ go mod init a2
  $ cd chandy-lamport/
  $ go test
  Running test '2nodes.top', '2nodes-simple.events'
  Running test '2nodes.top', '2nodes-message.events'
  Running test '3nodes.top', '3nodes-simple.events'
  Running test '3nodes.top', '3nodes-bidirectional-messages.events'
  Running test '8nodes.top', '8nodes-sequential-snapshots.events'
  Running test '8nodes.top', '8nodes-concurrent-snapshots.events'
  Running test '10nodes.top', '10nodes.events'
  PASS
  ok      _/path/to/chandy-lamport 0.012s

To run individual tests, you can look up the test names in snapshot_test.go and run:

  $ go test -run 2Node
  Running test '2nodes.top', '2nodes-simple.events'
  Running test '2nodes.top', '2nodes-message.events'
  PASS
  ok      chandy-lamport  0.006s
## Point Distribution
TestPoints
2NodesSimple13
2NodesSingleMessage13
3NodesMultipleMessages14
3NodesMultipleBidirectionalMessages14
8NodesSequentialSnapshots15
8NodesConcurrentSnapshots15
10Nodes16
## Submitting Assignment You hand in your assignment as before. ```bash $ git commit -am "[you fill me in]" $ git tag -a -m "i finished assignment 2" a2-handin $ git push origin master a2-handin ``` Submit your assignment on Autolab (https://autograder.cse.buffalo.edu/).

Recall, in order to overwrite a tag use the force flag as follows.

```bash $ git tag -fam "i finished assignment 2" a2-handin $ git push -f --tags ``` You should verify that you are able to see your final commit and tags on the Github page of your repository for this assignment.