SDN Controller Programming Guide
72
KeyValueNode node = null;
try {
node = haService.createNode(appName, "Key",
new byte[]{'d', 'a', 't', 'a'});
} catch (Exception e) {
...
}
try {
node.setValue(
new byte[] {'n', 'e', 'w', 'd', 'a', 't', 'a'}, true);
} catch (Exception e) {
...
}
try {
node.delete(true);
} catch (Exception e) {
...
}
}
private void keyQueryOperations() {
KeyValueNode node = null;
try {
node == haService.getNode(appName, "Key");
} catch (KeyNotFoundException e) {
...
} catch (Exception e) {
…
}
List<String> keyList = null;
try {
keyList = haService.getKeys(appName);
} catch (Exception e) {
...
}
}
}
Distributed Locking
Protecting the access to shared resources becomes increasingly important in the distributed
environment. Distributed Locking component of HA service helps in achieving serialized access to
shared resource.