Java Code Examples for org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper#setData()
The following examples show how to use
org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper#setData() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReplicationUtils.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
/** * Bump up timestamp if the provided timestamp value is larger than current timetamp * @param timestamp * @throws IOException * @throws KeeperException * @throws InterruptedException */ public static void setTimestamp(long timestamp) throws IOException, KeeperException, InterruptedException { TimestampSource timestampSource = SIDriver.driver().getTimestampSource(); long currentTimestamp = timestampSource.currentTimestamp(); if (currentTimestamp < timestamp) { RecoverableZooKeeper rzk = ZkUtils.getRecoverableZooKeeper(); HBaseSIEnvironment env = HBaseSIEnvironment.loadEnvironment(new SystemClock(), rzk); ConfigurationSource configurationSource = env.configuration().getConfigSource(); String rootNode = configurationSource.getString(HConfiguration.SPLICE_ROOT_PATH, HConfiguration.DEFAULT_ROOT_PATH); String node = rootNode + HConfiguration.MAX_RESERVED_TIMESTAMP_PATH; //if (LOG.isDebugEnabled()) { SpliceLogUtils.info(LOG, "bump up timestamp to %d", timestamp); //} byte[] data = Bytes.toBytes(timestamp); rzk.setData(node, data, -1 /* version */); timestampSource.refresh(); } else { //if (LOG.isDebugEnabled()) { SpliceLogUtils.info(LOG, "current timestamp = %d > %d", currentTimestamp, timestamp); //} } }
Example 2
Source File: ReplicationUtils.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
public static void disableMaster(String masterClusterKey) throws InterruptedException, KeeperException, IOException { // Delete all peers from master cluster Configuration conf = ReplicationUtils.createConfiguration(masterClusterKey); ZKWatcher masterZkw = new ZKWatcher(conf, "replication monitor", null, false); RecoverableZooKeeper masterRzk = masterZkw.getRecoverableZooKeeper(); String[] s = masterClusterKey.split(":"); String hbaseRootDir = s[2]; String peerPath = hbaseRootDir+"/replication/peers"; List<String> peers = masterRzk.getChildren(peerPath, false); for (String peer : peers) { String p = peerPath + "/" + peer; List<String> children = masterRzk.getChildren(p, false); String peerStatePath = p + "/" + children.get(0); masterRzk.setData(peerStatePath, toByteArray(ReplicationProtos.ReplicationState.State.DISABLED), -1); System.out.println("Disabled peer " + peer); } }
Example 3
Source File: OlapServerSubmitter.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
private void reportDiagnostics(String diagnostics) { try { RecoverableZooKeeper rzk = ZkUtils.getRecoverableZooKeeper(); String root = HConfiguration.getConfiguration().getSpliceRootPath(); String diagnosticsPath = root + HBaseConfiguration.OLAP_SERVER_PATH + HBaseConfiguration.OLAP_SERVER_DIAGNOSTICS_PATH + "/" + queueName; if (rzk.exists(diagnosticsPath, false) != null) { rzk.setData(diagnosticsPath, Bytes.toBytes(diagnostics), -1); } else { rzk.create(diagnosticsPath, Bytes.toBytes(diagnostics), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); } } catch (Exception e) { LOG.error("Exception while trying to report diagnostics", e); // ignore this exception during error reporting } }
Example 4
Source File: OlapServerMaster.java From spliceengine with GNU Affero General Public License v3.0 | 6 votes |
private void reportDiagnostics(String diagnostics) { try { RecoverableZooKeeper rzk = ZkUtils.getRecoverableZooKeeper(); String root = HConfiguration.getConfiguration().getSpliceRootPath(); String diagnosticsRoot = root + HBaseConfiguration.OLAP_SERVER_PATH + HBaseConfiguration.OLAP_SERVER_DIAGNOSTICS_PATH; zkSafeCreate(diagnosticsRoot); String diagnosticsPath = diagnosticsRoot + "/spark-" + queueName; if (rzk.exists(diagnosticsPath, false) != null) { rzk.setData(diagnosticsPath, com.splicemachine.primitives.Bytes.toBytes(diagnostics), -1); } else { rzk.create(diagnosticsPath, com.splicemachine.primitives.Bytes.toBytes(diagnostics), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); } } catch (Exception e) { LOG.error("Exception while trying to report diagnostics", e); // ignore this exception during error reporting } }
Example 5
Source File: ZkUtils.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
public static void setData(String path,byte[] data,int version, RecoverableZooKeeper rzk) throws IOException{ try{ rzk.setData(path,data,version); }catch(KeeperException | InterruptedException e){ throw new IOException(e); } }
Example 6
Source File: ReplicationMonitorChore.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
private void setNewMasterTimestamp(String newMasterClusterKey, long ts) throws IOException, KeeperException, InterruptedException{ Configuration conf = ReplicationUtils.createConfiguration(newMasterClusterKey); try (ZKWatcher masterZkw = new ZKWatcher(conf, "replication monitor", null, false)) { RecoverableZooKeeper rzk = masterZkw.getRecoverableZooKeeper(); String rootNode = HConfiguration.getConfiguration().getSpliceRootPath(); String node = rootNode + HConfiguration.MAX_RESERVED_TIMESTAMP_PATH; rzk.setData(node, Bytes.toBytes(ts), -1); } }