org.apache.hadoop.hbase
Class ZNodeClearer

java.lang.Object
  extended by org.apache.hadoop.hbase.ZNodeClearer

public class ZNodeClearer
extends Object

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.


Field Summary
static org.apache.commons.logging.Log LOG
           
 
Method Summary
static boolean clear(org.apache.hadoop.conf.Configuration conf)
          Delete the master znode if its content (ServerName string) is the same as the one in the znode file.
static void deleteMyEphemeralNodeOnDisk()
          delete the znode file
static String getMyEphemeralNodeFileName()
          Get the name of the file used to store the znode contents
static String readMyEphemeralNodeOnDisk()
          read the content of znode file, expects a single line.
static void writeMyEphemeralNodeOnDisk(String fileContent)
          Logs the errors without failing on exception.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG
Method Detail

writeMyEphemeralNodeOnDisk

public static void writeMyEphemeralNodeOnDisk(String fileContent)
Logs the errors without failing on exception.


readMyEphemeralNodeOnDisk

public static String readMyEphemeralNodeOnDisk()
                                        throws IOException
read the content of znode file, expects a single line.

Throws:
IOException

getMyEphemeralNodeFileName

public static String getMyEphemeralNodeFileName()
Get the name of the file used to store the znode contents


deleteMyEphemeralNodeOnDisk

public static void deleteMyEphemeralNodeOnDisk()
delete the znode file


clear

public static boolean clear(org.apache.hadoop.conf.Configuration conf)
Delete the master znode if its content (ServerName string) is the same as the one in the znode file. (env: HBASE_ZNODE_FILE).

Returns:
true on successful deletion, false otherwise.


Copyright © 2007–2015 The Apache Software Foundation. All rights reserved.