/// <exception cref="System.IO.IOException"/> private DelegationKey GetKeyFromZK(int keyId) { string nodePath = GetNodePath(ZkDtsmMasterKeyRoot, DelegationKeyPrefix + keyId); try { byte[] data = zkClient.GetData().ForPath(nodePath); if ((data == null) || (data.Length == 0)) { return(null); } ByteArrayInputStream bin = new ByteArrayInputStream(data); DataInputStream din = new DataInputStream(bin); DelegationKey key = new DelegationKey(); key.ReadFields(din); return(key); } catch (KeeperException.NoNodeException) { Log.Error("No node in path [" + nodePath + "]"); } catch (Exception ex) { throw new IOException(ex); } return(null); }
/// <summary>Read data on a path</summary> /// <param name="path">path of operation</param> /// <returns>the data</returns> /// <exception cref="System.IO.IOException">read failure</exception> public virtual byte[] ZkRead(string path) { CheckServiceLive(); string fullpath = CreateFullPath(path); try { if (Log.IsDebugEnabled()) { Log.Debug("Reading {}", fullpath); } return(curator.GetData().ForPath(fullpath)); } catch (Exception e) { throw OperationFailure(fullpath, "read()", e); } }