tecnogram888 / Project4Skeleton

http://inst.eecs.berkeley.edu/~cs162/sp12/phase4.html
1 stars 0 forks source link

processTPCOpRunnable in TPCMaster #4

Open tecnogram888 opened 12 years ago

tecnogram888 commented 12 years ago

Implement details: two phase commit

FOUR PARTS:

INIT WAIT Abort Commit

tecnogram888 commented 12 years ago

http://piazza.com/class#spring2012/cs162/755

tecnogram888 commented 12 years ago

I added a skeleton so you can see where you come in

tecnogram888 commented 12 years ago

If you do a few, i can see how it's done..I can do a few too if it ends up being too many

tecnogram888 commented 12 years ago

other people can chip in also

tecnogram888 commented 12 years ago

code:

        while (true) {
            switch (TPCState) {
                // send the appropriate message to client
                case INIT: 
                    if (isPutReq) {
                        // LUKE SEND 2PC Put Value Request
                    } else {
                        // LUKE SEND 2PC Del Value Request
                    }
                    break;
                case WAIT:
                    // Luke send right message
                    break;
                case ABORT:
                    // Luke send message
                    break;
                case COMMIT:
                    // Luke send message
                    break;
                default: 
                    return;
            }
            // TODO: Listen for response from client 
            boolean nextStep = true; // LUKE SET THIS VALUE TO true if we receive the right message, false if not
            boolean commit = true; // LUKE SET THIS VALUE based on message received
            if (nextStep) {
                otherThreadDoneLock.lock();
                if (otherThreadDone == false) {
                    otherThreadDone = true;
                } else {
                    otherThreadDone = false;
                    // move on to appropriate state. 
                }
                otherThreadDoneLock.unlock();
            }
        }