Throughout this lab you will create a personal GitHub account, use that GitHub account to modify some code from the Lab repository, and then submit it to us for grading! This same basic process will be used throughout CS193 to complete and turn in all of your labs, so for this first one, we're focusing on making sure you can understand the process.
If you already have a personal Github account and have activated your Student Developer Pack (i.e. you can create private repositories), feel free to ignore this section.
Github is a service that combines the git version control system (remember what version control is from lecture?) with code hosting and project management services. Throughout most of your career as a Software Developer, you'll be using Github A LOT, so let's go ahead and get you set up with an account.
Hop on over to the Github website. Once you're there, click on the Sign Up link in the upper right to create your account. Choose a memorable, but professional, username (you'll probably have your Github username listed on your resume and be handing it out to companies regularly). Use your Purdue email address to create this account as well. This will allow you to unlock some sweet benefits that Github gives to students for free.
Once your Github account is all set up, you need to request access to the Github Student Developer pack. To do this, navigate to the Student Developer Pack website and follow the steps there to request access. As soon as you have access to the student benefits, you can continue on with this lab.
In lecture and during lab we gave out a link to follow to access Lab 1 on Github. Follow this link and click the "Accept" button to begin importing the Lab 1 repository to your personal Github account. You should receive an email when this is complete (<1 minute).
Now head on over to github.com and (if you're logged in and everything went smoothly) you should see a new repository called Purdue-CS193/lab-1-<Your Github Username>. You will be editing some files in this repository to complete your lab.
The repository that was just added to your Github account is already set up with a simple file that displays a basic website. The website content is found in the index.md file. Throughout this lab you will be editing this file to create your own content for this website.
To active the website so you can navigate to it, click on the Purdue-CS193/lab-1-<Your Github Username> repository from your Github home page. In the upper right corner, click on the Settings button. Scroll down to the section called GitHub Pages. Change the Source setting to the option called master branch and click save. At this point, you can navigate to https://purdue-cs193.github.io/lab-1-<Your Github Username>/
to view the website you just activated!
Right now, there isn't any meaningful content in this website, just a placeholder that tells you a little about what you can do with the website template.
Having just a template website is pretty boring. To edit your website to display more interesting content, go back to the main page for the Purdue-CS193/lab-1-<Your Github Username> repository.
From here, click on the index.md file. You should see the same content you viewed at https://purdue-cs193.github.io/lab-1-<Your Github Username>/
except this time it is not themed.
To edit this file, click on the edit button (it looks like a little pencil) in the upper right hand corner of the file display. This will open a text editor where you can change the contents of the website to whatever you want. Take a few minutes to experiment with the different formatting tools that the website template tells you are available.
To save your changes so that they will display on your website, fill out the Commit Changes form by describing what you changed about the website. Select the option called Commit directly to the master branch and click Commit changes. If all is well, you should be able to navigate back to https://purdue-cs193.github.io/lab-1-<Your Github Username>/
and view the changes you made.
When you're ready, create a heading (a heading is some text that is preceded by a # sign) to title your website <Your Name>'s first CS193 Lab
Next, create a bulleted list of some of your favorite things about Purdue CS193 (if you don't have any, I'll be sad :( but try to make some up anyway).
When you're done, commit your changes, just as you did above and you're done! CONGRATULATIONS you just completed your first CS193 Lab :) Give yourself a pat on the back and bask in the glory of your brand new fancy GitHub Website!
If you aren't a fan of the super cool hacker theme that I chose to be the default of your website, you can easily change it. Navigate to the settings page for your Purdue-CS193/lab-1-<Your Github Username> and scroll down to the GitHub Pages section. Click on Change theme and pick your favorite theme!
// In QuorumCnxManager.java
@Override
public void run() {
...
lastMessageSent.put(sid, b);
// DMCK: event interception
InterceptionLayer.interceptLEEvent(self.getId(), sid,
stateOrdinal, leader, zxid, epoch);
send(b);
...
}
// Leader election update
else if (filename.startsWith("zkUpdate-")) {
// parse local states from file
...
dmck.localStates[sender].setKeyValue("state", state);
dmck.localStates[sender].setKeyValue("proposedLeader", proposedLeader);
dmck.localStates[sender].setKeyValue("proposedZxid", proposedZxid);
...
}
// In target-sys-conf
# number of nodes to start with
num_node=3
# number of nodes total in cluster
num_node_total=4
# Workload - Number of Crash(es) (Optional)
# Define how many crashes that you want to test in your workload
num_crash=3
# Workload - Number of Reboot(s) (Optional)
# Define how many reboots that you want to test in your workload
num_reboot=3
// In adjustCrashAndReboot()
tmp = Math.min(numAdd, numNodeTotal - numOnline);
for (int i = 0; i < tmp; ++i) {
AbstractNodeAddTransition add = new AbstractNodeAddTransition(this);
for (int j = 0; j < numNodeTotal; ++j) {
add.setPossibleVectorClock(j, vectorClocks[j][numNodeTotal]);
}
enabledTransitions.add(add);
numAdd--;
}
@Override
public boolean apply() {
LOG.info("Add and start node " + id + " " + Arrays.deepToString(vectorClock));
if (dmck.runNode(id, vectorClock, 1)) {
dmck.numCurrentReboot++;
dmck.numNode++;
return true;
}
return false;
}
// In QuorumPeer.java
synchronized (QV_LOCK) {
if (qcm != null && quorumVerifier != null && lastSeenQuorumVerifier != null) {
...
// intercept for quorum peer thread
InterceptionLayer.interceptQuorumPeerEvent(this.getId(), e.getKey());
qcm.connectOne(e.getKey());
}
}
// In QuorumCnxManager.java
public void receiveConnection(Socket sock) {
...
// intercept for listener
InterceptionLayer.interceptConnectEvent(self.getId(), sid);
connectOne(sid);
...
}
// In QuorumCnxManager.java
synchronized void connectOne(long sid){
...
synchronized (self.QV_LOCK) {
...
String addr = self.getElectionAddress().getHostString()
+ ":" + self.getElectionAddress().getPort();
...
}
...
}
Step 1. Deploy 3 nodes A,B,C with configuration A,B,C .
Step 2. Deploy node ` D` with configuration `A,B,C,D`.
Step 3. Restart nodes A,B,C with configuration A,B,C,D,
then the leader will be D, cluster hangs, command like
`ls /` will be blocked.
Step 4. Restart nodes D, cluster state is back to normal now.
// In QuorumPeer.java
public InetSocketAddress getElectionAddress(){
synchronized (QV_LOCK) {
return myElectionAddr;
}
}
// In Leader.java
void lead() throws IOException, InterruptedException {
...
InterceptionLayer.interceptLeaderLead(self.getId());
startZkServer();
...
}
synchronized void startZkServer() {
...
QuorumVerifier newQV = self.getLastSeenQuorumVerifier();
Long designatedLeader = getDesignatedLeader(newLeaderProposal, zk.getZxid());
self.processReconfig(newQV, designatedLeader, zk.getZxid(), true);
if (designatedLeader != self.getId()) {
allowedToCommit = false; // The root cause
}
zk.startup();
}