hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [31/44] hbase-site git commit: Published site at .
Date Tue, 30 Jan 2018 15:18:39 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/a3fb6d74/devapidocs/src-html/org/apache/hadoop/hbase/master/MasterMetaBootstrap.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/MasterMetaBootstrap.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/MasterMetaBootstrap.html
index 22c90f0..2399814 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/master/MasterMetaBootstrap.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/MasterMetaBootstrap.html
@@ -32,149 +32,137 @@
 <span class="sourceLineNo">024</span><a name="line.24"></a>
 <span class="sourceLineNo">025</span>import org.apache.hadoop.hbase.HConstants;<a
name="line.25"></a>
 <span class="sourceLineNo">026</span>import org.apache.hadoop.hbase.ServerName;<a
name="line.26"></a>
-<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.TableName;<a
name="line.27"></a>
-<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.client.RegionInfo;<a
name="line.28"></a>
-<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.client.RegionInfoBuilder;<a
name="line.29"></a>
-<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.client.RegionReplicaUtil;<a
name="line.30"></a>
-<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.client.TableState;<a
name="line.31"></a>
-<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.master.assignment.AssignmentManager;<a
name="line.32"></a>
-<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.monitoring.MonitoredTask;<a
name="line.33"></a>
-<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;<a
name="line.34"></a>
-<span class="sourceLineNo">035</span>import org.apache.hadoop.hbase.zookeeper.ZKUtil;<a
name="line.35"></a>
-<span class="sourceLineNo">036</span>import org.apache.hadoop.hbase.zookeeper.ZKWatcher;<a
name="line.36"></a>
-<span class="sourceLineNo">037</span>import org.apache.yetus.audience.InterfaceAudience;<a
name="line.37"></a>
-<span class="sourceLineNo">038</span>import org.apache.zookeeper.KeeperException;<a
name="line.38"></a>
-<span class="sourceLineNo">039</span>import org.slf4j.Logger;<a name="line.39"></a>
-<span class="sourceLineNo">040</span>import org.slf4j.LoggerFactory;<a name="line.40"></a>
-<span class="sourceLineNo">041</span><a name="line.41"></a>
-<span class="sourceLineNo">042</span>/**<a name="line.42"></a>
-<span class="sourceLineNo">043</span> * Used by the HMaster on startup to split
meta logs and assign the meta table.<a name="line.43"></a>
-<span class="sourceLineNo">044</span> */<a name="line.44"></a>
-<span class="sourceLineNo">045</span>@InterfaceAudience.Private<a name="line.45"></a>
-<span class="sourceLineNo">046</span>public class MasterMetaBootstrap {<a
name="line.46"></a>
-<span class="sourceLineNo">047</span>  private static final Logger LOG = LoggerFactory.getLogger(MasterMetaBootstrap.class);<a
name="line.47"></a>
-<span class="sourceLineNo">048</span><a name="line.48"></a>
-<span class="sourceLineNo">049</span>  private final MonitoredTask status;<a
name="line.49"></a>
-<span class="sourceLineNo">050</span>  private final HMaster master;<a name="line.50"></a>
-<span class="sourceLineNo">051</span><a name="line.51"></a>
-<span class="sourceLineNo">052</span>  public MasterMetaBootstrap(final HMaster
master, final MonitoredTask status) {<a name="line.52"></a>
-<span class="sourceLineNo">053</span>    this.master = master;<a name="line.53"></a>
-<span class="sourceLineNo">054</span>    this.status = status;<a name="line.54"></a>
-<span class="sourceLineNo">055</span>  }<a name="line.55"></a>
-<span class="sourceLineNo">056</span><a name="line.56"></a>
-<span class="sourceLineNo">057</span>  public void recoverMeta() throws InterruptedException,
IOException {<a name="line.57"></a>
-<span class="sourceLineNo">058</span>    master.recoverMeta();<a name="line.58"></a>
-<span class="sourceLineNo">059</span>    master.getTableStateManager().start();<a
name="line.59"></a>
-<span class="sourceLineNo">060</span>    enableCrashedServerProcessing(false);<a
name="line.60"></a>
-<span class="sourceLineNo">061</span>  }<a name="line.61"></a>
-<span class="sourceLineNo">062</span><a name="line.62"></a>
-<span class="sourceLineNo">063</span>  public void processDeadServers() {<a
name="line.63"></a>
-<span class="sourceLineNo">064</span>    // get a list for previously failed
RS which need log splitting work<a name="line.64"></a>
-<span class="sourceLineNo">065</span>    // we recover hbase:meta region servers
inside master initialization and<a name="line.65"></a>
-<span class="sourceLineNo">066</span>    // handle other failed servers in SSH
in order to start up master node ASAP<a name="line.66"></a>
-<span class="sourceLineNo">067</span>    Set&lt;ServerName&gt; previouslyFailedServers
=<a name="line.67"></a>
-<span class="sourceLineNo">068</span>        master.getMasterWalManager().getFailedServersFromLogFolders();<a
name="line.68"></a>
-<span class="sourceLineNo">069</span><a name="line.69"></a>
-<span class="sourceLineNo">070</span>    // Master has recovered hbase:meta region
server and we put<a name="line.70"></a>
-<span class="sourceLineNo">071</span>    // other failed region servers in a
queue to be handled later by SSH<a name="line.71"></a>
-<span class="sourceLineNo">072</span>    for (ServerName tmpServer : previouslyFailedServers)
{<a name="line.72"></a>
-<span class="sourceLineNo">073</span>      master.getServerManager().processDeadServer(tmpServer,
true);<a name="line.73"></a>
-<span class="sourceLineNo">074</span>    }<a name="line.74"></a>
-<span class="sourceLineNo">075</span>  }<a name="line.75"></a>
-<span class="sourceLineNo">076</span><a name="line.76"></a>
-<span class="sourceLineNo">077</span>  public void assignMetaReplicas()<a
name="line.77"></a>
-<span class="sourceLineNo">078</span>      throws IOException, InterruptedException,
KeeperException {<a name="line.78"></a>
-<span class="sourceLineNo">079</span>    int numReplicas = master.getConfiguration().getInt(HConstants.META_REPLICAS_NUM,<a
name="line.79"></a>
-<span class="sourceLineNo">080</span>           HConstants.DEFAULT_META_REPLICA_NUM);<a
name="line.80"></a>
-<span class="sourceLineNo">081</span>    for (int i = 1; i &lt; numReplicas;
i++) {<a name="line.81"></a>
-<span class="sourceLineNo">082</span>      assignMeta(i);<a name="line.82"></a>
-<span class="sourceLineNo">083</span>    }<a name="line.83"></a>
-<span class="sourceLineNo">084</span>    unassignExcessMetaReplica(numReplicas);<a
name="line.84"></a>
-<span class="sourceLineNo">085</span>  }<a name="line.85"></a>
-<span class="sourceLineNo">086</span><a name="line.86"></a>
-<span class="sourceLineNo">087</span>  private void unassignExcessMetaReplica(int
numMetaReplicasConfigured) {<a name="line.87"></a>
-<span class="sourceLineNo">088</span>    final ZKWatcher zooKeeper = master.getZooKeeper();<a
name="line.88"></a>
-<span class="sourceLineNo">089</span>    // unassign the unneeded replicas (for
e.g., if the previous master was configured<a name="line.89"></a>
-<span class="sourceLineNo">090</span>    // with a replication of 3 and now it
is 2, we need to unassign the 1 unneeded replica)<a name="line.90"></a>
-<span class="sourceLineNo">091</span>    try {<a name="line.91"></a>
-<span class="sourceLineNo">092</span>      List&lt;String&gt; metaReplicaZnodes
= zooKeeper.getMetaReplicaNodes();<a name="line.92"></a>
-<span class="sourceLineNo">093</span>      for (String metaReplicaZnode : metaReplicaZnodes)
{<a name="line.93"></a>
-<span class="sourceLineNo">094</span>        int replicaId = zooKeeper.znodePaths.getMetaReplicaIdFromZnode(metaReplicaZnode);<a
name="line.94"></a>
-<span class="sourceLineNo">095</span>        if (replicaId &gt;= numMetaReplicasConfigured)
{<a name="line.95"></a>
-<span class="sourceLineNo">096</span>          RegionState r = MetaTableLocator.getMetaRegionState(zooKeeper,
replicaId);<a name="line.96"></a>
-<span class="sourceLineNo">097</span>          LOG.info("Closing excess replica
of meta region " + r.getRegion());<a name="line.97"></a>
-<span class="sourceLineNo">098</span>          // send a close and wait for a
max of 30 seconds<a name="line.98"></a>
-<span class="sourceLineNo">099</span>          ServerManager.closeRegionSilentlyAndWait(master.getClusterConnection(),<a
name="line.99"></a>
-<span class="sourceLineNo">100</span>              r.getServerName(), r.getRegion(),
30000);<a name="line.100"></a>
-<span class="sourceLineNo">101</span>          ZKUtil.deleteNode(zooKeeper, zooKeeper.znodePaths.getZNodeForReplica(replicaId));<a
name="line.101"></a>
-<span class="sourceLineNo">102</span>        }<a name="line.102"></a>
-<span class="sourceLineNo">103</span>      }<a name="line.103"></a>
-<span class="sourceLineNo">104</span>    } catch (Exception ex) {<a name="line.104"></a>
-<span class="sourceLineNo">105</span>      // ignore the exception since we don't
want the master to be wedged due to potential<a name="line.105"></a>
-<span class="sourceLineNo">106</span>      // issues in the cleanup of the extra
regions. We can do that cleanup via hbck or manually<a name="line.106"></a>
-<span class="sourceLineNo">107</span>      LOG.warn("Ignoring exception " + ex);<a
name="line.107"></a>
-<span class="sourceLineNo">108</span>    }<a name="line.108"></a>
-<span class="sourceLineNo">109</span>  }<a name="line.109"></a>
-<span class="sourceLineNo">110</span><a name="line.110"></a>
-<span class="sourceLineNo">111</span>  /**<a name="line.111"></a>
-<span class="sourceLineNo">112</span>   * Check &lt;code&gt;hbase:meta&lt;/code&gt;
is assigned. If not, assign it.<a name="line.112"></a>
-<span class="sourceLineNo">113</span>   */<a name="line.113"></a>
-<span class="sourceLineNo">114</span>  protected void assignMeta(int replicaId)<a
name="line.114"></a>
-<span class="sourceLineNo">115</span>      throws InterruptedException, IOException,
KeeperException {<a name="line.115"></a>
-<span class="sourceLineNo">116</span>    final AssignmentManager assignmentManager
= master.getAssignmentManager();<a name="line.116"></a>
+<span class="sourceLineNo">027</span>import org.apache.hadoop.hbase.client.RegionInfo;<a
name="line.27"></a>
+<span class="sourceLineNo">028</span>import org.apache.hadoop.hbase.client.RegionInfoBuilder;<a
name="line.28"></a>
+<span class="sourceLineNo">029</span>import org.apache.hadoop.hbase.client.RegionReplicaUtil;<a
name="line.29"></a>
+<span class="sourceLineNo">030</span>import org.apache.hadoop.hbase.master.assignment.AssignmentManager;<a
name="line.30"></a>
+<span class="sourceLineNo">031</span>import org.apache.hadoop.hbase.monitoring.MonitoredTask;<a
name="line.31"></a>
+<span class="sourceLineNo">032</span>import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;<a
name="line.32"></a>
+<span class="sourceLineNo">033</span>import org.apache.hadoop.hbase.zookeeper.ZKUtil;<a
name="line.33"></a>
+<span class="sourceLineNo">034</span>import org.apache.hadoop.hbase.zookeeper.ZKWatcher;<a
name="line.34"></a>
+<span class="sourceLineNo">035</span>import org.apache.yetus.audience.InterfaceAudience;<a
name="line.35"></a>
+<span class="sourceLineNo">036</span>import org.apache.zookeeper.KeeperException;<a
name="line.36"></a>
+<span class="sourceLineNo">037</span>import org.slf4j.Logger;<a name="line.37"></a>
+<span class="sourceLineNo">038</span>import org.slf4j.LoggerFactory;<a name="line.38"></a>
+<span class="sourceLineNo">039</span><a name="line.39"></a>
+<span class="sourceLineNo">040</span>/**<a name="line.40"></a>
+<span class="sourceLineNo">041</span> * Used by the HMaster on startup to split
meta logs and assign the meta table.<a name="line.41"></a>
+<span class="sourceLineNo">042</span> */<a name="line.42"></a>
+<span class="sourceLineNo">043</span>@InterfaceAudience.Private<a name="line.43"></a>
+<span class="sourceLineNo">044</span>public class MasterMetaBootstrap {<a
name="line.44"></a>
+<span class="sourceLineNo">045</span>  private static final Logger LOG = LoggerFactory.getLogger(MasterMetaBootstrap.class);<a
name="line.45"></a>
+<span class="sourceLineNo">046</span><a name="line.46"></a>
+<span class="sourceLineNo">047</span>  private final MonitoredTask status;<a
name="line.47"></a>
+<span class="sourceLineNo">048</span>  private final HMaster master;<a name="line.48"></a>
+<span class="sourceLineNo">049</span><a name="line.49"></a>
+<span class="sourceLineNo">050</span>  public MasterMetaBootstrap(final HMaster
master, final MonitoredTask status) {<a name="line.50"></a>
+<span class="sourceLineNo">051</span>    this.master = master;<a name="line.51"></a>
+<span class="sourceLineNo">052</span>    this.status = status;<a name="line.52"></a>
+<span class="sourceLineNo">053</span>  }<a name="line.53"></a>
+<span class="sourceLineNo">054</span><a name="line.54"></a>
+<span class="sourceLineNo">055</span>  public void recoverMeta() throws InterruptedException,
IOException {<a name="line.55"></a>
+<span class="sourceLineNo">056</span>    master.recoverMeta();<a name="line.56"></a>
+<span class="sourceLineNo">057</span>    master.getTableStateManager().start();<a
name="line.57"></a>
+<span class="sourceLineNo">058</span>    enableCrashedServerProcessing(false);<a
name="line.58"></a>
+<span class="sourceLineNo">059</span>  }<a name="line.59"></a>
+<span class="sourceLineNo">060</span><a name="line.60"></a>
+<span class="sourceLineNo">061</span>  public void processDeadServers() {<a
name="line.61"></a>
+<span class="sourceLineNo">062</span>    // get a list for previously failed
RS which need log splitting work<a name="line.62"></a>
+<span class="sourceLineNo">063</span>    // we recover hbase:meta region servers
inside master initialization and<a name="line.63"></a>
+<span class="sourceLineNo">064</span>    // handle other failed servers in SSH
in order to start up master node ASAP<a name="line.64"></a>
+<span class="sourceLineNo">065</span>    Set&lt;ServerName&gt; previouslyFailedServers
=<a name="line.65"></a>
+<span class="sourceLineNo">066</span>        master.getMasterWalManager().getFailedServersFromLogFolders();<a
name="line.66"></a>
+<span class="sourceLineNo">067</span><a name="line.67"></a>
+<span class="sourceLineNo">068</span>    // Master has recovered hbase:meta region
server and we put<a name="line.68"></a>
+<span class="sourceLineNo">069</span>    // other failed region servers in a
queue to be handled later by SSH<a name="line.69"></a>
+<span class="sourceLineNo">070</span>    for (ServerName tmpServer : previouslyFailedServers)
{<a name="line.70"></a>
+<span class="sourceLineNo">071</span>      master.getServerManager().processDeadServer(tmpServer,
true);<a name="line.71"></a>
+<span class="sourceLineNo">072</span>    }<a name="line.72"></a>
+<span class="sourceLineNo">073</span>  }<a name="line.73"></a>
+<span class="sourceLineNo">074</span><a name="line.74"></a>
+<span class="sourceLineNo">075</span>  /**<a name="line.75"></a>
+<span class="sourceLineNo">076</span>   * For assigning hbase:meta replicas only.<a
name="line.76"></a>
+<span class="sourceLineNo">077</span>   * TODO: The way this assign runs, nothing
but chance to stop all replicas showing up on same<a name="line.77"></a>
+<span class="sourceLineNo">078</span>   * server as the hbase:meta region.<a
name="line.78"></a>
+<span class="sourceLineNo">079</span>   */<a name="line.79"></a>
+<span class="sourceLineNo">080</span>  protected void assignMetaReplicas()<a
name="line.80"></a>
+<span class="sourceLineNo">081</span>      throws IOException, InterruptedException,
KeeperException {<a name="line.81"></a>
+<span class="sourceLineNo">082</span>    int numReplicas = master.getConfiguration().getInt(HConstants.META_REPLICAS_NUM,<a
name="line.82"></a>
+<span class="sourceLineNo">083</span>           HConstants.DEFAULT_META_REPLICA_NUM);<a
name="line.83"></a>
+<span class="sourceLineNo">084</span>    if (numReplicas &lt;= 1) {<a
name="line.84"></a>
+<span class="sourceLineNo">085</span>      // No replicaas to assign. Return.<a
name="line.85"></a>
+<span class="sourceLineNo">086</span>      return;<a name="line.86"></a>
+<span class="sourceLineNo">087</span>    }<a name="line.87"></a>
+<span class="sourceLineNo">088</span>    final AssignmentManager assignmentManager
= master.getAssignmentManager();<a name="line.88"></a>
+<span class="sourceLineNo">089</span>    if (!assignmentManager.isMetaInitialized())
{<a name="line.89"></a>
+<span class="sourceLineNo">090</span>      throw new IllegalStateException("hbase:meta
must be initialized first before we can " +<a name="line.90"></a>
+<span class="sourceLineNo">091</span>          "assign out its replicas");<a
name="line.91"></a>
+<span class="sourceLineNo">092</span>    }<a name="line.92"></a>
+<span class="sourceLineNo">093</span>    ServerName metaServername =<a name="line.93"></a>
+<span class="sourceLineNo">094</span>        this.master.getMetaTableLocator().getMetaRegionLocation(this.master.getZooKeeper());<a
name="line.94"></a>
+<span class="sourceLineNo">095</span>    for (int i = 1; i &lt; numReplicas;
i++) {<a name="line.95"></a>
+<span class="sourceLineNo">096</span>      // Get current meta state for replica
from zk.<a name="line.96"></a>
+<span class="sourceLineNo">097</span>      RegionState metaState = MetaTableLocator.getMetaRegionState(master.getZooKeeper(),
i);<a name="line.97"></a>
+<span class="sourceLineNo">098</span>      RegionInfo hri = RegionReplicaUtil.getRegionInfoForReplica(<a
name="line.98"></a>
+<span class="sourceLineNo">099</span>          RegionInfoBuilder.FIRST_META_REGIONINFO,
i);<a name="line.99"></a>
+<span class="sourceLineNo">100</span>      LOG.debug(hri.getRegionNameAsString()
+ " replica region state from zookeeper=" + metaState);<a name="line.100"></a>
+<span class="sourceLineNo">101</span>      if (metaServername.equals(metaState.getServerName()))
{<a name="line.101"></a>
+<span class="sourceLineNo">102</span>        metaState = null;<a name="line.102"></a>
+<span class="sourceLineNo">103</span>        LOG.info(hri.getRegionNameAsString()
+<a name="line.103"></a>
+<span class="sourceLineNo">104</span>          " old location is same as current
hbase:meta location; setting location as null...");<a name="line.104"></a>
+<span class="sourceLineNo">105</span>      }<a name="line.105"></a>
+<span class="sourceLineNo">106</span>      // These assigns run inline. All is
blocked till they complete. Only interrupt is shutting<a name="line.106"></a>
+<span class="sourceLineNo">107</span>      // down hosting server which calls
AM#stop.<a name="line.107"></a>
+<span class="sourceLineNo">108</span>      if (metaState != null &amp;&amp;
metaState.getServerName() != null) {<a name="line.108"></a>
+<span class="sourceLineNo">109</span>        // Try to retain old assignment.<a
name="line.109"></a>
+<span class="sourceLineNo">110</span>        assignmentManager.assign(hri, metaState.getServerName());<a
name="line.110"></a>
+<span class="sourceLineNo">111</span>      } else {<a name="line.111"></a>
+<span class="sourceLineNo">112</span>        assignmentManager.assign(hri);<a
name="line.112"></a>
+<span class="sourceLineNo">113</span>      }<a name="line.113"></a>
+<span class="sourceLineNo">114</span>    }<a name="line.114"></a>
+<span class="sourceLineNo">115</span>    unassignExcessMetaReplica(numReplicas);<a
name="line.115"></a>
+<span class="sourceLineNo">116</span>  }<a name="line.116"></a>
 <span class="sourceLineNo">117</span><a name="line.117"></a>
-<span class="sourceLineNo">118</span>    // Work on meta region<a name="line.118"></a>
-<span class="sourceLineNo">119</span>    // TODO: Unimplemented<a name="line.119"></a>
-<span class="sourceLineNo">120</span>    // long timeout =<a name="line.120"></a>
-<span class="sourceLineNo">121</span>    //   master.getConfiguration().getLong("hbase.catalog.verification.timeout",
1000);<a name="line.121"></a>
-<span class="sourceLineNo">122</span>    if (replicaId == RegionInfo.DEFAULT_REPLICA_ID)
{<a name="line.122"></a>
-<span class="sourceLineNo">123</span>      status.setStatus("Assigning hbase:meta
region");<a name="line.123"></a>
-<span class="sourceLineNo">124</span>    } else {<a name="line.124"></a>
-<span class="sourceLineNo">125</span>      status.setStatus("Assigning hbase:meta
region, replicaId " + replicaId);<a name="line.125"></a>
-<span class="sourceLineNo">126</span>    }<a name="line.126"></a>
-<span class="sourceLineNo">127</span><a name="line.127"></a>
-<span class="sourceLineNo">128</span>    // Get current meta state from zk.<a
name="line.128"></a>
-<span class="sourceLineNo">129</span>    RegionState metaState = MetaTableLocator.getMetaRegionState(master.getZooKeeper(),
replicaId);<a name="line.129"></a>
-<span class="sourceLineNo">130</span>    LOG.debug("meta state from zookeeper:
" + metaState);<a name="line.130"></a>
-<span class="sourceLineNo">131</span>    RegionInfo hri = RegionReplicaUtil.getRegionInfoForReplica(<a
name="line.131"></a>
-<span class="sourceLineNo">132</span>        RegionInfoBuilder.FIRST_META_REGIONINFO,
replicaId);<a name="line.132"></a>
-<span class="sourceLineNo">133</span>    assignmentManager.assignMeta(hri, metaState.getServerName());<a
name="line.133"></a>
-<span class="sourceLineNo">134</span><a name="line.134"></a>
-<span class="sourceLineNo">135</span>    if (replicaId == RegionInfo.DEFAULT_REPLICA_ID)
{<a name="line.135"></a>
-<span class="sourceLineNo">136</span>      // TODO: should we prevent from using
state manager before meta was initialized?<a name="line.136"></a>
-<span class="sourceLineNo">137</span>      // tableStateManager.start();<a
name="line.137"></a>
-<span class="sourceLineNo">138</span>      master.getTableStateManager()<a
name="line.138"></a>
-<span class="sourceLineNo">139</span>        .setTableState(TableName.META_TABLE_NAME,
TableState.State.ENABLED);<a name="line.139"></a>
-<span class="sourceLineNo">140</span>    }<a name="line.140"></a>
+<span class="sourceLineNo">118</span>  private void unassignExcessMetaReplica(int
numMetaReplicasConfigured) {<a name="line.118"></a>
+<span class="sourceLineNo">119</span>    final ZKWatcher zooKeeper = master.getZooKeeper();<a
name="line.119"></a>
+<span class="sourceLineNo">120</span>    // unassign the unneeded replicas (for
e.g., if the previous master was configured<a name="line.120"></a>
+<span class="sourceLineNo">121</span>    // with a replication of 3 and now it
is 2, we need to unassign the 1 unneeded replica)<a name="line.121"></a>
+<span class="sourceLineNo">122</span>    try {<a name="line.122"></a>
+<span class="sourceLineNo">123</span>      List&lt;String&gt; metaReplicaZnodes
= zooKeeper.getMetaReplicaNodes();<a name="line.123"></a>
+<span class="sourceLineNo">124</span>      for (String metaReplicaZnode : metaReplicaZnodes)
{<a name="line.124"></a>
+<span class="sourceLineNo">125</span>        int replicaId = zooKeeper.znodePaths.getMetaReplicaIdFromZnode(metaReplicaZnode);<a
name="line.125"></a>
+<span class="sourceLineNo">126</span>        if (replicaId &gt;= numMetaReplicasConfigured)
{<a name="line.126"></a>
+<span class="sourceLineNo">127</span>          RegionState r = MetaTableLocator.getMetaRegionState(zooKeeper,
replicaId);<a name="line.127"></a>
+<span class="sourceLineNo">128</span>          LOG.info("Closing excess replica
of meta region " + r.getRegion());<a name="line.128"></a>
+<span class="sourceLineNo">129</span>          // send a close and wait for a
max of 30 seconds<a name="line.129"></a>
+<span class="sourceLineNo">130</span>          ServerManager.closeRegionSilentlyAndWait(master.getClusterConnection(),<a
name="line.130"></a>
+<span class="sourceLineNo">131</span>              r.getServerName(), r.getRegion(),
30000);<a name="line.131"></a>
+<span class="sourceLineNo">132</span>          ZKUtil.deleteNode(zooKeeper, zooKeeper.znodePaths.getZNodeForReplica(replicaId));<a
name="line.132"></a>
+<span class="sourceLineNo">133</span>        }<a name="line.133"></a>
+<span class="sourceLineNo">134</span>      }<a name="line.134"></a>
+<span class="sourceLineNo">135</span>    } catch (Exception ex) {<a name="line.135"></a>
+<span class="sourceLineNo">136</span>      // ignore the exception since we don't
want the master to be wedged due to potential<a name="line.136"></a>
+<span class="sourceLineNo">137</span>      // issues in the cleanup of the extra
regions. We can do that cleanup via hbck or manually<a name="line.137"></a>
+<span class="sourceLineNo">138</span>      LOG.warn("Ignoring exception " + ex);<a
name="line.138"></a>
+<span class="sourceLineNo">139</span>    }<a name="line.139"></a>
+<span class="sourceLineNo">140</span>  }<a name="line.140"></a>
 <span class="sourceLineNo">141</span><a name="line.141"></a>
-<span class="sourceLineNo">142</span>    master.getTableStateManager().start();<a
name="line.142"></a>
-<span class="sourceLineNo">143</span><a name="line.143"></a>
-<span class="sourceLineNo">144</span>    // Make sure a hbase:meta location is
set. We need to enable SSH here since<a name="line.144"></a>
-<span class="sourceLineNo">145</span>    // if the meta region server is died
at this time, we need it to be re-assigned<a name="line.145"></a>
-<span class="sourceLineNo">146</span>    // by SSH so that system tables can
be assigned.<a name="line.146"></a>
-<span class="sourceLineNo">147</span>    // No need to wait for meta is assigned
= 0 when meta is just verified.<a name="line.147"></a>
-<span class="sourceLineNo">148</span>    if (replicaId == RegionInfo.DEFAULT_REPLICA_ID)
enableCrashedServerProcessing(false);<a name="line.148"></a>
-<span class="sourceLineNo">149</span>    LOG.info("hbase:meta with replicaId
" + replicaId + ", location="<a name="line.149"></a>
-<span class="sourceLineNo">150</span>      + master.getMetaTableLocator().getMetaRegionLocation(master.getZooKeeper(),
replicaId));<a name="line.150"></a>
-<span class="sourceLineNo">151</span>    status.setStatus("META assigned.");<a
name="line.151"></a>
-<span class="sourceLineNo">152</span>  }<a name="line.152"></a>
-<span class="sourceLineNo">153</span><a name="line.153"></a>
-<span class="sourceLineNo">154</span>  private void enableCrashedServerProcessing(final
boolean waitForMeta)<a name="line.154"></a>
-<span class="sourceLineNo">155</span>      throws InterruptedException {<a
name="line.155"></a>
-<span class="sourceLineNo">156</span>    // If crashed server processing is disabled,
we enable it and expire those dead but not expired<a name="line.156"></a>
-<span class="sourceLineNo">157</span>    // servers. This is required so that
if meta is assigning to a server which dies after<a name="line.157"></a>
-<span class="sourceLineNo">158</span>    // assignMeta starts assignment, ServerCrashProcedure
can re-assign it. Otherwise, we will be<a name="line.158"></a>
-<span class="sourceLineNo">159</span>    // stuck here waiting forever if waitForMeta
is specified.<a name="line.159"></a>
-<span class="sourceLineNo">160</span>    if (!master.isServerCrashProcessingEnabled())
{<a name="line.160"></a>
-<span class="sourceLineNo">161</span>      master.setServerCrashProcessingEnabled(true);<a
name="line.161"></a>
-<span class="sourceLineNo">162</span>      master.getServerManager().processQueuedDeadServers();<a
name="line.162"></a>
-<span class="sourceLineNo">163</span>    }<a name="line.163"></a>
-<span class="sourceLineNo">164</span><a name="line.164"></a>
-<span class="sourceLineNo">165</span>    if (waitForMeta) {<a name="line.165"></a>
-<span class="sourceLineNo">166</span>      master.getMetaTableLocator().waitMetaRegionLocation(master.getZooKeeper());<a
name="line.166"></a>
-<span class="sourceLineNo">167</span>    }<a name="line.167"></a>
-<span class="sourceLineNo">168</span>  }<a name="line.168"></a>
-<span class="sourceLineNo">169</span>}<a name="line.169"></a>
+<span class="sourceLineNo">142</span>  private void enableCrashedServerProcessing(final
boolean waitForMeta)<a name="line.142"></a>
+<span class="sourceLineNo">143</span>      throws InterruptedException {<a
name="line.143"></a>
+<span class="sourceLineNo">144</span>    // If crashed server processing is disabled,
we enable it and expire those dead but not expired<a name="line.144"></a>
+<span class="sourceLineNo">145</span>    // servers. This is required so that
if meta is assigning to a server which dies after<a name="line.145"></a>
+<span class="sourceLineNo">146</span>    // assignMeta starts assignment, ServerCrashProcedure
can re-assign it. Otherwise, we will be<a name="line.146"></a>
+<span class="sourceLineNo">147</span>    // stuck here waiting forever if waitForMeta
is specified.<a name="line.147"></a>
+<span class="sourceLineNo">148</span>    if (!master.isServerCrashProcessingEnabled())
{<a name="line.148"></a>
+<span class="sourceLineNo">149</span>      master.setServerCrashProcessingEnabled(true);<a
name="line.149"></a>
+<span class="sourceLineNo">150</span>      master.getServerManager().processQueuedDeadServers();<a
name="line.150"></a>
+<span class="sourceLineNo">151</span>    }<a name="line.151"></a>
+<span class="sourceLineNo">152</span><a name="line.152"></a>
+<span class="sourceLineNo">153</span>    if (waitForMeta) {<a name="line.153"></a>
+<span class="sourceLineNo">154</span>      master.getMetaTableLocator().waitMetaRegionLocation(master.getZooKeeper());<a
name="line.154"></a>
+<span class="sourceLineNo">155</span>    }<a name="line.155"></a>
+<span class="sourceLineNo">156</span>  }<a name="line.156"></a>
+<span class="sourceLineNo">157</span>}<a name="line.157"></a>
 
 
 


Mime
View raw message