org.apache.hadoop.hbase.ZNodeClearer类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.apache.hadoop.hbase.ZNodeClearer类的一些代码示例,展示了ZNodeClearer类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZNodeClearer类的具体详情如下:
包路径:org.apache.hadoop.hbase.ZNodeClearer
类名称:ZNodeClearer

ZNodeClearer介绍

[英]Contains a set of methods for the collaboration between the start/stop scripts and the servers. It allows to delete immediately the znode when the master or the regions server crashes. The region server / master writes a specific file when it starts / becomes main master. When they end properly, they delete the file.

In the script, we check for the existence of these files when the program ends. If they still exist we conclude that the server crashed, likely without deleting their znode. To have a faster recovery we delete immediately the znode.

The strategy depends on the server type. For a region server we store the znode path in the file, and use it to delete it. for a master, as the znode path constant whatever the server, we check its content to make sure that the backup server is not now in charge.
[中]包含一组用于启动/停止脚本和服务器之间协作的方法。它允许在主服务器或区域服务器崩溃时立即删除znode。区域服务器/主服务器在启动/成为主服务器时写入特定文件。当它们正确结束时,会删除该文件。
在脚本中,我们在程序结束时检查这些文件是否存在。如果它们仍然存在,我们断定服务器崩溃了,很可能没有删除它们的znode。为了更快地恢复,我们立即删除znode。
策略取决于服务器类型。对于区域服务器,我们将znode路径存储在文件中,并使用它删除它。对于主服务器,无论服务器是什么,znode路径都是常量,因此我们检查其内容以确保备份服务器现在不负责。

代码示例

代码示例来源:origin: apache/hbase

public void stop() {
  try {
   synchronized (clusterHasActiveMaster) {
    // Master is already stopped, wake up the manager
    // thread so that it can shutdown soon.
    clusterHasActiveMaster.notifyAll();
   }
   // If our address is in ZK, delete it on our way out
   ServerName activeMaster = null;
   try {
    activeMaster = MasterAddressTracker.getMasterAddress(this.watcher);
   } catch (IOException e) {
    LOG.warn("Failed get of master address: " + e.toString());
   }
   if (activeMaster != null &&  activeMaster.equals(this.sn)) {
    ZKUtil.deleteNode(watcher, watcher.getZNodePaths().masterAddressZNode);
    // We may have failed to delete the znode at the previous step, but
    //  we delete the file anyway: a second attempt to delete the znode is likely to fail again.
    ZNodeClearer.deleteMyEphemeralNodeOnDisk();
   }
  } catch (KeeperException e) {
   LOG.debug(this.watcher.prefix("Failed delete of our master address node; " +
     e.getMessage()));
  }
 }
}

代码示例来源:origin: apache/hbase

/**
 *  delete the znode file
 */
public static void deleteMyEphemeralNodeOnDisk() {
 String fileName = getMyEphemeralNodeFileName();
 if (fileName != null) {
  new File(fileName).delete();
 }
}

代码示例来源:origin: apache/hbase

