public void updateKeyInZK(AuthenticationKey key) {
    String keyZNode = getKeyNode(key.getKeyId());
    try {
      byte[] keyData = Writables.getBytes(key);
      try {
        ZKUtil.updateExistingNodeData(watcher, keyZNode, keyData, -1);
      } catch (KeeperException.NoNodeException ne) {
        // node was somehow removed, try adding it back
        ZKUtil.createSetData(watcher, keyZNode, keyData);
      }
    } catch (KeeperException ke) {
      LOG.error(HBaseMarkers.FATAL,
        "Unable to update master key " + key.getKeyId() + " in znode " + keyZNode);
      watcher.abort("Unable to synchronize secret key " + key.getKeyId() + " in zookeeper", ke);
    } catch (IOException ioe) {
      // this can only happen from an error serializing the key
      watcher.abort("Failed serializing key " + key.getKeyId(), ioe);
    }
  }
Synchronizes token encryption keys across cluster nodes.
hbase-server/src/main/java/org/apache/hadoop/hbase/security/token/ZKSecretWatcher.java