You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2013/11/12 20:18:20 UTC
svn commit: r1541201 - in /hbase/branches/0.89-fb/src:
main/java/org/apache/hadoop/hbase/master/HMaster.java
main/java/org/apache/hadoop/hbase/master/ServerManager.java
test/java/org/apache/hadoop/hbase/regionserver/TestMasterOnlineConfigChange.java
Author: liyin
Date: Tue Nov 12 19:18:20 2013
New Revision: 1541201
URL: http://svn.apache.org/r1541201
Log:
[0.89-fb] [master] Enable ServerManager to pick up config changes online for resending messages
Author: aaiyer
Summary: Enable ServerManager to pick up config changes online for resending messages
Test Plan: added a unit test
Reviewers: gauravm
Reviewed By: gauravm
CC: hbase-eng@
Differential Revision: https://phabricator.fb.com/D1046640
Added:
hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestMasterOnlineConfigChange.java
Modified:
hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1541201&r1=1541200&r2=1541201&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Tue Nov 12 19:18:20 2013
@@ -457,6 +457,7 @@ public class HMaster extends HasThread i
synchronized(this) {
serverManager = new ServerManager(this);
}
+ this.getConfigurationManager().registerObserver(serverManager);
this.regionServerOperationQueue =
new RegionServerOperationQueue(this.conf, serverManager,
@@ -2387,7 +2388,11 @@ public class HMaster extends HasThread i
public void updateConfiguration() {
LOG.info("Reloading the configuration from disk.");
conf.reloadConfiguration();
- configurationManager.notifyAllObservers(conf);
+ getConfigurationManager().notifyAllObservers(conf);
+ }
+
+ public ConfigurationManager getConfigurationManager() {
+ return configurationManager;
}
}
Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=1541201&r1=1541200&r2=1541201&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java Tue Nov 12 19:18:20 2013
@@ -30,6 +30,7 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
@@ -48,6 +49,7 @@ import org.apache.hadoop.hbase.Stoppable
import org.apache.hadoop.hbase.YouAreDeadException;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.conf.ConfigurationObserver;
import org.apache.hadoop.hbase.ipc.HRegionInterface;
import org.apache.hadoop.hbase.master.RegionManager.RegionState;
import org.apache.hadoop.hbase.util.Bytes;
@@ -62,7 +64,7 @@ import org.apache.hadoop.hbase.util.HasT
* The ServerManager class manages info about region servers - HServerInfo,
* load numbers, dying servers, etc.
*/
-public class ServerManager {
+public class ServerManager implements ConfigurationObserver {
private static final Log LOG =
LogFactory.getLog(ServerManager.class.getName());
@@ -133,7 +135,7 @@ public class ServerManager {
*/
final Object deadServerStatusLock = new Object();
- private final boolean resendDroppedMessages;
+ private final AtomicBoolean resendDroppedMessages = new AtomicBoolean();
/**
* A set of host:port pairs representing regionservers that are blacklisted
@@ -236,7 +238,7 @@ public class ServerManager {
this.blacklistUpdateInterval = c.getLong("hbase.master.blacklist.update.interval",
DEFAULT_BLACKLIST_UPDATE_WINDOW);
- this.resendDroppedMessages = c.getBoolean("hbase.master.msgs.resend-openclose", false);
+ this.resendDroppedMessages.set(c.getBoolean("hbase.master.msgs.resend-openclose", false));
}
/**
@@ -643,7 +645,7 @@ public class ServerManager {
// Tell the region server to close regions that we have marked for closing.
for (HRegionInfo i:
this.master.getRegionManager().getMarkedToClose(serverInfo.getServerName())) {
- if (resendDroppedMessages) {
+ if (resendDroppedMessages.get()) {
if (closingRegions == null || !closingRegions.contains(i.getEncodedName())) {
HMsg msg = new HMsg(HMsg.Type.MSG_REGION_CLOSE, i);
LOG.info("HMsg " + msg.toString() + " was lost earlier. Resending to " + serverInfo.getServerName());
@@ -663,7 +665,7 @@ public class ServerManager {
// Figure out what the RegionServer ought to do, and write back.
- if (resendDroppedMessages) {
+ if (resendDroppedMessages.get()) {
// 1. Remind the server to open the regions that the RS has not acked for
// Normally, the master shouldn't need to do this. But, this may be required
// if there was a network Incident, in which the master's message to OPEN a
@@ -1511,4 +1513,14 @@ public class ServerManager {
LOG.debug("Cleared all the blacklisted servers");
blacklistedRSHostPortMap.clear();
}
+
+ @Override
+ public void notifyOnChange(Configuration conf) {
+ boolean oldValue = this.resendDroppedMessages.get();
+ this.resendDroppedMessages.set(conf.getBoolean("hbase.master.msgs.resend-openclose", oldValue));
+ }
+
+ public boolean getResendDroppedMessages() {
+ return this.resendDroppedMessages.get();
+ }
}
Added: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestMasterOnlineConfigChange.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestMasterOnlineConfigChange.java?rev=1541201&view=auto
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestMasterOnlineConfigChange.java (added)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestMasterOnlineConfigChange.java Tue Nov 12 19:18:20 2013
@@ -0,0 +1,72 @@
+/**
+ * Copyright 2010 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.regionserver;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.master.HMaster;
+import org.apache.hadoop.hbase.master.ServerManager;
+
+public class TestMasterOnlineConfigChange extends
+ TestCase {
+
+ static final Log LOG =
+ LogFactory.getLog(TestMasterOnlineConfigChange.class.getName());
+ HBaseTestingUtility hbaseTestingUtility = new HBaseTestingUtility();
+ Configuration conf = null;
+ HMaster master;
+
+
+ @Override
+ public void setUp() throws Exception {
+ conf = hbaseTestingUtility.getConfiguration();
+ hbaseTestingUtility.startMiniCluster(1,1);
+ master = hbaseTestingUtility.getHBaseCluster().getActiveMaster();
+ }
+
+
+ /**
+ * Check if the server side profiling config parameter changes online
+ * @throws IOException
+ */
+ public void testServerManagerResendMessagesChange() throws IOException {
+ ServerManager serverMgr = master.getServerManager();
+ boolean origSetting =
+ serverMgr.getResendDroppedMessages();
+
+ conf.setBoolean("hbase.master.msgs.resend-openclose",
+ !origSetting);
+
+ // Confirm that without the notification call, the parameter is unchanged
+ assertEquals(origSetting,
+ serverMgr.getResendDroppedMessages());
+
+ // After the notification, it should be changed
+ master.getConfigurationManager().notifyAllObservers(conf);
+ assertEquals(!origSetting,
+ serverMgr.getResendDroppedMessages());
+ }
+}