-
Notifications
You must be signed in to change notification settings - Fork 1
Recipe: Niovakv Leader Election
Ensure that the writes happening before killing the leader , the writes should be reflected after electing a new leader as well.
- Pmdb Server Count: Start servers such that quorum is formed. (Number of servers /2 + 1)
- Niovakv Server Count : 1 or more servers need to be started.
- Niovakv Client-Count: 1 or more clients need to be started.
export CGO_LDFLAGS="-L/usr/local/niova/niova-core/lib/"
export CGO_CFLAGS="-I/usr/local/niova/niova-core/include/niova"
export LD_LIBRARY_PATH=/usr/local/niova/niova-core/lib/
export PATH=$PATH:/usr/local/go/bin
export PYTHONPATH= <holon-directory-path>
export NIOVA_BIN_PATH= /home/user-name/dir-name/niova-core/libexec/niova
Here to start niovakv client we need to pass various parameters for write operation
Operation : "write"
Key : <key-prefix>
Value : <value-prefix>
OutfileName : <abc>
NumRequest : <how many request to process / by default it is 5 no of request>
MultiKey : <since we here are passing single key and value this value will be False>
Sequential : <since we here are passing single key and value this value will be False>
Here’s some output from the write operation json file:
{
"write": [
{
"Request": {
"Operation": "write",
"Key": "Country0",
"Value": "India0",
"Request_timestamp": "2021-09-22T07:23:12.087609427Z"
},
"Response": {
"Status": 0,
"Response": "",
"Validate": true,
"Response_timestamp": "2021-09-22T07:23:12.121613006Z"
},
"Req_resolved_time": 34003603
}
]
}
- Add checks for Status for write operation it should be 0.
"Response": {
"Status": 0,
"Response": "",
"Validate": true,
"Response_timestamp": "2021-09-22T07:23:12.121613006Z"
},
"Req_resolved_time": 34003603
}
Here to get the leader uuid we need to pass various parameters to the niovakv_client
Operation : "leader"
Key : ""
Value : ""
OutfileName : <abc>
NumRequest : 0
MultiKey : <since we here are passing single key and value this value will be False>
Sequential : <since we here are passing single key and value this value will be False>
Here’s some output from the leader operation json file:
{
"Leader-UUID": "ead05b74-1b75-11ec-a153-43e6ab21c54a
}
Kill the current leader-uuid and verify that a new leader election should happen and a new uuid elected as leader-uuid.
Here to get the leader uuid we need to pass various parameters to the niovakv_client
Operation : "leader"
Key : ""
Value : ""
OutfileName : <abc>
NumRequest : 0
MultiKey : <since we here are passing single key and value this value will be False>
Sequential : <since we here are passing single key and value this value will be False>
Here’s output from the leader operation json file:
{
"Leader-UUID": "eacf937e-1b75-11ec-b88d-c36a6fdc1fb1"
}
- Add checks to verify new leader is elected
<"OldLeaderUUID"> != <"NewLeaderUUID">
Here to start niovakv client we need to pass various parameters for read operation.
Operation : "read"
Key : <key-prefix same as what is mentioned in write key-prefix>
Value : ""
OutfileName : <abc>
NumRequest : <how many request to process / by default it is 5 no of request>
MultiKey : <since we here are passing single key and value this value will be False>
Sequential : <since we here are passing single key and value this value will be False>
Here’s some output from the write operation json file:
{
"read": [
{
"Request": {
"Operation": "read",
"Key": "Country0",
"Value": "",
"Request_timestamp": "2021-09-22T07:23:15.038529797Z"
},
"Response": {
"Status": 0,
"Response": "India0",
"Validate": false,
"Response_timestamp": "2021-09-22T07:23:15.041801536Z"
},
"Req_resolved_time": 3271736
}
]
}
- Added some checks to verify read value and write value are same
- Status of read should be equal to zero
- Read of Response should be equal to write of Value