You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by jd...@apache.org on 2012/03/22 19:12:54 UTC
svn commit: r1303943 - in /hbase/branches/0.92: CHANGES.txt
src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java
src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java
Author: jdcryans
Date: Thu Mar 22 18:12:54 2012
New Revision: 1303943
URL: http://svn.apache.org/viewvc?rev=1303943&view=rev
Log:
HBASE-5586 [replication] NPE in ReplicationSource when creating a stream
to an inexistent cluster
Added:
hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java
Modified:
hbase/branches/0.92/CHANGES.txt
hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java
Modified: hbase/branches/0.92/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1303943&r1=1303942&r2=1303943&view=diff
==============================================================================
--- hbase/branches/0.92/CHANGES.txt (original)
+++ hbase/branches/0.92/CHANGES.txt Thu Mar 22 18:12:54 2012
@@ -11,6 +11,8 @@ Release 0.92.2 - Unreleased
HBASE-5270 Handle potential data loss due to concurrent processing of
processFaileOver and ServerShutdownHandler (Chunhui)
HBASE-5560 Avoid RegionServer GC caused by timed-out calls (Dhruba)
+ HBASE-5586 [replication] NPE in ReplicationSource when creating a stream
+ to an inexistent cluster
IMPROVEMENTS
HBASE-5592 Make it easier to get a table from shell (Ben West)
Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java?rev=1303943&r1=1303942&r2=1303943&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java (original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/replication/ReplicationZookeeper.java Thu Mar 22 18:12:54 2012
@@ -215,11 +215,11 @@ public class ReplicationZookeeper {
*/
public List<ServerName> getSlavesAddresses(String peerClusterId) {
if (this.peerClusters.size() == 0) {
- return new ArrayList<ServerName>(0);
+ return Collections.emptyList();
}
ReplicationPeer peer = this.peerClusters.get(peerClusterId);
if (peer == null) {
- return new ArrayList<ServerName>(0);
+ return Collections.emptyList();
}
List<ServerName> addresses;
@@ -278,7 +278,7 @@ public class ReplicationZookeeper {
throws KeeperException {
List<String> children = ZKUtil.listChildrenNoWatch(zkw, znode);
if(children == null) {
- return null;
+ return Collections.emptyList();
}
List<ServerName> addresses = new ArrayList<ServerName>(children.size());
for (String child : children) {
Added: hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java?rev=1303943&view=auto
==============================================================================
--- hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java (added)
+++ hbase/branches/0.92/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationZookeeper.java Thu Mar 22 18:12:54 2012
@@ -0,0 +1,115 @@
+/**
+ * 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.replication;
+
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.Server;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.catalog.CatalogTracker;
+import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.zookeeper.KeeperException;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class TestReplicationZookeeper {
+
+ private static Configuration conf;
+
+ private static HBaseTestingUtility utility;
+
+ private static ZooKeeperWatcher zkw;
+
+ private static ReplicationZookeeper repZk;
+
+ private static String slaveClusterKey;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ utility = new HBaseTestingUtility();
+ utility.startMiniZKCluster();
+ conf = utility.getConfiguration();
+ zkw = HBaseTestingUtility.getZooKeeperWatcher(utility);
+ DummyServer server = new DummyServer();
+ repZk = new ReplicationZookeeper(server, new AtomicBoolean());
+ slaveClusterKey = conf.get(HConstants.ZOOKEEPER_QUORUM) + ":" +
+ conf.get("hbase.zookeeper.property.clientPort") + ":/1";
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ utility.shutdownMiniZKCluster();
+ }
+
+ @Test
+ public void testGetAddressesMissingSlave()
+ throws IOException, KeeperException {
+ repZk.addPeer("1", slaveClusterKey);
+ // HBASE-5586 used to get an NPE
+ assertEquals(0, repZk.getSlavesAddresses("1").size());
+ }
+
+ static class DummyServer implements Server {
+
+ @Override
+ public Configuration getConfiguration() {
+ return conf;
+ }
+
+ @Override
+ public ZooKeeperWatcher getZooKeeper() {
+ return zkw;
+ }
+
+ @Override
+ public CatalogTracker getCatalogTracker() {
+ return null;
+ }
+
+ @Override
+ public ServerName getServerName() {
+ return new ServerName("hostname.example.org", 1234, -1L);
+ }
+
+ @Override
+ public void abort(String why, Throwable e) {
+ }
+
+ @Override
+ public boolean isAborted() {
+ return false;
+ }
+
+ @Override
+ public void stop(String why) {
+ }
+
+ @Override
+ public boolean isStopped() {
+ return false;
+ }
+ }
+}