HBASE-1575 HMaster does not handle ZK session expiration

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@791901 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Daniel Cryans 2009-07-07 16:33:41 +00:00
parent 085f87eebb
commit 9cf697f4df
3 changed files with 36 additions and 11 deletions

View File

@ -442,6 +442,7 @@ Release 0.20.0 - Unreleased
like new LruBlockCache (Jon Gray via Stack) like new LruBlockCache (Jon Gray via Stack)
HBASE-1218 Implement in-memory column (Jon Gray via Stack) HBASE-1218 Implement in-memory column (Jon Gray via Stack)
HBASE-1606 Remove zoo.cfg, put config options into hbase-site.xml HBASE-1606 Remove zoo.cfg, put config options into hbase-site.xml
HBASE-1575 HMaster does not handle ZK session expiration
OPTIMIZATIONS OPTIMIZATIONS
HBASE-1412 Change values for delete column and column family in KeyValue HBASE-1412 Change values for delete column and column family in KeyValue

View File

@ -90,6 +90,8 @@ import org.apache.hadoop.net.DNS;
import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.StringUtils;
import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher; import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;
import org.apache.zookeeper.Watcher.Event.KeeperState;
/** /**
* HMaster is the "master server" for a HBase. * HMaster is the "master server" for a HBase.
@ -227,7 +229,6 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
this.maxRegionOpenTime = this.maxRegionOpenTime =
conf.getLong("hbase.hbasemaster.maxregionopen", 120 * 1000); conf.getLong("hbase.hbasemaster.maxregionopen", 120 * 1000);
this.leaseTimeout = conf.getInt("hbase.master.lease.period", 120 * 1000); this.leaseTimeout = conf.getInt("hbase.master.lease.period", 120 * 1000);
this.server = HBaseRPC.getServer(this, address.getBindAddress(), this.server = HBaseRPC.getServer(this, address.getBindAddress(),
address.getPort(), conf.getInt("hbase.regionserver.handler.count", 10), address.getPort(), conf.getInt("hbase.regionserver.handler.count", 10),
false, conf); false, conf);
@ -265,6 +266,8 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
return; return;
} else if(zooKeeperWrapper.writeMasterAddress(address)) { } else if(zooKeeperWrapper.writeMasterAddress(address)) {
zooKeeperWrapper.setClusterState(true); zooKeeperWrapper.setClusterState(true);
// Watch our own node
zooKeeperWrapper.readMasterAddress(this);
return; return;
} }
} }
@ -1091,6 +1094,24 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
return zooKeeperWrapper; return zooKeeperWrapper;
} }
/**
* @see org.apache.zookeeper.Watcher#process(org.apache.zookeeper.WatchedEvent)
*/
@Override
public void process(WatchedEvent event) {
LOG.debug(("Got event " + event.getType() +
" with path " + event.getPath()));
// Master should kill itself if its session expired or if its
// znode was deleted manually (usually for testing purposes)
if(event.getState() == KeeperState.Expired ||
(event.getType().equals(EventType.NodeDeleted) &&
event.getPath().equals(
this.zooKeeperWrapper.getMasterElectionZNode()))) {
LOG.error("Master lost its znode, killing itself now");
System.exit(1);
}
}
/* /*
* Main program * Main program
*/ */
@ -1171,11 +1192,4 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
doMain(args, HMaster.class); doMain(args, HMaster.class);
} }
/**
* @see org.apache.zookeeper.Watcher#process(org.apache.zookeeper.WatchedEvent)
*/
@Override
public void process(WatchedEvent event) {
// TODO: Write me to handle session expired events.
}
} }

View File

@ -620,4 +620,14 @@ public class ZooKeeperWrapper implements HConstants {
private String joinPath(String parent, String child) { private String joinPath(String parent, String child) {
return parent + ZNODE_PATH_SEPARATOR + child; return parent + ZNODE_PATH_SEPARATOR + child;
} }
/**
* Get the path of the masterElectionZNode
* @return the path to masterElectionZNode
*/
public String getMasterElectionZNode() {
return masterElectionZNode;
}
} }