znodeFileContent = ZNodeClearer.readMyEphemeralNodeOnDisk();
if (ZNodeClearer.tablesOnMaster(conf)) {
  ZNodeClearer.parseMasterServerName(znodeFileContent));
} else {
 return MasterAddressTracker.deleteIfEquals(zkw, znodeFileContent);

代码示例来源:origin: apache/hbase

ZNodeClearer.writeMyEphemeralNodeOnDisk(this.sn.toString());
 ZNodeClearer.deleteMyEphemeralNodeOnDisk();
} else {
 msg = "Another master is the active master, " + currentMaster +

代码示例来源:origin: apache/hbase

return stopMaster();
} else if ("clear".equals(command)) {
 return (ZNodeClearer.clear(getConf()) ? 0 : 1);
} else {
 usage("Invalid command: " + command);

代码示例来源:origin: apache/hbase

ZNodeClearer.writeMyEphemeralNodeOnDisk(getMyEphemeralNodePath());

代码示例来源:origin: harbby/presto-connectors

znodeFileContent = ZNodeClearer.readMyEphemeralNodeOnDisk();
 return MasterAddressTracker.deleteIfEquals(zkw, znodeFileContent);
} catch (FileNotFoundException fnfe) {

代码示例来源:origin: harbby/presto-connectors

ZNodeClearer.writeMyEphemeralNodeOnDisk(this.sn.toString());
 ZNodeClearer.deleteMyEphemeralNodeOnDisk();
} else {
 msg = "Another master is the active master, " + currentMaster +

代码示例来源:origin: harbby/presto-connectors

return stopMaster();
} else if ("clear".equals(command)) {
 return (ZNodeClearer.clear(getConf()) ? 0 : 1);
} else {
 usage("Invalid command: " + command);

代码示例来源:origin: harbby/presto-connectors

ZNodeClearer.writeMyEphemeralNodeOnDisk(getMyEphemeralNodePath());

代码示例来源:origin: apache/hbase

/**
 * read the content of znode file, expects a single line.
 */
public static String readMyEphemeralNodeOnDisk() throws IOException {
 String fileName = getMyEphemeralNodeFileName();
 if (fileName == null){
  throw new FileNotFoundException("No filename; set environment variable HBASE_ZNODE_FILE");
 }
 FileReader znodeFile = new FileReader(fileName);
 BufferedReader br = null;
 try {
  br = new BufferedReader(znodeFile);
  String file_content = br.readLine();
  return file_content;
 } finally {
  if (br != null) br.close();
 }
}

代码示例来源:origin: apache/hbase

ZNodeClearer.deleteMyEphemeralNodeOnDisk();

代码示例来源:origin: apache/hbase

String fileName = ZNodeClearer.getMyEphemeralNodeFileName();
if (fileName == null) {
 LOG.warn("Environment variable HBASE_ZNODE_FILE not set; znodes will not be cleared " +

代码示例来源:origin: harbby/presto-connectors

public void stop() {
  try {
   synchronized (clusterHasActiveMaster) {
    // Master is already stopped, wake up the manager
    // thread so that it can shutdown soon.
    clusterHasActiveMaster.notifyAll();
   }
   // If our address is in ZK, delete it on our way out
   ServerName activeMaster = null;
   try {
    activeMaster = MasterAddressTracker.getMasterAddress(this.watcher);
   } catch (IOException e) {
    LOG.warn("Failed get of master address: " + e.toString());
   }
   if (activeMaster != null &&  activeMaster.equals(this.sn)) {
    ZKUtil.deleteNode(watcher, watcher.getMasterAddressZNode());
    // We may have failed to delete the znode at the previous step, but
    //  we delete the file anyway: a second attempt to delete the znode is likely to fail again.
    ZNodeClearer.deleteMyEphemeralNodeOnDisk();
   }
  } catch (KeeperException e) {
   LOG.error(this.watcher.prefix("Error deleting our own master address node"), e);
  }
 }
}

代码示例来源:origin: harbby/presto-connectors

/**
 *  delete the znode file
 */
public static void deleteMyEphemeralNodeOnDisk() {
 String fileName = getMyEphemeralNodeFileName();
 if (fileName != null) {
  new File(fileName).delete();
 }
}

代码示例来源:origin: harbby/presto-connectors

ZNodeClearer.deleteMyEphemeralNodeOnDisk();

代码示例来源:origin: harbby/presto-connectors

/**
 * read the content of znode file, expects a single line.
 */
public static String readMyEphemeralNodeOnDisk() throws IOException {
 String fileName = getMyEphemeralNodeFileName();
 if (fileName == null){
  throw new FileNotFoundException("No filename; set environment variable HBASE_ZNODE_FILE");
 }
 FileReader znodeFile = new FileReader(fileName);
 BufferedReader br = null;
 try {
  br = new BufferedReader(znodeFile);
  String file_content = br.readLine();
  return file_content;
 } finally {
  if (br != null) br.close();
 }
}

代码示例来源:origin: harbby/presto-connectors

String fileName = ZNodeClearer.getMyEphemeralNodeFileName();
if (fileName == null) {
 LOG.warn("Environment variable HBASE_ZNODE_FILE not set; znodes will not be cleared " +

相关文章