HBASE-1596 Remove WatcherWrapper and have all users of Zookeeper provide a Watcher
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@790970 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a6c48ab299
commit
80b5452a0d
|
@ -431,6 +431,8 @@ Release 0.20.0 - Unreleased
|
|||
HBASE-1385 Revamp TableInputFormat, needs updating to match hadoop 0.20.x
|
||||
AND remove bit where we can make < maps than regions
|
||||
(Lars George via Stack)
|
||||
HBASE-1596 Remove WatcherWrapper and have all users of Zookeeper provide a
|
||||
Watcher
|
||||
|
||||
OPTIMIZATIONS
|
||||
HBASE-1412 Change values for delete column and column family in KeyValue
|
||||
|
|
|
@ -88,6 +88,8 @@ import org.apache.hadoop.io.Writable;
|
|||
import org.apache.hadoop.ipc.RemoteException;
|
||||
import org.apache.hadoop.net.DNS;
|
||||
import org.apache.hadoop.util.StringUtils;
|
||||
import org.apache.zookeeper.WatchedEvent;
|
||||
import org.apache.zookeeper.Watcher;
|
||||
|
||||
/**
|
||||
* HMaster is the "master server" for a HBase.
|
||||
|
@ -98,7 +100,7 @@ import org.apache.hadoop.util.StringUtils;
|
|||
* sleep time which is invariant.
|
||||
*/
|
||||
public class HMaster extends Thread implements HConstants, HMasterInterface,
|
||||
HMasterRegionInterface {
|
||||
HMasterRegionInterface, Watcher {
|
||||
|
||||
static final Log LOG = LogFactory.getLog(HMaster.class.getName());
|
||||
|
||||
|
@ -242,7 +244,7 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
|||
|
||||
this.sleeper = new Sleeper(this.threadWakeFrequency, this.closed);
|
||||
|
||||
zooKeeperWrapper = new ZooKeeperWrapper(conf);
|
||||
zooKeeperWrapper = new ZooKeeperWrapper(conf, this);
|
||||
zkMasterAddressWatcher = new ZKMasterAddressWatcher(this);
|
||||
serverManager = new ServerManager(this);
|
||||
regionManager = new RegionManager(this);
|
||||
|
@ -1168,4 +1170,12 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
|||
public static void main(String [] args) {
|
||||
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.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -314,7 +314,7 @@ public class HRegionServer implements HConstants, HRegionInterface,
|
|||
}
|
||||
|
||||
private void reinitializeZooKeeper() throws IOException {
|
||||
zooKeeperWrapper = new ZooKeeperWrapper(conf);
|
||||
zooKeeperWrapper = new ZooKeeperWrapper(conf, this);
|
||||
watchMasterAddress();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/**
|
||||
* Copyright 2009 The Apache Software Foundation
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.zookeeper;
|
||||
|
||||
import org.apache.zookeeper.WatchedEvent;
|
||||
import org.apache.zookeeper.Watcher;
|
||||
|
||||
/**
|
||||
* Place-holder Watcher.
|
||||
* Does nothing currently.
|
||||
*/
|
||||
public class WatcherWrapper implements Watcher {
|
||||
private final Watcher otherWatcher;
|
||||
|
||||
/**
|
||||
* Construct with a Watcher to pass events to.
|
||||
* @param otherWatcher Watcher to pass events to.
|
||||
*/
|
||||
public WatcherWrapper(Watcher otherWatcher) {
|
||||
this.otherWatcher = otherWatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event WatchedEvent from ZooKeeper.
|
||||
*/
|
||||
public void process(WatchedEvent event) {
|
||||
if (otherWatcher != null) {
|
||||
otherWatcher.process(event);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -62,7 +62,6 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
}
|
||||
|
||||
private final ZooKeeper zooKeeper;
|
||||
private final WatcherWrapper watcher;
|
||||
|
||||
private final String parentZNode;
|
||||
public final String rootRegionZNode;
|
||||
|
@ -71,15 +70,6 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
public final String masterElectionZNode;
|
||||
public final String clusterStateZNode;
|
||||
|
||||
/**
|
||||
* Create a ZooKeeperWrapper.
|
||||
* @param conf HBaseConfiguration to read settings from.
|
||||
* @throws IOException If a connection error occurs.
|
||||
*/
|
||||
public ZooKeeperWrapper(HBaseConfiguration conf) throws IOException {
|
||||
this(conf, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a ZooKeeperWrapper.
|
||||
* @param conf HBaseConfiguration to read settings from.
|
||||
|
@ -94,9 +84,8 @@ public class ZooKeeperWrapper implements HConstants {
|
|||
}
|
||||
|
||||
int sessionTimeout = conf.getInt("zookeeper.session.timeout", 10 * 1000);
|
||||
this.watcher = new WatcherWrapper(watcher);
|
||||
try {
|
||||
zooKeeper = new ZooKeeper(quorumServers, sessionTimeout, this.watcher);
|
||||
zooKeeper = new ZooKeeper(quorumServers, sessionTimeout, watcher);
|
||||
} catch (IOException e) {
|
||||
LOG.error("Failed to create ZooKeeper object: " + e);
|
||||
throw new IOException(e);
|
||||
|
|
|
@ -54,7 +54,7 @@ public class TestZooKeeper extends HBaseClusterTestCase {
|
|||
* @throws IOException
|
||||
*/
|
||||
public void testWritesRootRegionLocation() throws IOException {
|
||||
ZooKeeperWrapper zooKeeper = new ZooKeeperWrapper(conf);
|
||||
ZooKeeperWrapper zooKeeper = new ZooKeeperWrapper(conf, new EmptyWatcher());
|
||||
|
||||
boolean outOfSafeMode = zooKeeper.checkOutOfSafeMode();
|
||||
assertFalse(outOfSafeMode);
|
||||
|
@ -83,7 +83,7 @@ public class TestZooKeeper extends HBaseClusterTestCase {
|
|||
*/
|
||||
public void testParentExists() throws IOException {
|
||||
conf.set("zookeeper.znode.safemode", "/a/b/c/d/e");
|
||||
ZooKeeperWrapper zooKeeper = new ZooKeeperWrapper(conf);
|
||||
ZooKeeperWrapper zooKeeper = new ZooKeeperWrapper(conf, new EmptyWatcher());
|
||||
assertTrue(zooKeeper.writeOutOfSafeMode());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue