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-4275 RS should communicate fatal "aborts" back to the master (todd)
|
||||||
HBASE-4263 New config property for user-table only RegionObservers
|
HBASE-4263 New config property for user-table only RegionObservers
|
||||||
(Lars Hofhansl)
|
(Lars Hofhansl)
|
||||||
|
HBASE-4257 Limit the number of regions in transitions displayed on
|
||||||
|
master webpage. (todd)
|
||||||
|
|
||||||
TASKS
|
TASKS
|
||||||
HBASE-3559 Move report of split to master OFF the heartbeat channel
|
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.
|
limitations under the License.
|
||||||
</%doc>
|
</%doc>
|
||||||
<%import>
|
<%import>
|
||||||
|
org.apache.hadoop.hbase.HRegionInfo;
|
||||||
org.apache.hadoop.hbase.master.AssignmentManager;
|
org.apache.hadoop.hbase.master.AssignmentManager;
|
||||||
org.apache.hadoop.hbase.master.AssignmentManager.RegionState;
|
org.apache.hadoop.hbase.master.AssignmentManager.RegionState;
|
||||||
|
java.util.Iterator;
|
||||||
java.util.Map;
|
java.util.Map;
|
||||||
</%import>
|
</%import>
|
||||||
<%args>
|
<%args>
|
||||||
AssignmentManager assignmentManager;
|
AssignmentManager assignmentManager;
|
||||||
|
int limit = 100;
|
||||||
</%args>
|
</%args>
|
||||||
<%java>
|
<%java>
|
||||||
Map<String, RegionState> rit = assignmentManager.getRegionsInTransition();
|
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>
|
</%java>
|
||||||
|
|
||||||
<h2>Regions in Transition</h2>
|
<h2>Regions in Transition</h2>
|
||||||
@ -39,4 +64,7 @@ No regions in transition.
|
|||||||
<tr><td><% entry.getKey() %></td><td><% entry.getValue().toDescriptiveString() %></td>
|
<tr><td><% entry.getKey() %></td><td><% entry.getValue().toDescriptiveString() %></td>
|
||||||
</%for>
|
</%for>
|
||||||
</table>
|
</table>
|
||||||
|
<%if removed > 0 %>
|
||||||
|
(<% removed %> more regions in transition not shown)
|
||||||
|
</%if>
|
||||||
</%if>
|
</%if>
|
@ -19,10 +19,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.master;
|
package org.apache.hadoop.hbase.master;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NavigableMap;
|
import java.util.NavigableMap;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hbase.*;
|
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.regionserver.HRegion;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
||||||
|
import org.apache.hbase.tmpl.master.AssignmentManagerStatusTmpl;
|
||||||
import org.apache.hbase.tmpl.master.MasterStatusTmpl;
|
import org.apache.hbase.tmpl.master.MasterStatusTmpl;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -57,17 +62,8 @@ public class TestMasterStatusServlet {
|
|||||||
static final HRegionInfo FAKE_HRI =
|
static final HRegionInfo FAKE_HRI =
|
||||||
new HRegionInfo(FAKE_TABLE.getName(), Bytes.toBytes("a"), Bytes.toBytes("b"));
|
new HRegionInfo(FAKE_TABLE.getName(), Bytes.toBytes("a"), Bytes.toBytes("b"));
|
||||||
|
|
||||||
// static final HRegionInfo FAKE_REGION = null;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setupBasicMocks() {
|
public void setupBasicMocks() {
|
||||||
try {
|
|
||||||
HRegion.createHRegion(FAKE_HRI, HBaseTestingUtility.getTestDir(),
|
|
||||||
HBaseConfiguration.create(), FAKE_TABLE);
|
|
||||||
} catch(IOException ioe) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
conf = HBaseConfiguration.create();
|
conf = HBaseConfiguration.create();
|
||||||
|
|
||||||
master = Mockito.mock(HMaster.class);
|
master = Mockito.mock(HMaster.class);
|
||||||
@ -147,4 +143,42 @@ public class TestMasterStatusServlet {
|
|||||||
master, admin);
|
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…
x
Reference in New Issue
Block a user