At this point, most of you are probably ready to understand and implement a Dynamo style key value storage; this assignment is about implementing a simplified version of Dynamo. (And you might argue that it’s not Dynamo any more ;) There are three main pieces you need to implement: 1) Partitioning, 2) Replication, and 3) Failure handling.
The main goal is to provide both availability and linearizability at the same time. In other words, your implementation should always perform read and write operations successfully even under failures. At the same time, a read operation should always return the most recent value. To accomplish this goal, this document gives you a guideline of the implementation. However, you have freedom to come up with your own design as long as you provide availability and linearizability at the same time (that is, to the extent that the tester can test)
The exception is partitioning and replication, which should be done exactly the way Dynamo does.
This document assumes that you are already familiar with Dynamo. If you are not, that is your first step. There are many similarities between this assignment and the previous assignment for the most basic functionalities, and you are free to reuse your code from the previous assignment.
Before we discuss the requirements of this assignment, here are two references for the Dynamo design:- Lecture slides
- Dynamo paper
- Just like the previous assignment, you need to support insert/query/delete operations. Also, you need to support @ and * queries.
- There are always 5 nodes in the system. There is no need to implement adding/removing nodes from the system.
- However, there can be at most 1 node failure at any given time . We will emulate a failure only by force closing an app instance. We will not emulate a failure by killing an entire emulator instance.
- All failures are temporary; you can assume that a failed node will recover soon, i.e., it will not be permanently unavailable during a run.
- When a node recovers, it should copy all the object writes it missed during the failure. This can be done by asking the right nodes and copy from them.
- Please focus on correctness rather than performance. Once you handle failures correctly, if you still have time, you can improve your performance.
- Your content provider should support concurrent read/write operations .
- Your content provider should handle a failure happening at the same time with read/write operations .
- Replication should be done exactly the same way as Dynamo does. In other words, a (key, value) pair should be replicated over three consecutive partitions, starting from the partition that the key belongs to.
- Unlike Dynamo, there are two things you do not need to implement. a. Virtual nodes: Your implementation should use physical nodes rather than virtual nodes, i.e., all partitions are static and fixed. b. Hinted handoff: Your implementation do not need to implement hinted handoff. This means that when there is a failure, it is OK to replicate on only two nodes.
- All replicas should store the same value for each key. This is “perkey” consistency. There is no consistency guarantee you need to provide across keys. More formally, you need to implement perkey linearizability .
- Each content provider instance should have a node id derived from its emulator port. This node id should be obtained by applying the above hash function (i.e., genHash()) to the emulator port. For example, the node id of the content provider instance running on emulator5554 should be, node_id = genHash(“5554”) . This is necessary to find the correct position of each node in the Dynamo ring.
- Your content provider’s URI should be “content://edu.buffalo.cse.cse486586.simpledynamo.provider”, which means that any app should be able to access your content provider using that URI. This is already defined in the template, so please don’t change this. Your content provider does not need to match/support any other URI pattern.
- We have fixed the ports & sockets. a. Your app should open one server socket that listens on 10000. b. You need to use run_avd.py and set_redir.py to set up the testing environment. c. The grading will use 5 AVDs. The redirection ports are 11108, 11112, 11116, 11120, and 11124. d. You should just hardcode the above 5 ports and use them to set up connections. e. Please use the code snippet provided in PA1 on how to determine your local AVD. i. emulator5554: “5554” ii. emulator5556: “5556” iii. emulator5558: “5558” iv. emulator5560: “5560” v. emulator5562: “5562”
- Any app (not just your app) should be able to access (read and write) your content provider. As with the previous assignment, please do not include any permission to access your content provider.
-
Membership
- Just as the original Dynamo, every node can know every other node. This means that each node knows all other nodes in the system and also knows exactly which partition belongs to which node; any node can forward a request to the correct node without using a ringbased routing.
-
Request routing
- Unlike Chord, each Dynamo node knows all other nodes in the system and also knows exactly which partition belongs to which node.
- Under no failures, a request for a key is directly forwarded to the coordinator (i.e., the successor of the key), and the coordinator should be in charge of serving read/write operations.
-
Quorum replication
- For linearizability, you can implement a quorumbased replication used by Dynamo.
- Note that the original design does not provide linearizability. You need to adapt the design.
- The replication degree N should be 3. This means that given a key, the key’s coordinator as well as the 2 successor nodes in the Dynamo ring should store the key.
- Both the reader quorum size R and the writer quorum size W should be 2.
- The coordinator for a get/put request should always contact other two nodes and get a vote from each (i.e., an acknowledgement for a write, or a value for a read).
- For write operations, all objects can be versioned in order to distinguish stale copies from the most recent copy.
- For read operations, if the readers in the reader quorum have different versions of the same object, the coordinator should pick the most recent version and return it.
-
Chain replication
- Another replication strategy you can implement is chain replication, which provides linearizability.
- If you are interested in more details, please take a look at the following paper: http://www.cs.cornell.edu/home/rvr/papers/osdi04.pdf
- In chain replication, a write operation always comes to the first partition; then it propagates to the next two partitions in sequence. The last partition returns the result of the write.
- A read operation always comes to the last partition and reads the value from the last partition.
-
Failure handling
- Handling failures should be done very carefully because there can be many corner cases to consider and cover.
- Just as the original Dynamo, each request can be used to detect a node failure.
- For this purpose, you can use a timeout for a socket read; you can pick a reasonable timeout value, e.g., 100 ms, and if a node does not respond within the timeout, you can consider it a failure.
- Do not rely on socket creation or connect status to determine if a node has failed. Due to the Android emulator networking setup, it is not safe to rely on socket creation or connect status to judge node failures. Please use an explicit method to test whether an app instance is running or not, e.g., using a socket read timeout as described above.
- When a coordinator for a request fails and it does not respond to the request, its successor can be contacted next for the request.