@Override public void updateMasterKey(int keySeq, String s) { CuratorFramework zk = getSession(); String keyPath = rootNode + NODE_KEYS + "/" + String.format(ZK_SEQ_FORMAT, keySeq); try { zk.setData().forPath(keyPath, s.getBytes()); } catch (Exception e) { throw new TokenStoreException("Error setting data in " + keyPath, e); } }
private byte[] zkGetData(String nodePath) { CuratorFramework zk = getSession(); try { return zk.getData().forPath(nodePath); } catch (KeeperException.NoNodeException ex) { return null; } catch (Exception e) { throw new TokenStoreException("Error reading " + nodePath, e); } }
private byte[] zkGetData(String nodePath) { CuratorFramework zk = getSession(); try { return zk.getData().forPath(nodePath); } catch (KeeperException.NoNodeException ex) { return null; } catch (Exception e) { throw new TokenStoreException("Error reading " + nodePath, e); } }
private List<String> zkGetChildren(String path) { CuratorFramework zk = getSession(); try { return zk.getChildren().forPath(path); } catch (Exception e) { throw new TokenStoreException("Error getting children for " + path, e); } }
@Override public void updateMasterKey(int keySeq, String s) { CuratorFramework zk = getSession(); String keyPath = rootNode + NODE_KEYS + "/" + String.format(ZK_SEQ_FORMAT, keySeq); try { zk.setData().forPath(keyPath, s.getBytes()); } catch (Exception e) { throw new TokenStoreException("Error setting data in " + keyPath, e); } }
private byte[] zkGetData(String nodePath) { CuratorFramework zk = getSession(); try { return zk.getData().forPath(nodePath); } catch (KeeperException.NoNodeException ex) { return null; } catch (Exception e) { throw new TokenStoreException("Error reading " + nodePath, e); } }
@Override public boolean removeToken(DelegationTokenIdentifier tokenIdentifier) throws TokenStoreException{ try { return (Boolean)invokeOnRawStore("removeToken", new Object[] { TokenStoreDelegationTokenSecretManager.encodeWritable(tokenIdentifier)}, String.class); } catch (IOException e) { throw new TokenStoreException(e); } }
@Override public DelegationTokenInformation getToken(DelegationTokenIdentifier tokenIdentifier) { byte[] tokenBytes = zkGetData(getTokenPath(tokenIdentifier)); try { return HiveDelegationTokenSupport.decodeDelegationTokenInformation(tokenBytes); } catch (Exception ex) { throw new TokenStoreException("Failed to decode token", ex); } }
@Override public void updateMasterKey(int keySeq, String s) { CuratorFramework zk = getSession(); String keyPath = rootNode + NODE_KEYS + "/" + String.format(ZK_SEQ_FORMAT, keySeq); try { zk.setData().forPath(keyPath, s.getBytes()); } catch (Exception e) { throw new TokenStoreException("Error setting data in " + keyPath, e); } }
private String getTokenPath(DelegationTokenIdentifier tokenIdentifier) { try { return rootNode + NODE_TOKENS + "/" + TokenStoreDelegationTokenSecretManager.encodeWritable(tokenIdentifier); } catch (IOException ex) { throw new TokenStoreException("Failed to encode token identifier", ex); } }
@Override public DelegationTokenInformation getToken(DelegationTokenIdentifier tokenIdentifier) { byte[] tokenBytes = zkGetData(getTokenPath(tokenIdentifier)); try { return HiveDelegationTokenSupport.decodeDelegationTokenInformation(tokenBytes); } catch (Exception ex) { throw new TokenStoreException("Failed to decode token", ex); } }
private String getTokenPath(DelegationTokenIdentifier tokenIdentifier) { try { return rootNode + NODE_TOKENS + "/" + TokenStoreDelegationTokenSecretManager.encodeWritable(tokenIdentifier); } catch (IOException ex) { throw new TokenStoreException("Failed to encode token identifier", ex); } }
private List<String> zkGetChildren(String path) { CuratorFramework zk = getSession(); try { return zk.getChildren().forPath(path); } catch (Exception e) { throw new TokenStoreException("Error getting children for " + path, e); } }
@Override public void updateMasterKey(int keySeq, String s) { try { ZooKeeper zk = getSession(); zk.setData(rootNode + NODE_KEYS + "/" + String.format(ZK_SEQ_FORMAT, keySeq), s.getBytes(), -1); } catch (KeeperException ex) { throw new TokenStoreException(ex); } catch (InterruptedException ex) { throw new TokenStoreException(ex); } }
private void zkDelete(String path) { CuratorFramework zk = getSession(); try { zk.delete().forPath(path); } catch (KeeperException.NoNodeException ex) { // already deleted } catch (Exception e) { throw new TokenStoreException("Error deleting " + path, e); } }
@Override public DelegationTokenInformation getToken(DelegationTokenIdentifier tokenIdentifier) throws TokenStoreException { try { String tokenStr = (String)invokeOnRawStore("getToken", new Object[] { TokenStoreDelegationTokenSecretManager.encodeWritable(tokenIdentifier)}, String.class); return (null == tokenStr) ? null : HiveDelegationTokenSupport.decodeDelegationTokenInformation(Base64.decodeBase64(tokenStr)); } catch (IOException e) { throw new TokenStoreException(e); } }
private void zkDelete(String path) { CuratorFramework zk = getSession(); try { zk.delete().forPath(path); } catch (KeeperException.NoNodeException ex) { // already deleted } catch (Exception e) { throw new TokenStoreException("Error deleting " + path, e); } }
@Override public boolean removeToken(DelegationTokenIdentifier tokenIdentifier) throws TokenStoreException{ try { return (Boolean)invokeOnRawStore("removeToken", new Object[] { TokenStoreDelegationTokenSecretManager.encodeWritable(tokenIdentifier)}, String.class); } catch (IOException e) { throw new TokenStoreException(e); } }
@Override public DelegationTokenInformation getToken(DelegationTokenIdentifier tokenIdentifier) throws TokenStoreException { try { String tokenStr = (String)invokeOnRawStore("getToken", new Object[] { TokenStoreDelegationTokenSecretManager.encodeWritable(tokenIdentifier)}, String.class); return (null == tokenStr) ? null : HiveDelegationTokenSupport.decodeDelegationTokenInformation(Base64.decodeBase64(tokenStr)); } catch (IOException e) { throw new TokenStoreException(e); } }
private void zkDelete(String path) { CuratorFramework zk = getSession(); try { zk.delete().forPath(path); } catch (KeeperException.NoNodeException ex) { // already deleted } catch (Exception e) { throw new TokenStoreException("Error deleting " + path, e); } }