-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
534 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
127.0.0.1 7000 | ||
2 | ||
configs/shard_0.txt | ||
configs/shard_1.txt |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
127.0.0.1 8100 0 | ||
127.0.0.1 8101 1 | ||
127.0.0.1 8102 2 | ||
127.0.0.1 8103 3 | ||
127.0.0.1 8104 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
127.0.0.1 8200 0 | ||
127.0.0.1 8201 1 | ||
127.0.0.1 8202 2 | ||
127.0.0.1 8203 3 | ||
127.0.0.1 8204 4 | ||
127.0.0.1 8205 5 | ||
127.0.0.1 8206 6 | ||
127.0.0.1 8207 7 | ||
127.0.0.1 8208 8 | ||
127.0.0.1 8209 9 | ||
127.0.0.1 8210 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
127.0.0.1 8300 0 | ||
127.0.0.1 8301 1 | ||
127.0.0.1 8302 2 | ||
127.0.0.1 8303 3 | ||
127.0.0.1 8304 4 | ||
127.0.0.1 8305 5 | ||
127.0.0.1 8306 6 | ||
127.0.0.1 8307 7 | ||
127.0.0.1 8308 8 | ||
127.0.0.1 8309 9 | ||
127.0.0.1 8310 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
127.0.0.1 8400 0 | ||
127.0.0.1 8401 1 | ||
127.0.0.1 8402 2 | ||
127.0.0.1 8403 3 | ||
127.0.0.1 8404 4 | ||
127.0.0.1 8405 5 | ||
127.0.0.1 8406 6 | ||
127.0.0.1 8407 7 | ||
127.0.0.1 8408 8 | ||
127.0.0.1 8409 9 | ||
127.0.0.1 8410 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
#ifndef master_h | ||
#define master_h | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "message.h" | ||
#include "network.h" | ||
#include "shard.h" | ||
|
||
class Master { | ||
private: | ||
int port_; | ||
std::string host_; | ||
std::vector<Shard*> shards_; | ||
|
||
int tolerated_failures_; | ||
|
||
/* The master uses this to communicate | ||
with the clients */ | ||
network net_; | ||
|
||
public: | ||
/* Init and shit */ | ||
Master(int port, std::string host, std::string master_config_file); | ||
|
||
/* Generic network code */ | ||
void recv(); | ||
void handle_msg(Message* message); | ||
|
||
int get_shard_id(Message* message); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
#ifndef shard_h | ||
#define shard_h | ||
|
||
#include <condition_variable> | ||
#include <fstream> | ||
#include <mutex> | ||
#include <queue> | ||
#include <string> | ||
#include <thread> | ||
#include <vector> | ||
|
||
#include "message.h" | ||
#include "network.h" | ||
|
||
class Shard { | ||
private: | ||
/* The port and host that this shard manager will use | ||
to communicate with the shard */ | ||
int port_; | ||
std::string host_; | ||
/* The config file which describes the key/value/paxos replicas | ||
in the shard */ | ||
std::string config_filename_; | ||
std::vector<node> replicas_; | ||
/* Only incremented on failure, so we can promote a new | ||
leader in the shard */ | ||
int cur_view_num_ = 0; | ||
/* Should be incremented on every request to this shard */ | ||
int client_seq_num_ = 0; | ||
/* Used to handle and sync communication with the shard */ | ||
network net_; | ||
std::queue<Message*> msg_queue_; | ||
std::mutex m; | ||
std::condition_variable cv; | ||
public: | ||
Shard(int port, std::string host, std::string config_filename); | ||
void run(); | ||
/* These functions assume that this shard has the key that you want */ | ||
void register_msg(Message* message); | ||
Message* handle_get(std::string key, node sender); | ||
Message* handle_put(std::string key, std::string value, node sender); | ||
Message* handle_delete(std::string key, node sender); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/python3 | ||
|
||
f = input('How many failures to tolerate per shard? ') | ||
n = input('How many shards? ') | ||
p = input('Starting port (try 8000)? ') | ||
|
||
startup = '' | ||
master_config_data = '127.0.0.1 7000\n%s\n' % f | ||
for i in range(0, int(n)): | ||
shard_port = int(p) + 100 * i | ||
shard_config = 'configs/shard_%d.txt' % i | ||
master_config_data += shard_config + '\n' | ||
shard_data = '' | ||
t = 2 * int(f) + 1 | ||
for k in range(0, t): | ||
start_str = "./bin/paxos_server --port %d --host 127.0.0.1 --config %s --id %d &\n" % (shard_port + k, shard_config, k) | ||
startup += start_str | ||
shard_data += "127.0.0.1 %d %d\n" % (shard_port + k, k) | ||
f_ = open(shard_config, 'w') | ||
f_.write(shard_data) | ||
|
||
f_ = open('scripts/all_start.sh', 'w') | ||
f_.write(startup) | ||
f_ = open('configs/master_config.txt', 'w') | ||
f_.write(master_config_data) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
./bin/paxos_server --port 8000 --host 127.0.0.1 --config configs/shard_0.txt --id 0 & | ||
./bin/paxos_server --port 8001 --host 127.0.0.1 --config configs/shard_0.txt --id 1 & | ||
./bin/paxos_server --port 8002 --host 127.0.0.1 --config configs/shard_0.txt --id 2 & | ||
./bin/paxos_server --port 8003 --host 127.0.0.1 --config configs/shard_0.txt --id 3 & | ||
./bin/paxos_server --port 8004 --host 127.0.0.1 --config configs/shard_0.txt --id 4 & | ||
./bin/paxos_server --port 8100 --host 127.0.0.1 --config configs/shard_1.txt --id 0 & | ||
./bin/paxos_server --port 8101 --host 127.0.0.1 --config configs/shard_1.txt --id 1 & | ||
./bin/paxos_server --port 8102 --host 127.0.0.1 --config configs/shard_1.txt --id 2 & | ||
./bin/paxos_server --port 8103 --host 127.0.0.1 --config configs/shard_1.txt --id 3 & | ||
./bin/paxos_server --port 8104 --host 127.0.0.1 --config configs/shard_1.txt --id 4 & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
ps aux | grep paxos_server | ||
ps aux | grep chat_client_ | ||
ps aux | grep kv_client_ | ||
ps aux | grep kv_master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
echo -e "\nStarting up the master..." | ||
./bin/kv_master \ | ||
--port 7000 \ | ||
--host 127.0.0.1 \ | ||
--config configs/master_config.txt & | ||
sleep 1 | ||
echo -e "\nMaster is up on port 7000... " | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
|
||
# Start up 2f+1 replicas, where f=1 | ||
REPLICAS=(0 1 2) | ||
BASE_PORT=8000 | ||
echo -e "\nStart up shard 0 key/value/paxos replicas ..." | ||
|
||
for i in {0..2..1}; do | ||
./bin/paxos_server \ | ||
--port "$((BASE_PORT + i))" \ | ||
--host 127.0.0.1 \ | ||
--config configs/shard_0.txt \ | ||
--id "$i" \ | ||
--holes configs/no_holes.txt & | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
|
||
# Start up 2f+1 replicas, where f=1 | ||
REPLICAS=(0 1 2) | ||
BASE_PORT=8000 | ||
echo -e "\nStart up shard 0 key/value/paxos replicas ..." | ||
|
||
for i in {0..2..1}; do | ||
./bin/paxos_server \ | ||
--port "$((BASE_PORT + i))" \ | ||
--host 127.0.0.1 \ | ||
--config configs/shard_0.txt \ | ||
--id "$i" \ | ||
--holes configs/no_holes.txt & | ||
done | ||
|
||
BASE_PORT=9000 | ||
echo -e "\nStart up shard 1 key/value/paxos replicas ..." | ||
|
||
for i in {0..2..1}; do | ||
./bin/paxos_server \ | ||
--port "$((BASE_PORT + i))" \ | ||
--host 127.0.0.1 \ | ||
--config configs/shard_1.txt \ | ||
--id "$i" \ | ||
--holes configs/no_holes.txt & | ||
done | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.