HBASE-4257 Limit the number of regions in transitions displayed on master webpage.
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1164690 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7994ce3ea9
commit
8efece3ba5
|
@ -434,6 +434,8 @@ Release 0.91.0 - Unreleased
|
|||
HBASE-4275 RS should communicate fatal "aborts" back to the master (todd)
|
||||
HBASE-4263 New config property for user-table only RegionObservers
|
||||
(Lars Hofhansl)
|
||||
HBASE-4257 Limit the number of regions in transitions displayed on
|
||||
master webpage. (todd)
|
||||
|
||||
TASKS
|
||||
HBASE-3559 Move report of split to master OFF the heartbeat channel
|
||||
|
|
|
@ -18,15 +18,40 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
</%doc>
|
||||
<%import>
|
||||
org.apache.hadoop.hbase.HRegionInfo;
|
||||
org.apache.hadoop.hbase.master.AssignmentManager;
|
||||
org.apache.hadoop.hbase.master.AssignmentManager.RegionState;
|
||||
java.util.Iterator;
|
||||
java.util.Map;
|
||||
</%import>
|
||||
<%args>
|
||||
AssignmentManager assignmentManager;
|
||||
int limit = 100;
|
||||
</%args>
|
||||
<%java>
|
||||
Map<String, RegionState> rit = assignmentManager.getRegionsInTransition();
|
||||
|
||||
int toRemove = rit.size() - limit;
|
||||
int removed = 0;
|
||||
if (toRemove > 0) {
|
||||
// getRegionsInTransition returned a copy, so we can mutate it
|
||||
for (Iterator<Map.Entry<String, RegionState>> it = rit.entrySet().iterator();
|
||||
it.hasNext() && toRemove > 0;
|
||||
) {
|
||||
Map.Entry<String, RegionState> e = it.next();
|
||||
if (HRegionInfo.FIRST_META_REGIONINFO.getEncodedName().equals(
|
||||
e.getKey()) ||
|
||||
HRegionInfo.ROOT_REGIONINFO.getEncodedName().equals(
|
||||
e.getKey())) {
|
||||
// don't remove the meta regions, they're too interesting!
|
||||
continue;
|
||||
}
|
||||
it.remove();
|
||||
toRemove--;
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
|
||||
</%java>
|
||||
|
||||
<h2>Regions in Transition</h2>
|
||||
|
@ -39,4 +64,7 @@ No regions in transition.
|
|||
<tr><td><% entry.getKey() %></td><td><% entry.getValue().toDescriptiveString() %></td>
|
||||
</%for>
|
||||
</table>
|
||||
<%if removed > 0 %>
|
||||
(<% removed %> more regions in transition not shown)
|
||||
</%if>
|
||||
</%if>
|
|
@ -19,10 +19,14 @@
|
|||
*/
|
||||
package org.apache.hadoop.hbase.master;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.List;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.*;
|
||||
|
@ -33,6 +37,7 @@ import org.apache.hadoop.hbase.master.ServerManager;
|
|||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
||||
import org.apache.hbase.tmpl.master.AssignmentManagerStatusTmpl;
|
||||
import org.apache.hbase.tmpl.master.MasterStatusTmpl;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -57,17 +62,8 @@ public class TestMasterStatusServlet {
|
|||
static final HRegionInfo FAKE_HRI =
|
||||
new HRegionInfo(FAKE_TABLE.getName(), Bytes.toBytes("a"), Bytes.toBytes("b"));
|
||||
|
||||
// static final HRegionInfo FAKE_REGION = null;
|
||||
|
||||
@Before
|
||||
public void setupBasicMocks() {
|
||||
try {
|
||||
HRegion.createHRegion(FAKE_HRI, HBaseTestingUtility.getTestDir(),
|
||||
HBaseConfiguration.create(), FAKE_TABLE);
|
||||
} catch(IOException ioe) {
|
||||
|
||||
}
|
||||
|
||||
conf = HBaseConfiguration.create();
|
||||
|
||||
master = Mockito.mock(HMaster.class);
|
||||
|
@ -146,5 +142,43 @@ public class TestMasterStatusServlet {
|
|||
.render(new StringWriter(),
|
||||
master, admin);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAssignmentManagerTruncatedList() throws IOException {
|
||||
AssignmentManager am = Mockito.mock(AssignmentManager.class);
|
||||
|
||||
// Add 100 regions as in-transition
|
||||
NavigableMap<String, RegionState> regionsInTransition =
|
||||
Maps.newTreeMap();
|
||||
for (byte i = 0; i < 100; i++) {
|
||||
HRegionInfo hri = new HRegionInfo(FAKE_TABLE.getName(),
|
||||
new byte[]{i}, new byte[]{(byte) (i+1)});
|
||||
regionsInTransition.put(hri.getEncodedName(),
|
||||
new RegionState(hri, RegionState.State.CLOSING, 12345L, FAKE_HOST));
|
||||
}
|
||||
// Add META in transition as well
|
||||
regionsInTransition.put(
|
||||
HRegionInfo.FIRST_META_REGIONINFO.getEncodedName(),
|
||||
new RegionState(HRegionInfo.FIRST_META_REGIONINFO,
|
||||
RegionState.State.CLOSING, 12345L, FAKE_HOST));
|
||||
Mockito.doReturn(regionsInTransition).when(am).getRegionsInTransition();
|
||||
|
||||
// Render to a string
|
||||
StringWriter sw = new StringWriter();
|
||||
new AssignmentManagerStatusTmpl()
|
||||
.setLimit(50)
|
||||
.render(sw, am);
|
||||
String result = sw.toString();
|
||||
|
||||
// Should always include META
|
||||
assertTrue(result.contains(HRegionInfo.FIRST_META_REGIONINFO.getEncodedName()));
|
||||
|
||||
// Make sure we only see 50 of them
|
||||
Matcher matcher = Pattern.compile("CLOSING").matcher(result);
|
||||
int count = 0;
|
||||
while (matcher.find()) {
|
||||
count++;
|
||||
}
|
||||
assertEquals(50, count);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue