-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOrchestratorNode.py
More file actions
43 lines (35 loc) · 1.15 KB
/
OrchestratorNode.py
File metadata and controls
43 lines (35 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from kafka import KafkaConsumer, KafkaProducer
import json
import time
class OrchestratorNode:
def __init__(self):
self.producer = KafkaProducer()
def sendTestConfig(self, testID, testType, testDelay):
data = {
"testID": testID, #! <RANDOMLY GENERATED UNQUE TEST ID>,
"testType": testType,
"testDelay": testDelay,
}
self.producer.send(topic='test_config', value=json.dumps(data).encode())
self.producer.flush()
print("Test configuration set")
def triggerTest(self, testID):
data = {
"testID": testID,
"trigger": "YES"
}
self.producer.send(topic='trigger', value=json.dumps(data).encode())
self.producer.flush()
print("Trigger request sent")
orchestrator = OrchestratorNode()
testID = 'fnfn3221'
testType = 'Avalanche'
# testType = 'Tsunami'
if testType == 'Avalanche':
testDelay = 0
else:
testDelay = int(input("Enter delay (in ms): "))
orchestrator.sendTestConfig(testID,testType, testDelay)
orchestrator.triggerTest(testID)
orchestrator.producer.flush()
orchestrator.producer.close()