Skip to content

Commit

Permalink
HBASE-19114 Split out o.a.h.h.zookeeper from hbase-server and hbase-c…
Browse files Browse the repository at this point in the history
…lient

- Moved DrainingServerTracker and RegionServerTracker to hbase-server:o.a.h.h.master.
- Moved SplitOrMergeTracker to oahh.master (because it depends on a PB)
- Moving hbase-client:oahh.zookeeper.*  to hbase-zookeeper module.  After HBASE-19200, hbase-client doesn't need them anymore (except 3 classes).
- Renamed some classes to use a consistent naming for classes - ZK instead of mix of ZK, Zk , ZooKeeper. Couldn't rename following public classes: MiniZooKeeperCluster, ZooKeeperConnectionException. Left RecoverableZooKeeper for lack of better name. (suggestions?)
- Sadly, can't move tests out because they depend on HBaseTestingUtility (which defeats part of the purpose - trimming down hbase-server tests. We need to promote more use of mocks in our tests)
  • Loading branch information
apeksharma committed Nov 17, 2017
1 parent ca74ec7 commit 330b0d0
Show file tree
Hide file tree
Showing 168 changed files with 1,226 additions and 832 deletions.
14 changes: 7 additions & 7 deletions bin/hbase
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# * See the License for the specific language governing permissions and
# * limitations under the License.
# */
#
#
# The hbase command script. Based on the hadoop command script putting
# in hbase classes, libs and configurations ahead of hadoop's.
#
Expand Down Expand Up @@ -91,10 +91,10 @@ if [ $# = 0 ]; then
echo " hfile Store file analyzer"
echo " zkcli Run the ZooKeeper shell"
echo " master Run an HBase HMaster node"
echo " regionserver Run an HBase HRegionServer node"
echo " regionserver Run an HBase HRegionServer node"
echo " zookeeper Run a ZooKeeper server"
echo " rest Run an HBase REST server"
echo " thrift Run the HBase Thrift server"
echo " rest Run an HBase REST server"
echo " thrift Run the HBase Thrift server"
echo " thrift2 Run the HBase Thrift2 server"
echo " clean Run the HBase clean up script"
echo " classpath Dump hbase CLASSPATH"
Expand Down Expand Up @@ -274,7 +274,7 @@ fi
if $cygwin; then
JAVA_LIBRARY_PATH=`cygpath -p "$JAVA_LIBRARY_PATH"`
fi

# restore ordinary behaviour
unset IFS

Expand Down Expand Up @@ -362,7 +362,7 @@ elif [ "$COMMAND" = "wal" ] ; then
elif [ "$COMMAND" = "hfile" ] ; then
CLASS='org.apache.hadoop.hbase.io.hfile.HFilePrettyPrinter'
elif [ "$COMMAND" = "zkcli" ] ; then
CLASS="org.apache.hadoop.hbase.zookeeper.ZooKeeperMainServer"
CLASS="org.apache.hadoop.hbase.zookeeper.ZKMainServer"
elif [ "$COMMAND" = "backup" ] ; then
CLASS='org.apache.hadoop.hbase.backup.BackupDriver'
elif [ "$COMMAND" = "restore" ] ; then
Expand Down Expand Up @@ -422,7 +422,7 @@ elif [ "$COMMAND" = "zookeeper" ] ; then
fi
elif [ "$COMMAND" = "clean" ] ; then
case $1 in
--cleanZk|--cleanHdfs|--cleanAll)
--cleanZk|--cleanHdfs|--cleanAll)
matches="yes" ;;
*) ;;
esac
Expand Down
10 changes: 5 additions & 5 deletions bin/hbase.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
@rem * See the License for the specific language governing permissions and
@rem * limitations under the License.
@rem */
@rem
@rem
@rem The hbase command script. Based on the hadoop command script putting
@rem in hbase classes, libs and configurations ahead of hadoop's.
@rem
Expand Down Expand Up @@ -197,16 +197,16 @@ if exist "%HBASE_HOME%\build\native" (
rem This loop would set %hbase-command-arguments%
set _hbasearguments=
:MakeCmdArgsLoop
if [%1]==[] goto :EndLoop
if [%1]==[] goto :EndLoop

if not defined _hbasearguments (
set _hbasearguments=%1
) else (
set _hbasearguments=!_hbasearguments! %1
)
shift
goto :MakeCmdArgsLoop
:EndLoop
goto :MakeCmdArgsLoop
:EndLoop

set hbase-command-arguments=%_hbasearguments%

Expand Down Expand Up @@ -424,7 +424,7 @@ goto :eof
goto :eof

:zkcli
set CLASS=org.apache.hadoop.hbase.zookeeper.ZooKeeperMainServer
set CLASS=org.apache.hadoop.hbase.zookeeper.ZKMainServer
goto :eof

:mapredcp
Expand Down
2 changes: 1 addition & 1 deletion conf/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ log4j.logger.org.apache.hadoop.hbase=INFO
log4j.logger.org.apache.hadoop.hbase.META=INFO
# Make these two classes INFO-level. Make them DEBUG to see more zk debug.
log4j.logger.org.apache.hadoop.hbase.zookeeper.ZKUtil=INFO
log4j.logger.org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher=INFO
log4j.logger.org.apache.hadoop.hbase.zookeeper.ZKWatcher=INFO
#log4j.logger.org.apache.hadoop.dfs=DEBUG
# Set this class to log INFO only otherwise its OTT
# Enable this to get detailed connection error/retry logging.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ log4j.logger.org.apache.zookeeper=INFO
log4j.logger.org.apache.hadoop.hbase=INFO
# Make these two classes INFO-level. Make them DEBUG to see more zk debug.
log4j.logger.org.apache.hadoop.hbase.zookeeper.ZKUtil=INFO
log4j.logger.org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher=INFO
log4j.logger.org.apache.hadoop.hbase.zookeeper.ZKWatcher=INFO
#log4j.logger.org.apache.hadoop.dfs=DEBUG
# Set this class to log INFO only otherwise its OTT
# Enable this to get detailed connection error/retry logging.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ log4j.logger.org.apache.zookeeper=INFO
log4j.logger.org.apache.hadoop.hbase=INFO
# Make these two classes INFO-level. Make them DEBUG to see more zk debug.
log4j.logger.org.apache.hadoop.hbase.zookeeper.ZKUtil=INFO
log4j.logger.org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher=INFO
log4j.logger.org.apache.hadoop.hbase.zookeeper.ZKWatcher=INFO
#log4j.logger.org.apache.hadoop.dfs=DEBUG
# Set this class to log INFO only otherwise its OTT
# Enable this to get detailed connection error/retry logging.
Expand Down
4 changes: 4 additions & 0 deletions hbase-assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-examples</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-zookeeper</artifactId>
</dependency>
</dependencies>
<profiles>
<profile>
Expand Down
1 change: 1 addition & 0 deletions hbase-assembly/src/main/assembly/hadoop-two-compat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<include>org.apache.hbase:hbase-spark-it</include>
<include>org.apache.hbase:hbase-testing-util</include>
<include>org.apache.hbase:hbase-thrift</include>
<include>org.apache.hbase:hbase-zookeeper</include>
</includes>
<!-- Binaries for the dependencies also go in the hbase-jars directory -->
<binaries>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.apache.hadoop.hbase.regionserver.StorefileRefresherChore;
import org.apache.hadoop.hbase.testclassification.IntegrationTests;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -37,7 +37,7 @@
/**
* An integration test that starts the cluster with three replicas for the meta
* It then creates a table, flushes the meta, kills the server holding the primary.
* After that a client issues put/get requests on the created table - the other
* After that a client issues put/get requests on the created table - the other
* replicas of the meta would be used to get the location of the region of the created
* table.
*/
Expand All @@ -60,7 +60,7 @@ public static void setUp() throws Exception {
StorefileRefresherChore.REGIONSERVER_STOREFILE_REFRESH_PERIOD, 1000);
// Make sure there are three servers.
util.initializeCluster(3);
ZooKeeperWatcher zkw = util.getZooKeeperWatcher();
ZKWatcher zkw = util.getZooKeeperWatcher();
Configuration conf = util.getConfiguration();
String baseZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.hadoop.util.ToolRunner;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.Code;
Expand Down Expand Up @@ -139,7 +139,7 @@ protected int doWork() throws Exception {

private void testZNodeACLs() throws IOException, KeeperException, InterruptedException {

ZooKeeperWatcher watcher = new ZooKeeperWatcher(conf, "IntegrationTestZnodeACLs", null);
ZKWatcher watcher = new ZKWatcher(conf, "IntegrationTestZnodeACLs", null);
RecoverableZooKeeper zk = ZKUtil.connect(this.conf, watcher);

String baseZNode = watcher.znodePaths.baseZNode;
Expand All @@ -155,7 +155,7 @@ private void testZNodeACLs() throws IOException, KeeperException, InterruptedExc
LOG.info("Checking ZK permissions: SUCCESS");
}

private void checkZnodePermsRecursive(ZooKeeperWatcher watcher,
private void checkZnodePermsRecursive(ZKWatcher watcher,
RecoverableZooKeeper zk, String znode) throws KeeperException, InterruptedException {

boolean expectedWorldReadable = watcher.isClientReadable(znode);
Expand Down Expand Up @@ -201,7 +201,7 @@ private void assertZnodePerms(RecoverableZooKeeper zk, String znode,
assertTrue(expectedWorldReadable);
// assert that anyone can only read
assertEquals(perms, Perms.READ);
} else if (superUsers != null && ZooKeeperWatcher.isSuperUserId(superUsers, id)) {
} else if (superUsers != null && ZKWatcher.isSuperUserId(superUsers, id)) {
// assert that super user has all the permissions
assertEquals(perms, Perms.ALL);
} else if (new Id("sasl", masterPrincipal).equals(id)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
Expand All @@ -64,7 +65,6 @@
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.MapReduceCell;
import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.hadoop.io.RawComparator;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
Expand Down Expand Up @@ -406,10 +406,10 @@ public void setup(Context context) {
LOG.info("setting WAL durability to default.");
}
// TODO: This is kind of ugly doing setup of ZKW just to read the clusterid.
ZooKeeperWatcher zkw = null;
ZKWatcher zkw = null;
Exception ex = null;
try {
zkw = new ZooKeeperWatcher(conf, context.getTaskAttemptID().toString(), null);
zkw = new ZKWatcher(conf, context.getTaskAttemptID().toString(), null);
clusterIds = Collections.singletonList(ZKClusterId.getUUIDForCluster(zkw));
} catch (ZooKeeperConnectionException e) {
ex = e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.util.Threads;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.MRJobConfig;
Expand Down Expand Up @@ -330,10 +330,10 @@ protected void cleanup(Context context) {

private static Pair<ReplicationPeerConfig, Configuration> getPeerQuorumConfig(
final Configuration conf, String peerId) throws IOException {
ZooKeeperWatcher localZKW = null;
ZKWatcher localZKW = null;
ReplicationPeerZKImpl peer = null;
try {
localZKW = new ZooKeeperWatcher(conf, "VerifyReplication",
localZKW = new ZKWatcher(conf, "VerifyReplication",
new Abortable() {
@Override public void abort(String why, Throwable e) {}
@Override public boolean isAborted() {return false;}
Expand Down
4 changes: 4 additions & 0 deletions hbase-replication/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-zookeeper</artifactId>
</dependency>
<!-- General dependencies -->
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.Stoppable;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;

/**
* A factory class for instantiating replication objects that deal with replication state.
Expand All @@ -48,17 +48,17 @@ public static ReplicationQueuesClient getReplicationQueuesClient(
return (ReplicationQueuesClient) ConstructorUtils.invokeConstructor(classToBuild, args);
}

public static ReplicationPeers getReplicationPeers(final ZooKeeperWatcher zk, Configuration conf,
Abortable abortable) {
public static ReplicationPeers getReplicationPeers(final ZKWatcher zk, Configuration conf,
Abortable abortable) {
return getReplicationPeers(zk, conf, null, abortable);
}

public static ReplicationPeers getReplicationPeers(final ZooKeeperWatcher zk, Configuration conf,
final ReplicationQueuesClient queuesClient, Abortable abortable) {
public static ReplicationPeers getReplicationPeers(final ZKWatcher zk, Configuration conf,
final ReplicationQueuesClient queuesClient, Abortable abortable) {
return new ReplicationPeersZKImpl(zk, conf, queuesClient, abortable);
}

public static ReplicationTracker getReplicationTracker(ZooKeeperWatcher zookeeper,
public static ReplicationTracker getReplicationTracker(ZKWatcher zookeeper,
final ReplicationPeers replicationPeers, Configuration conf, Abortable abortable,
Stoppable stopper) {
return new ReplicationTrackerZKImpl(zookeeper, replicationPeers, conf, abortable, stopper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ReplicationProtos;
import org.apache.hadoop.hbase.zookeeper.ZKNodeTracker;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperNodeTracker;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.NodeExistsException;
Expand All @@ -62,7 +62,7 @@ public class ReplicationPeerZKImpl extends ReplicationStateZKBase
* @param id string representation of this peer's identifier
* @param peerConfig configuration for the replication peer
*/
public ReplicationPeerZKImpl(ZooKeeperWatcher zkWatcher, Configuration conf,
public ReplicationPeerZKImpl(ZKWatcher zkWatcher, Configuration conf,
String id, ReplicationPeerConfig peerConfig,
Abortable abortable)
throws ReplicationException {
Expand Down Expand Up @@ -258,9 +258,9 @@ private boolean ensurePeerEnabled(final String path)
/**
* Tracker for state of this peer
*/
public class PeerStateTracker extends ZooKeeperNodeTracker {
public class PeerStateTracker extends ZKNodeTracker {

public PeerStateTracker(String peerStateZNode, ZooKeeperWatcher watcher,
public PeerStateTracker(String peerStateZNode, ZKWatcher watcher,
Abortable abortable) {
super(watcher, peerStateZNode, abortable);
}
Expand All @@ -281,11 +281,11 @@ public synchronized void nodeDataChanged(String path) {
/**
* Tracker for PeerConfigNode of this peer
*/
public class PeerConfigTracker extends ZooKeeperNodeTracker {
public class PeerConfigTracker extends ZKNodeTracker {

ReplicationPeerConfigListener listener;

public PeerConfigTracker(String peerConfigNode, ZooKeeperWatcher watcher,
public PeerConfigTracker(String peerConfigNode, ZKWatcher watcher,
Abortable abortable) {
super(watcher, peerConfigNode, abortable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
import org.apache.hadoop.hbase.zookeeper.ZKConfig;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
import org.apache.hadoop.hbase.zookeeper.ZKUtil.ZKUtilOp;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.hadoop.hbase.zookeeper.ZNodePaths;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.zookeeper.KeeperException;

Expand Down Expand Up @@ -84,8 +84,8 @@ public class ReplicationPeersZKImpl extends ReplicationStateZKBase implements Re

private static final Log LOG = LogFactory.getLog(ReplicationPeersZKImpl.class);

public ReplicationPeersZKImpl(final ZooKeeperWatcher zk, final Configuration conf,
final ReplicationQueuesClient queuesClient, Abortable abortable) {
public ReplicationPeersZKImpl(final ZKWatcher zk, final Configuration conf,
final ReplicationQueuesClient queuesClient, Abortable abortable) {
super(zk, conf, abortable);
this.abortable = abortable;
this.peerClusters = new ConcurrentHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Abortable;
import org.apache.hadoop.hbase.zookeeper.ZKWatcher;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;

/**
* Wrapper around common arguments used to construct ReplicationQueues. Used to construct various
Expand All @@ -30,7 +30,7 @@
@InterfaceAudience.Private
public class ReplicationQueuesArguments {

private ZooKeeperWatcher zk;
private ZKWatcher zk;
private Configuration conf;
private Abortable abort;

Expand All @@ -39,16 +39,16 @@ public ReplicationQueuesArguments(Configuration conf, Abortable abort) {
this.abort = abort;
}

public ReplicationQueuesArguments(Configuration conf, Abortable abort, ZooKeeperWatcher zk) {
public ReplicationQueuesArguments(Configuration conf, Abortable abort, ZKWatcher zk) {
this(conf, abort);
setZk(zk);
}

public ZooKeeperWatcher getZk() {
public ZKWatcher getZk() {
return zk;
}

public void setZk(ZooKeeperWatcher zk) {
public void setZk(ZKWatcher zk) {
this.zk = zk;
}

Expand Down
Loading

0 comments on commit 330b0d0

Please sign in to comment.