/** * Store the rpc throttle value. * @param enable Set to <code>true</code> to enable, <code>false</code> to disable. * @throws IOException if an unexpected io exception occurs */ public void switchRpcThrottle(boolean enable) throws IOException { try { byte[] upData = Bytes.toBytes(enable); ZKUtil.createSetData(zookeeper, rpcThrottleZNode, upData); } catch (KeeperException e) { throw new IOException("Failed to store rpc throttle", e); } } }
public static void setClusterId(ZKWatcher watcher, ClusterId id) throws KeeperException { ZKUtil.createSetData(watcher, watcher.getZNodePaths().clusterIdZNode, id.toByteArray()); }
/** * Perform a best effort enable of hfile retention, which relies on zookeeper communicating the // * * change back to the hfile cleaner. * <p> * No attempt is made to make sure that backups are successfully created - it is inherently an * <b>asynchronous operation</b>. * @param zooKeeper watcher connection to zk cluster * @param table table name on which to enable archiving * @throws KeeperException */ private void enable(ZKWatcher zooKeeper, byte[] table) throws KeeperException { LOG.debug("Ensuring archiving znode exists"); ZKUtil.createAndFailSilent(zooKeeper, archiveZnode); // then add the table to the list of znodes to archive String tableNode = this.getTableNode(table); LOG.debug("Creating: " + tableNode + ", data: []"); ZKUtil.createSetData(zooKeeper, tableNode, new byte[0]); }
@Override public void setPeerNewSyncReplicationState(String peerId, SyncReplicationState state) throws ReplicationException { try { ZKUtil.createSetData(zookeeper, getNewSyncReplicationStateNode(peerId), SyncReplicationState.toByteArray(state)); } catch (KeeperException e) { throw new ReplicationException( "Unable to set the new sync replication state for peer with id=" + peerId, e); } }
public void addKeyToZK(AuthenticationKey key) { String keyZNode = getKeyNode(key.getKeyId()); try { byte[] keyData = Writables.getBytes(key); // TODO: is there any point in retrying beyond what ZK client does? ZKUtil.createSetData(watcher, keyZNode, keyData); } catch (KeeperException ke) { LOG.error(HBaseMarkers.FATAL, "Unable to synchronize master key "+key.getKeyId()+ " to znode "+keyZNode, ke); 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); } }
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); } }
private SyncReplicationState getSyncReplicationState(String peerId, String path) throws ReplicationException { try { byte[] data = ZKUtil.getData(zookeeper, path); if (data == null || data.length == 0) { if (ZKUtil.checkExists(zookeeper, getPeerNode(peerId)) != -1) { // should be a peer from previous version, set the sync replication state for it. ZKUtil.createSetData(zookeeper, path, NONE_STATE_ZNODE_BYTES); return SyncReplicationState.NONE; } else { throw new ReplicationException( "Replication peer sync state shouldn't be empty, peerId=" + peerId); } } return SyncReplicationState.parseFrom(data); } catch (KeeperException | InterruptedException | IOException e) { throw new ReplicationException( "Error getting sync replication state of path " + path + " for peer with id=" + peerId, e); } }
ZKUtil.createSetData(watcher, prepare, ProtobufUtil.prependPBMagic(data));
public static void setClusterId(ZooKeeperWatcher watcher, String id) throws KeeperException { ZKUtil.createSetData(watcher, watcher.clusterIdZNode, Bytes.toBytes(id)); } }
public void setExpiredTsToZk(long currentExpiredTs) throws Exception { ZKUtil.createSetData(zk, themisExpiredTsZNodePath, Bytes.toBytes(String.valueOf(currentExpiredTs))); LOG.info("successfully set currentExpiredTs to zk, currentExpiredTs=" + currentExpiredTs + ", zkPath=" + themisExpiredTsZNodePath); }
public static void setClusterId(ZooKeeperWatcher watcher, ClusterId id) throws KeeperException { ZKUtil.createSetData(watcher, watcher.clusterIdZNode, id.toByteArray()); }
public static void setClusterId(ZKWatcher watcher, ClusterId id) throws KeeperException { ZKUtil.createSetData(watcher, watcher.getZNodePaths().clusterIdZNode, id.toByteArray()); }
/** * Perform a best effort enable of hfile retention, which relies on zookeeper communicating the // * * change back to the hfile cleaner. * <p> * No attempt is made to make sure that backups are successfully created - it is inherently an * <b>asynchronous operation</b>. * @param zooKeeper watcher connection to zk cluster * @param table table name on which to enable archiving * @throws KeeperException */ private void enable(ZooKeeperWatcher zooKeeper, byte[] table) throws KeeperException { LOG.debug("Ensuring archiving znode exists"); ZKUtil.createAndFailSilent(zooKeeper, archiveZnode); // then add the table to the list of znodes to archive String tableNode = this.getTableNode(table); LOG.debug("Creating: " + tableNode + ", data: []"); ZKUtil.createSetData(zooKeeper, tableNode, new byte[0]); }
if (data == null) { ZKUtil .createSetData(this.watcher, nodePath, ZKUtil.positionToByteArray(lastSequenceId)); } else { lastRecordedFlushedSequenceId = ZKUtil.createSetData(this.watcher, nodePath, ZKUtil.regionSequenceIdsToByteArray(lastSequenceId, null)); if (LOG.isDebugEnabled()) {
public void addKeyToZK(AuthenticationKey key) { String keyZNode = getKeyNode(key.getKeyId()); try { byte[] keyData = Writables.getBytes(key); // TODO: is there any point in retrying beyond what ZK client does? ZKUtil.createSetData(watcher, keyZNode, keyData); } catch (KeeperException ke) { LOG.fatal("Unable to synchronize master key "+key.getKeyId()+ " to znode "+keyZNode, ke); 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); } }
ZKUtil.createSetData(watcher, prepare, ProtobufUtil.prependPBMagic(data));
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.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); } }
ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk), Bytes.toBytes(String.valueOf(Long.MIN_VALUE))); ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk), Bytes.toBytes(String.valueOf(prewriteTs + 5)));
ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk), Bytes.toBytes(String.valueOf(Long.MIN_VALUE))); admin.flush(TABLENAME); ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk), Bytes.toBytes(String.valueOf(prewriteTs + 1))); admin.flush(TABLENAME); ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk), Bytes.toBytes(String.valueOf(Long.MIN_VALUE))); ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk), Bytes.toBytes(String.valueOf(prewriteTs + 5)));
ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk), Bytes.toBytes(String.valueOf(Long.MIN_VALUE))); admin.flush(TABLENAME); ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk), Bytes.toBytes(String.valueOf(prewriteTs + 1))); admin.flush(TABLENAME); ZKUtil.createSetData(zk, ThemisMasterObserver.getThemisExpiredTsZNodePath(zk), Bytes.toBytes(String.valueOf(prewriteTs + 5))); admin.flush(TABLENAME);