public void doTransition(Message message, NotificationContext context) {
HelixManager manager = context.getManager();
ZkHelixPropertyStore<ZNRecord> store = manager.getHelixPropertyStore();
final String setPath = "/TEST_PERF/set";
final String updatePath = "/TEST_PERF/update";
final PartitionId key = message.getPartitionId();
try {
// get/set once
ZNRecord record = null;
try {
record = store.get(setPath, null, 0);
} catch (ZkNoNodeException e) {
record = new ZNRecord(setPath);
}
record.setSimpleField("setTimestamp", "" + System.currentTimeMillis());
store.set(setPath, record, AccessOption.PERSISTENT);
// update once
store.update(updatePath, new DataUpdater<ZNRecord>() {
@Override
public ZNRecord update(ZNRecord currentData) {
if (currentData == null) {
currentData = new ZNRecord(updatePath);
}
currentData.setSimpleField(key.stringify(), "" + System.currentTimeMillis());
return currentData;
}
}, AccessOption.PERSISTENT);