Skip to content

Commit 5adcdbe

Browse files
Nits2 (#54)
* added jaeger flag * added actor macro
1 parent 2edd420 commit 5adcdbe

File tree

9 files changed

+55
-13
lines changed

9 files changed

+55
-13
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ members = [
99
"macros",
1010
"examples/paxos",
1111
"examples/ping_pong",
12-
"examples/read_write_server",
12+
"examples/read_write_server", "examples/paxos",
1313
]
1414

1515
exclude = [

examples/paxos/paxos.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ port = 3000
3131
acceptors = ["a1", "a2", "a3"]
3232
# chaos.msg_loss = { start_ms = 100, probability = 0.7 }
3333
# chaos.msg_duplication = { start_ms = 0, probability = 0.7 , factor=2 }
34-
chaos.msg_delay = { start_ms = 0, delay_range_ms = [500, 1000] , senders = ["a1"] }
34+
# chaos.msg_delay = { start_ms = 0, delay_range_ms = [500, 1000] , senders = ["a1"] }
3535

3636
# [[placement.leader]]
3737
# nodename = "node1"

examples/paxos/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ mod common;
33
mod leader;
44

55
pub use reactor_actor::setup_shared_logger_ref;
6-
use reactor_actor::{ActorAddr, RuntimeCtx};
6+
use reactor_actor::{ActorAddr, RuntimeCtx, actor};
77

88
use lazy_static::lazy_static;
99
use serde_json::Value;
@@ -15,12 +15,12 @@ const SLEEP_MS: u64 = 100;
1515
lazy_static! {
1616
static ref RUNTIME: tokio::runtime::Runtime = tokio::runtime::Runtime::new().unwrap();
1717
}
18-
#[unsafe(no_mangle)]
18+
#[actor]
1919
pub fn acceptor(ctx: RuntimeCtx, _payload: HashMap<String, Value>) {
2020
RUNTIME.spawn(acceptor::acceptor(ctx));
2121
}
2222

23-
#[unsafe(no_mangle)]
23+
#[actor]
2424
pub fn leader(ctx: RuntimeCtx, mut payload: HashMap<String, Value>) {
2525
let acceptors = payload
2626
.remove("acceptors")

generic_nctrl/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ edition = "2024"
88
env_logger = "0.11.8"
99
tokio = { version = "1", features = ["full", "tracing"] }
1010
reactor-node = { path = "../node" }
11-
reactor-inst = { path = "../instrument" }
1211
clap = { version = "4", features = ["derive"] }
1312
serde_json = "1.0.140"
1413
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
14+
reactor-inst = { path = "../instrument", optional=true }
15+
log.workspace = true
1516

1617

1718
[features]
1819
default = []
1920
swagger = ["reactor-node/swagger"]
21+
jaeger = ["reactor-inst"]
2022

2123

2224

generic_nctrl/src/main.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ pub struct Cli {
1919
#[tokio::main]
2020
async fn main() {
2121
let cli = Cli::parse();
22+
23+
#[cfg(feature = "jaeger")]
2224
let _gurad = reactor_inst::init_tracing();
25+
26+
#[cfg(not(feature = "jaeger"))]
27+
{
28+
use env_logger::Builder;
29+
use log::LevelFilter;
30+
31+
Builder::new().filter_level(LevelFilter::Info).init();
32+
}
33+
2334
node_controller(cli.port, cli.dir).await;
2435
}

reactor-dashboard/ui/src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ function App() {
3535

3636
try {
3737
const res = await api.getStatus();
38-
console.log(res.data.loaded_libs);
3938

4039
const newData: NodeData = {
4140
actors: Array.isArray(res.data.actors) ? res.data.actors : [],

reactor-dashboard/ui/src/components/deploy-form.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,19 @@ function OpToNodes(nodes: Node[]): Record<string, string[]> {
146146
return opToNodes
147147
}
148148

149+
function OpToLib(nodes: Node[]): Record<string, string> {
150+
const opToLib: Record<string, string> = {}
151+
152+
for (const node of nodes) {
153+
for (const [lib, ops] of Object.entries(node.data.loaded_libs)) {
154+
for (const op of ops){
155+
opToLib[op] = lib;
156+
}
157+
}
158+
}
159+
return opToLib;
160+
}
161+
149162
export default function JobRunner({ nodes }: DialogDemoProps) {
150163
const [selectedOp, setSelectedOp] = useState<string | null>(null);
151164
const [selectedNode, setSelectedNode] = useState<string | null>(null);
@@ -157,8 +170,14 @@ export default function JobRunner({ nodes }: DialogDemoProps) {
157170
const [isJsonValid, setIsJsonValid] = useState<boolean>(true);
158171

159172
const opToNodes = OpToNodes(nodes);
173+
const opToLib = OpToLib(nodes);
160174
const allOps = Object.keys(opToNodes);
161-
const nodesForOp = selectedOp ? opToNodes[selectedOp] ?? [] : []
175+
const nodesForOp = selectedOp ? opToNodes[selectedOp] ?? [] : [];
176+
177+
let jc = new JobController(placement);
178+
for (const node of nodes){
179+
jc.registerNode(node.hostname, node.hostname, node.port);
180+
}
162181

163182
const handlePlace = () => {
164183
if (!selectedOp) {
@@ -204,16 +223,16 @@ export default function JobRunner({ nodes }: DialogDemoProps) {
204223
setPlacement(newPlacement);
205224
};
206225

207-
const handleDeploy = () =>{
208-
let jc = new JobController(placement);
209-
jc.startJob([...placement.get_actors()]);
226+
const handleDeploy = () => {
227+
jc.startJob([...placement.get_ops(opToLib)]);
228+
toast.success("Job Deployed sucessfully");
210229
};
211230

212231
return (
213232
<Sheet>
214233
<Toaster position="top-center" richColors/>
215234
<SheetTrigger asChild>
216-
<Button onClick={handleDeploy}>Deploy Job</Button>
235+
<Button>Deploy Job</Button>
217236
</SheetTrigger>
218237
<SheetContent className="w-[1000px] sm:w-[1000px]">
219238
<SheetHeader>
@@ -295,7 +314,7 @@ export default function JobRunner({ nodes }: DialogDemoProps) {
295314
<SheetFooter>
296315
<Button variant="secondary">Load</Button>
297316
<Button variant="secondary">Save changes</Button>
298-
<Button type="submit">Deploy</Button>
317+
<Button type="submit" onClick={handleDeploy}>Deploy</Button>
299318
<SheetClose asChild>
300319
<Button variant="outline">Close</Button>
301320
</SheetClose>

reactor-dashboard/ui/src/reactor-ctrl.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class ManualPlacementManager implements PlacementManager {
6161
}
6262

6363
place(opInfo: LogicalOp): PhysicalOp[] {
64+
console.log(this.map);
6465
const ops = this.map.get(opInfo.name);
6566
if (!ops) {
6667
throw new Error(`No physical ops found for logical op: ${opInfo.name}`);
@@ -93,6 +94,15 @@ export class ManualPlacementManager implements PlacementManager {
9394
return this.actors;
9495
}
9596

97+
get_ops(opToLib: Record<string, string>): Set<LogicalOp> {
98+
const ops = Object.entries(opToLib).map(([name, libName]) => ({
99+
name,
100+
libName,
101+
}));
102+
103+
return new Set(ops);
104+
}
105+
96106
}
97107

98108
export class NodeHandle {

0 commit comments

Comments
 (0)