Skip to content

Commit

Permalink
Merge branch 'main' into fix-1110
Browse files Browse the repository at this point in the history
  • Loading branch information
MingweiSamuel authored Dec 7, 2024
2 parents 3a83e97 + 33eed2f commit b82d000
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Two Phase Commit
This is a remedial 2PC implementation.
This is a remedial 2PC implementation.

Design limitations:
- No database logging (just log statements via println)
Expand All @@ -8,22 +8,22 @@ Design limitations:
- Subordinates make random decisions whether to commit or abort

### To Run the code:
Look in the file `members.json` to find the addresses of the coordinator and subordinates.
Look in the file `members.json` to find the addresses of the coordinator and subordinates.
For the coordinator, launch a process on the node with a matching IP address as follows.
Here we assume the coordinator's IP address is `localhost` and port `12346` is free:
```
cargo run --example two_pc -- --path hydroflow/examples/two_pc/members.json --role coordinator --addr localhost:12346
cargo run --example two_pc_hf -- --path hydroflow/examples/two_pc_hf/members.json --role coordinator --addr localhost:12346
```

Now for each subordinate, launch a process on the node with the matching IP address as follows.
Here we assume the subordinate's IP address is `127.0.0.1` and port `12349` is free:
```
cargo run --example two_pc -- --path hydroflow/examples/two_pc/members.json --role subordinate --addr localhost:12349
cargo run --example two_pc_hf -- --path hydroflow/examples/two_pc_hf/members.json --role subordinate --addr localhost:12349
```

Now, in the coordinator process you can type an integer at `stdin`. Each integer you type is considered a transaction ID,
Now, in the coordinator process you can type an integer at `stdin`. Each integer you type is considered a transaction ID,
and a two-phase commit process is run for that transaction. Votes to commit or abort are randomized.

You should see logging information on screen at both the coordinator and the subordinates.

Adding the `--graph <graph_type>` flag to the end of the command lines above will print out a node-and-edge diagram of the program. Supported values for `<graph_type>` include [mermaid](https://mermaid-js.github.io/) and [dot](https://graphviz.org/doc/info/lang.html).
Adding the `--graph <graph_type>` flag to the end of the command lines above will print out a node-and-edge diagram of the program. Supported values for `<graph_type>` include [mermaid](https://mermaid-js.github.io/) and [dot](https://graphviz.org/doc/info/lang.html).
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,31 @@ fn test() {

use hydroflow::util::{run_cargo_example, wait_for_process_output};

const TEST_NAME: &str = "two_pc_hf";

let members_path = format!(
"{}/examples/two_pc/members.json",
env!("CARGO_MANIFEST_DIR")
"{}/examples/{}/members.json",
env!("CARGO_MANIFEST_DIR"),
TEST_NAME,
);

let (_coordinator, mut coordinator_stdin, mut coordinator_stdout) = run_cargo_example(
"two_pc",
TEST_NAME,
&format!("--path {members_path} --role coordinator --addr 127.0.0.1:12346"),
);

let (_subordinate1, _, mut subordinate1_stdout) = run_cargo_example(
"two_pc",
TEST_NAME,
&format!("--path {members_path} --role subordinate --addr 127.0.0.1:12347"),
);

let (_subordinate2, _, mut subordinate2_stdout) = run_cargo_example(
"two_pc",
TEST_NAME,
&format!("--path {members_path} --role subordinate --addr 127.0.0.1:12348"),
);

let (_subordinate3, _, mut subordinate3_stdout) = run_cargo_example(
"two_pc",
TEST_NAME,
&format!("--path {members_path} --role subordinate --addr 127.0.0.1:12349"),
);

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions template/hydroflow_plus/cargo-generate.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
[template]
include = [
".cargo",
".vscode",
"examples",
"src",
".gitignore",
"build.rs",
"Cargo.toml",
"README.md",
"rust-toolchain.toml"
]
ignore = [
"Cargo.lock",
]

0 comments on commit b82d000

Please sign in to comment.