http://git-wip-us.apache.org/repos/asf/hbase-site/blob/738e976e/devapidocs/src-html/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.html index 460238a..508fc27 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/procedure/DisableTableProcedure.html @@ -269,7 +269,7 @@ <span class="sourceLineNo">261</span> TableStateManager tsm = env.getMasterServices().getTableStateManager();<a name="line.261"></a> <span class="sourceLineNo">262</span> TableState ts = tsm.getTableState(tableName);<a name="line.262"></a> <span class="sourceLineNo">263</span> if (!ts.isEnabled()) {<a name="line.263"></a> -<span class="sourceLineNo">264</span> LOG.info("Not ENABLED skipping {}", this);<a name="line.264"></a> +<span class="sourceLineNo">264</span> LOG.info("Not ENABLED, state={}, skipping disable; {}", ts.getState(), this);<a name="line.264"></a> <span class="sourceLineNo">265</span> setFailure("master-disable-table", new TableNotEnabledException(ts.toString()));<a name="line.265"></a> <span class="sourceLineNo">266</span> canTableBeDisabled = false;<a name="line.266"></a> <span class="sourceLineNo">267</span> }<a name="line.267"></a>
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/738e976e/devapidocs/src-html/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.html index 95b7624..a87bdc6 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/procedure/EnableTableProcedure.html @@ -339,7 +339,7 @@ <span class="sourceLineNo">331</span> TableStateManager tsm = env.getMasterServices().getTableStateManager();<a name="line.331"></a> <span class="sourceLineNo">332</span> TableState ts = tsm.getTableState(tableName);<a name="line.332"></a> <span class="sourceLineNo">333</span> if(!ts.isDisabled()){<a name="line.333"></a> -<span class="sourceLineNo">334</span> LOG.info("Not DISABLED tableState=" + ts + "; skipping enable");<a name="line.334"></a> +<span class="sourceLineNo">334</span> LOG.info("Not DISABLED tableState={}; skipping enable; {}", ts.getState(), this);<a name="line.334"></a> <span class="sourceLineNo">335</span> setFailure("master-enable-table", new TableNotDisabledException(ts.toString()));<a name="line.335"></a> <span class="sourceLineNo">336</span> canTableBeEnabled = false;<a name="line.336"></a> <span class="sourceLineNo">337</span> }<a name="line.337"></a> http://git-wip-us.apache.org/repos/asf/hbase-site/blob/738e976e/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.CompactionChecker.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.CompactionChecker.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.CompactionChecker.html index e074a8c..8cc5add 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.CompactionChecker.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.CompactionChecker.html @@ -722,172 +722,172 @@ <span class="sourceLineNo">714</span> "hbase.regionserver.kerberos.principal", host);<a name="line.714"></a> <span class="sourceLineNo">715</span> }<a name="line.715"></a> <span class="sourceLineNo">716</span><a name="line.716"></a> -<span class="sourceLineNo">717</span> protected void waitForMasterActive() {<a name="line.717"></a> -<span class="sourceLineNo">718</span> }<a name="line.718"></a> -<span class="sourceLineNo">719</span><a name="line.719"></a> -<span class="sourceLineNo">720</span> protected String getProcessName() {<a name="line.720"></a> -<span class="sourceLineNo">721</span> return REGIONSERVER;<a name="line.721"></a> -<span class="sourceLineNo">722</span> }<a name="line.722"></a> +<span class="sourceLineNo">717</span><a name="line.717"></a> +<span class="sourceLineNo">718</span> /**<a name="line.718"></a> +<span class="sourceLineNo">719</span> * Wait for an active Master.<a name="line.719"></a> +<span class="sourceLineNo">720</span> * See override in Master superclass for how it is used.<a name="line.720"></a> +<span class="sourceLineNo">721</span> */<a name="line.721"></a> +<span class="sourceLineNo">722</span> protected void waitForMasterActive() {}<a name="line.722"></a> <span class="sourceLineNo">723</span><a name="line.723"></a> -<span class="sourceLineNo">724</span> protected boolean canCreateBaseZNode() {<a name="line.724"></a> -<span class="sourceLineNo">725</span> return this.masterless;<a name="line.725"></a> +<span class="sourceLineNo">724</span> protected String getProcessName() {<a name="line.724"></a> +<span class="sourceLineNo">725</span> return REGIONSERVER;<a name="line.725"></a> <span class="sourceLineNo">726</span> }<a name="line.726"></a> <span class="sourceLineNo">727</span><a name="line.727"></a> -<span class="sourceLineNo">728</span> protected boolean canUpdateTableDescriptor() {<a name="line.728"></a> -<span class="sourceLineNo">729</span> return false;<a name="line.729"></a> +<span class="sourceLineNo">728</span> protected boolean canCreateBaseZNode() {<a name="line.728"></a> +<span class="sourceLineNo">729</span> return this.masterless;<a name="line.729"></a> <span class="sourceLineNo">730</span> }<a name="line.730"></a> <span class="sourceLineNo">731</span><a name="line.731"></a> -<span class="sourceLineNo">732</span> protected RSRpcServices createRpcServices() throws IOException {<a name="line.732"></a> -<span class="sourceLineNo">733</span> return new RSRpcServices(this);<a name="line.733"></a> +<span class="sourceLineNo">732</span> protected boolean canUpdateTableDescriptor() {<a name="line.732"></a> +<span class="sourceLineNo">733</span> return false;<a name="line.733"></a> <span class="sourceLineNo">734</span> }<a name="line.734"></a> <span class="sourceLineNo">735</span><a name="line.735"></a> -<span class="sourceLineNo">736</span> protected void configureInfoServer() {<a name="line.736"></a> -<span class="sourceLineNo">737</span> infoServer.addServlet("rs-status", "/rs-status", RSStatusServlet.class);<a name="line.737"></a> -<span class="sourceLineNo">738</span> infoServer.setAttribute(REGIONSERVER, this);<a name="line.738"></a> -<span class="sourceLineNo">739</span> }<a name="line.739"></a> -<span class="sourceLineNo">740</span><a name="line.740"></a> -<span class="sourceLineNo">741</span> protected Class<? extends HttpServlet> getDumpServlet() {<a name="line.741"></a> -<span class="sourceLineNo">742</span> return RSDumpServlet.class;<a name="line.742"></a> +<span class="sourceLineNo">736</span> protected RSRpcServices createRpcServices() throws IOException {<a name="line.736"></a> +<span class="sourceLineNo">737</span> return new RSRpcServices(this);<a name="line.737"></a> +<span class="sourceLineNo">738</span> }<a name="line.738"></a> +<span class="sourceLineNo">739</span><a name="line.739"></a> +<span class="sourceLineNo">740</span> protected void configureInfoServer() {<a name="line.740"></a> +<span class="sourceLineNo">741</span> infoServer.addServlet("rs-status", "/rs-status", RSStatusServlet.class);<a name="line.741"></a> +<span class="sourceLineNo">742</span> infoServer.setAttribute(REGIONSERVER, this);<a name="line.742"></a> <span class="sourceLineNo">743</span> }<a name="line.743"></a> <span class="sourceLineNo">744</span><a name="line.744"></a> -<span class="sourceLineNo">745</span> @Override<a name="line.745"></a> -<span class="sourceLineNo">746</span> public boolean registerService(com.google.protobuf.Service instance) {<a name="line.746"></a> -<span class="sourceLineNo">747</span> /*<a name="line.747"></a> -<span class="sourceLineNo">748</span> * No stacking of instances is allowed for a single executorService name<a name="line.748"></a> -<span class="sourceLineNo">749</span> */<a name="line.749"></a> -<span class="sourceLineNo">750</span> com.google.protobuf.Descriptors.ServiceDescriptor serviceDesc =<a name="line.750"></a> -<span class="sourceLineNo">751</span> instance.getDescriptorForType();<a name="line.751"></a> -<span class="sourceLineNo">752</span> String serviceName = CoprocessorRpcUtils.getServiceName(serviceDesc);<a name="line.752"></a> -<span class="sourceLineNo">753</span> if (coprocessorServiceHandlers.containsKey(serviceName)) {<a name="line.753"></a> -<span class="sourceLineNo">754</span> LOG.error("Coprocessor executorService " + serviceName<a name="line.754"></a> -<span class="sourceLineNo">755</span> + " already registered, rejecting request from " + instance);<a name="line.755"></a> -<span class="sourceLineNo">756</span> return false;<a name="line.756"></a> -<span class="sourceLineNo">757</span> }<a name="line.757"></a> -<span class="sourceLineNo">758</span><a name="line.758"></a> -<span class="sourceLineNo">759</span> coprocessorServiceHandlers.put(serviceName, instance);<a name="line.759"></a> -<span class="sourceLineNo">760</span> if (LOG.isDebugEnabled()) {<a name="line.760"></a> -<span class="sourceLineNo">761</span> LOG.debug("Registered regionserver coprocessor executorService: executorService=" + serviceName);<a name="line.761"></a> -<span class="sourceLineNo">762</span> }<a name="line.762"></a> -<span class="sourceLineNo">763</span> return true;<a name="line.763"></a> -<span class="sourceLineNo">764</span> }<a name="line.764"></a> -<span class="sourceLineNo">765</span><a name="line.765"></a> -<span class="sourceLineNo">766</span> /**<a name="line.766"></a> -<span class="sourceLineNo">767</span> * Create a 'smarter' Connection, one that is capable of by-passing RPC if the request is to<a name="line.767"></a> -<span class="sourceLineNo">768</span> * the local server; i.e. a short-circuit Connection. Safe to use going to local or remote<a name="line.768"></a> -<span class="sourceLineNo">769</span> * server. Create this instance in a method can be intercepted and mocked in tests.<a name="line.769"></a> -<span class="sourceLineNo">770</span> * @throws IOException<a name="line.770"></a> -<span class="sourceLineNo">771</span> */<a name="line.771"></a> -<span class="sourceLineNo">772</span> @VisibleForTesting<a name="line.772"></a> -<span class="sourceLineNo">773</span> protected ClusterConnection createClusterConnection() throws IOException {<a name="line.773"></a> -<span class="sourceLineNo">774</span> Configuration conf = this.conf;<a name="line.774"></a> -<span class="sourceLineNo">775</span> if (conf.get(HConstants.CLIENT_ZOOKEEPER_QUORUM) != null) {<a name="line.775"></a> -<span class="sourceLineNo">776</span> // Use server ZK cluster for server-issued connections, so we clone<a name="line.776"></a> -<span class="sourceLineNo">777</span> // the conf and unset the client ZK related properties<a name="line.777"></a> -<span class="sourceLineNo">778</span> conf = new Configuration(this.conf);<a name="line.778"></a> -<span class="sourceLineNo">779</span> conf.unset(HConstants.CLIENT_ZOOKEEPER_QUORUM);<a name="line.779"></a> -<span class="sourceLineNo">780</span> }<a name="line.780"></a> -<span class="sourceLineNo">781</span> // Create a cluster connection that when appropriate, can short-circuit and go directly to the<a name="line.781"></a> -<span class="sourceLineNo">782</span> // local server if the request is to the local server bypassing RPC. Can be used for both local<a name="line.782"></a> -<span class="sourceLineNo">783</span> // and remote invocations.<a name="line.783"></a> -<span class="sourceLineNo">784</span> return ConnectionUtils.createShortCircuitConnection(conf, null, userProvider.getCurrent(),<a name="line.784"></a> -<span class="sourceLineNo">785</span> serverName, rpcServices, rpcServices);<a name="line.785"></a> -<span class="sourceLineNo">786</span> }<a name="line.786"></a> -<span class="sourceLineNo">787</span><a name="line.787"></a> -<span class="sourceLineNo">788</span> /**<a name="line.788"></a> -<span class="sourceLineNo">789</span> * Run test on configured codecs to make sure supporting libs are in place.<a name="line.789"></a> -<span class="sourceLineNo">790</span> * @param c<a name="line.790"></a> -<span class="sourceLineNo">791</span> * @throws IOException<a name="line.791"></a> -<span class="sourceLineNo">792</span> */<a name="line.792"></a> -<span class="sourceLineNo">793</span> private static void checkCodecs(final Configuration c) throws IOException {<a name="line.793"></a> -<span class="sourceLineNo">794</span> // check to see if the codec list is available:<a name="line.794"></a> -<span class="sourceLineNo">795</span> String [] codecs = c.getStrings("hbase.regionserver.codecs", (String[])null);<a name="line.795"></a> -<span class="sourceLineNo">796</span> if (codecs == null) return;<a name="line.796"></a> -<span class="sourceLineNo">797</span> for (String codec : codecs) {<a name="line.797"></a> -<span class="sourceLineNo">798</span> if (!CompressionTest.testCompression(codec)) {<a name="line.798"></a> -<span class="sourceLineNo">799</span> throw new IOException("Compression codec " + codec +<a name="line.799"></a> -<span class="sourceLineNo">800</span> " not supported, aborting RS construction");<a name="line.800"></a> -<span class="sourceLineNo">801</span> }<a name="line.801"></a> -<span class="sourceLineNo">802</span> }<a name="line.802"></a> -<span class="sourceLineNo">803</span> }<a name="line.803"></a> -<span class="sourceLineNo">804</span><a name="line.804"></a> -<span class="sourceLineNo">805</span> public String getClusterId() {<a name="line.805"></a> -<span class="sourceLineNo">806</span> return this.clusterId;<a name="line.806"></a> +<span class="sourceLineNo">745</span> protected Class<? extends HttpServlet> getDumpServlet() {<a name="line.745"></a> +<span class="sourceLineNo">746</span> return RSDumpServlet.class;<a name="line.746"></a> +<span class="sourceLineNo">747</span> }<a name="line.747"></a> +<span class="sourceLineNo">748</span><a name="line.748"></a> +<span class="sourceLineNo">749</span> @Override<a name="line.749"></a> +<span class="sourceLineNo">750</span> public boolean registerService(com.google.protobuf.Service instance) {<a name="line.750"></a> +<span class="sourceLineNo">751</span> /*<a name="line.751"></a> +<span class="sourceLineNo">752</span> * No stacking of instances is allowed for a single executorService name<a name="line.752"></a> +<span class="sourceLineNo">753</span> */<a name="line.753"></a> +<span class="sourceLineNo">754</span> com.google.protobuf.Descriptors.ServiceDescriptor serviceDesc =<a name="line.754"></a> +<span class="sourceLineNo">755</span> instance.getDescriptorForType();<a name="line.755"></a> +<span class="sourceLineNo">756</span> String serviceName = CoprocessorRpcUtils.getServiceName(serviceDesc);<a name="line.756"></a> +<span class="sourceLineNo">757</span> if (coprocessorServiceHandlers.containsKey(serviceName)) {<a name="line.757"></a> +<span class="sourceLineNo">758</span> LOG.error("Coprocessor executorService " + serviceName<a name="line.758"></a> +<span class="sourceLineNo">759</span> + " already registered, rejecting request from " + instance);<a name="line.759"></a> +<span class="sourceLineNo">760</span> return false;<a name="line.760"></a> +<span class="sourceLineNo">761</span> }<a name="line.761"></a> +<span class="sourceLineNo">762</span><a name="line.762"></a> +<span class="sourceLineNo">763</span> coprocessorServiceHandlers.put(serviceName, instance);<a name="line.763"></a> +<span class="sourceLineNo">764</span> if (LOG.isDebugEnabled()) {<a name="line.764"></a> +<span class="sourceLineNo">765</span> LOG.debug("Registered regionserver coprocessor executorService: executorService=" + serviceName);<a name="line.765"></a> +<span class="sourceLineNo">766</span> }<a name="line.766"></a> +<span class="sourceLineNo">767</span> return true;<a name="line.767"></a> +<span class="sourceLineNo">768</span> }<a name="line.768"></a> +<span class="sourceLineNo">769</span><a name="line.769"></a> +<span class="sourceLineNo">770</span> /**<a name="line.770"></a> +<span class="sourceLineNo">771</span> * Create a 'smarter' Connection, one that is capable of by-passing RPC if the request is to<a name="line.771"></a> +<span class="sourceLineNo">772</span> * the local server; i.e. a short-circuit Connection. Safe to use going to local or remote<a name="line.772"></a> +<span class="sourceLineNo">773</span> * server. Create this instance in a method can be intercepted and mocked in tests.<a name="line.773"></a> +<span class="sourceLineNo">774</span> * @throws IOException<a name="line.774"></a> +<span class="sourceLineNo">775</span> */<a name="line.775"></a> +<span class="sourceLineNo">776</span> @VisibleForTesting<a name="line.776"></a> +<span class="sourceLineNo">777</span> protected ClusterConnection createClusterConnection() throws IOException {<a name="line.777"></a> +<span class="sourceLineNo">778</span> Configuration conf = this.conf;<a name="line.778"></a> +<span class="sourceLineNo">779</span> if (conf.get(HConstants.CLIENT_ZOOKEEPER_QUORUM) != null) {<a name="line.779"></a> +<span class="sourceLineNo">780</span> // Use server ZK cluster for server-issued connections, so we clone<a name="line.780"></a> +<span class="sourceLineNo">781</span> // the conf and unset the client ZK related properties<a name="line.781"></a> +<span class="sourceLineNo">782</span> conf = new Configuration(this.conf);<a name="line.782"></a> +<span class="sourceLineNo">783</span> conf.unset(HConstants.CLIENT_ZOOKEEPER_QUORUM);<a name="line.783"></a> +<span class="sourceLineNo">784</span> }<a name="line.784"></a> +<span class="sourceLineNo">785</span> // Create a cluster connection that when appropriate, can short-circuit and go directly to the<a name="line.785"></a> +<span class="sourceLineNo">786</span> // local server if the request is to the local server bypassing RPC. Can be used for both local<a name="line.786"></a> +<span class="sourceLineNo">787</span> // and remote invocations.<a name="line.787"></a> +<span class="sourceLineNo">788</span> return ConnectionUtils.createShortCircuitConnection(conf, null, userProvider.getCurrent(),<a name="line.788"></a> +<span class="sourceLineNo">789</span> serverName, rpcServices, rpcServices);<a name="line.789"></a> +<span class="sourceLineNo">790</span> }<a name="line.790"></a> +<span class="sourceLineNo">791</span><a name="line.791"></a> +<span class="sourceLineNo">792</span> /**<a name="line.792"></a> +<span class="sourceLineNo">793</span> * Run test on configured codecs to make sure supporting libs are in place.<a name="line.793"></a> +<span class="sourceLineNo">794</span> * @param c<a name="line.794"></a> +<span class="sourceLineNo">795</span> * @throws IOException<a name="line.795"></a> +<span class="sourceLineNo">796</span> */<a name="line.796"></a> +<span class="sourceLineNo">797</span> private static void checkCodecs(final Configuration c) throws IOException {<a name="line.797"></a> +<span class="sourceLineNo">798</span> // check to see if the codec list is available:<a name="line.798"></a> +<span class="sourceLineNo">799</span> String [] codecs = c.getStrings("hbase.regionserver.codecs", (String[])null);<a name="line.799"></a> +<span class="sourceLineNo">800</span> if (codecs == null) return;<a name="line.800"></a> +<span class="sourceLineNo">801</span> for (String codec : codecs) {<a name="line.801"></a> +<span class="sourceLineNo">802</span> if (!CompressionTest.testCompression(codec)) {<a name="line.802"></a> +<span class="sourceLineNo">803</span> throw new IOException("Compression codec " + codec +<a name="line.803"></a> +<span class="sourceLineNo">804</span> " not supported, aborting RS construction");<a name="line.804"></a> +<span class="sourceLineNo">805</span> }<a name="line.805"></a> +<span class="sourceLineNo">806</span> }<a name="line.806"></a> <span class="sourceLineNo">807</span> }<a name="line.807"></a> <span class="sourceLineNo">808</span><a name="line.808"></a> -<span class="sourceLineNo">809</span> /**<a name="line.809"></a> -<span class="sourceLineNo">810</span> * Setup our cluster connection if not already initialized.<a name="line.810"></a> -<span class="sourceLineNo">811</span> * @throws IOException<a name="line.811"></a> -<span class="sourceLineNo">812</span> */<a name="line.812"></a> -<span class="sourceLineNo">813</span> protected synchronized void setupClusterConnection() throws IOException {<a name="line.813"></a> -<span class="sourceLineNo">814</span> if (clusterConnection == null) {<a name="line.814"></a> -<span class="sourceLineNo">815</span> clusterConnection = createClusterConnection();<a name="line.815"></a> -<span class="sourceLineNo">816</span> metaTableLocator = new MetaTableLocator();<a name="line.816"></a> -<span class="sourceLineNo">817</span> }<a name="line.817"></a> -<span class="sourceLineNo">818</span> }<a name="line.818"></a> -<span class="sourceLineNo">819</span><a name="line.819"></a> -<span class="sourceLineNo">820</span> /**<a name="line.820"></a> -<span class="sourceLineNo">821</span> * All initialization needed before we go register with Master.<br><a name="line.821"></a> -<span class="sourceLineNo">822</span> * Do bare minimum. Do bulk of initializations AFTER we've connected to the Master.<br><a name="line.822"></a> -<span class="sourceLineNo">823</span> * In here we just put up the RpcServer, setup Connection, and ZooKeeper.<a name="line.823"></a> -<span class="sourceLineNo">824</span> */<a name="line.824"></a> -<span class="sourceLineNo">825</span> private void preRegistrationInitialization() {<a name="line.825"></a> -<span class="sourceLineNo">826</span> try {<a name="line.826"></a> -<span class="sourceLineNo">827</span> initializeZooKeeper();<a name="line.827"></a> -<span class="sourceLineNo">828</span> setupClusterConnection();<a name="line.828"></a> -<span class="sourceLineNo">829</span> // Setup RPC client for master communication<a name="line.829"></a> -<span class="sourceLineNo">830</span> this.rpcClient = RpcClientFactory.createClient(conf, clusterId, new InetSocketAddress(<a name="line.830"></a> -<span class="sourceLineNo">831</span> this.rpcServices.isa.getAddress(), 0), clusterConnection.getConnectionMetrics());<a name="line.831"></a> -<span class="sourceLineNo">832</span> } catch (Throwable t) {<a name="line.832"></a> -<span class="sourceLineNo">833</span> // Call stop if error or process will stick around for ever since server<a name="line.833"></a> -<span class="sourceLineNo">834</span> // puts up non-daemon threads.<a name="line.834"></a> -<span class="sourceLineNo">835</span> this.rpcServices.stop();<a name="line.835"></a> -<span class="sourceLineNo">836</span> abort("Initialization of RS failed. Hence aborting RS.", t);<a name="line.836"></a> -<span class="sourceLineNo">837</span> }<a name="line.837"></a> -<span class="sourceLineNo">838</span> }<a name="line.838"></a> -<span class="sourceLineNo">839</span><a name="line.839"></a> -<span class="sourceLineNo">840</span> /**<a name="line.840"></a> -<span class="sourceLineNo">841</span> * Bring up connection to zk ensemble and then wait until a master for this cluster and then after<a name="line.841"></a> -<span class="sourceLineNo">842</span> * that, wait until cluster 'up' flag has been set. This is the order in which master does things.<a name="line.842"></a> -<span class="sourceLineNo">843</span> * <p><a name="line.843"></a> -<span class="sourceLineNo">844</span> * Finally open long-living server short-circuit connection.<a name="line.844"></a> -<span class="sourceLineNo">845</span> */<a name="line.845"></a> -<span class="sourceLineNo">846</span> @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE",<a name="line.846"></a> -<span class="sourceLineNo">847</span> justification="cluster Id znode read would give us correct response")<a name="line.847"></a> -<span class="sourceLineNo">848</span> private void initializeZooKeeper() throws IOException, InterruptedException {<a name="line.848"></a> -<span class="sourceLineNo">849</span> // Nothing to do in here if no Master in the mix.<a name="line.849"></a> -<span class="sourceLineNo">850</span> if (this.masterless) {<a name="line.850"></a> -<span class="sourceLineNo">851</span> return;<a name="line.851"></a> -<span class="sourceLineNo">852</span> }<a name="line.852"></a> -<span class="sourceLineNo">853</span><a name="line.853"></a> -<span class="sourceLineNo">854</span> // Create the master address tracker, register with zk, and start it. Then<a name="line.854"></a> -<span class="sourceLineNo">855</span> // block until a master is available. No point in starting up if no master<a name="line.855"></a> -<span class="sourceLineNo">856</span> // running.<a name="line.856"></a> -<span class="sourceLineNo">857</span> blockAndCheckIfStopped(this.masterAddressTracker);<a name="line.857"></a> -<span class="sourceLineNo">858</span><a name="line.858"></a> -<span class="sourceLineNo">859</span> // Wait on cluster being up. Master will set this flag up in zookeeper<a name="line.859"></a> -<span class="sourceLineNo">860</span> // when ready.<a name="line.860"></a> -<span class="sourceLineNo">861</span> blockAndCheckIfStopped(this.clusterStatusTracker);<a name="line.861"></a> +<span class="sourceLineNo">809</span> public String getClusterId() {<a name="line.809"></a> +<span class="sourceLineNo">810</span> return this.clusterId;<a name="line.810"></a> +<span class="sourceLineNo">811</span> }<a name="line.811"></a> +<span class="sourceLineNo">812</span><a name="line.812"></a> +<span class="sourceLineNo">813</span> /**<a name="line.813"></a> +<span class="sourceLineNo">814</span> * Setup our cluster connection if not already initialized.<a name="line.814"></a> +<span class="sourceLineNo">815</span> * @throws IOException<a name="line.815"></a> +<span class="sourceLineNo">816</span> */<a name="line.816"></a> +<span class="sourceLineNo">817</span> protected synchronized void setupClusterConnection() throws IOException {<a name="line.817"></a> +<span class="sourceLineNo">818</span> if (clusterConnection == null) {<a name="line.818"></a> +<span class="sourceLineNo">819</span> clusterConnection = createClusterConnection();<a name="line.819"></a> +<span class="sourceLineNo">820</span> metaTableLocator = new MetaTableLocator();<a name="line.820"></a> +<span class="sourceLineNo">821</span> }<a name="line.821"></a> +<span class="sourceLineNo">822</span> }<a name="line.822"></a> +<span class="sourceLineNo">823</span><a name="line.823"></a> +<span class="sourceLineNo">824</span> /**<a name="line.824"></a> +<span class="sourceLineNo">825</span> * All initialization needed before we go register with Master.<br><a name="line.825"></a> +<span class="sourceLineNo">826</span> * Do bare minimum. Do bulk of initializations AFTER we've connected to the Master.<br><a name="line.826"></a> +<span class="sourceLineNo">827</span> * In here we just put up the RpcServer, setup Connection, and ZooKeeper.<a name="line.827"></a> +<span class="sourceLineNo">828</span> */<a name="line.828"></a> +<span class="sourceLineNo">829</span> private void preRegistrationInitialization() {<a name="line.829"></a> +<span class="sourceLineNo">830</span> try {<a name="line.830"></a> +<span class="sourceLineNo">831</span> initializeZooKeeper();<a name="line.831"></a> +<span class="sourceLineNo">832</span> setupClusterConnection();<a name="line.832"></a> +<span class="sourceLineNo">833</span> // Setup RPC client for master communication<a name="line.833"></a> +<span class="sourceLineNo">834</span> this.rpcClient = RpcClientFactory.createClient(conf, clusterId, new InetSocketAddress(<a name="line.834"></a> +<span class="sourceLineNo">835</span> this.rpcServices.isa.getAddress(), 0), clusterConnection.getConnectionMetrics());<a name="line.835"></a> +<span class="sourceLineNo">836</span> } catch (Throwable t) {<a name="line.836"></a> +<span class="sourceLineNo">837</span> // Call stop if error or process will stick around for ever since server<a name="line.837"></a> +<span class="sourceLineNo">838</span> // puts up non-daemon threads.<a name="line.838"></a> +<span class="sourceLineNo">839</span> this.rpcServices.stop();<a name="line.839"></a> +<span class="sourceLineNo">840</span> abort("Initialization of RS failed. Hence aborting RS.", t);<a name="line.840"></a> +<span class="sourceLineNo">841</span> }<a name="line.841"></a> +<span class="sourceLineNo">842</span> }<a name="line.842"></a> +<span class="sourceLineNo">843</span><a name="line.843"></a> +<span class="sourceLineNo">844</span> /**<a name="line.844"></a> +<span class="sourceLineNo">845</span> * Bring up connection to zk ensemble and then wait until a master for this cluster and then after<a name="line.845"></a> +<span class="sourceLineNo">846</span> * that, wait until cluster 'up' flag has been set. This is the order in which master does things.<a name="line.846"></a> +<span class="sourceLineNo">847</span> * <p><a name="line.847"></a> +<span class="sourceLineNo">848</span> * Finally open long-living server short-circuit connection.<a name="line.848"></a> +<span class="sourceLineNo">849</span> */<a name="line.849"></a> +<span class="sourceLineNo">850</span> @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE",<a name="line.850"></a> +<span class="sourceLineNo">851</span> justification="cluster Id znode read would give us correct response")<a name="line.851"></a> +<span class="sourceLineNo">852</span> private void initializeZooKeeper() throws IOException, InterruptedException {<a name="line.852"></a> +<span class="sourceLineNo">853</span> // Nothing to do in here if no Master in the mix.<a name="line.853"></a> +<span class="sourceLineNo">854</span> if (this.masterless) {<a name="line.854"></a> +<span class="sourceLineNo">855</span> return;<a name="line.855"></a> +<span class="sourceLineNo">856</span> }<a name="line.856"></a> +<span class="sourceLineNo">857</span><a name="line.857"></a> +<span class="sourceLineNo">858</span> // Create the master address tracker, register with zk, and start it. Then<a name="line.858"></a> +<span class="sourceLineNo">859</span> // block until a master is available. No point in starting up if no master<a name="line.859"></a> +<span class="sourceLineNo">860</span> // running.<a name="line.860"></a> +<span class="sourceLineNo">861</span> blockAndCheckIfStopped(this.masterAddressTracker);<a name="line.861"></a> <span class="sourceLineNo">862</span><a name="line.862"></a> -<span class="sourceLineNo">863</span> // If we are HMaster then the cluster id should have already been set.<a name="line.863"></a> -<span class="sourceLineNo">864</span> if (clusterId == null) {<a name="line.864"></a> -<span class="sourceLineNo">865</span> // Retrieve clusterId<a name="line.865"></a> -<span class="sourceLineNo">866</span> // Since cluster status is now up<a name="line.866"></a> -<span class="sourceLineNo">867</span> // ID should have already been set by HMaster<a name="line.867"></a> -<span class="sourceLineNo">868</span> try {<a name="line.868"></a> -<span class="sourceLineNo">869</span> clusterId = ZKClusterId.readClusterIdZNode(this.zooKeeper);<a name="line.869"></a> -<span class="sourceLineNo">870</span> if (clusterId == null) {<a name="line.870"></a> -<span class="sourceLineNo">871</span> this.abort("Cluster ID has not been set");<a name="line.871"></a> -<span class="sourceLineNo">872</span> }<a name="line.872"></a> -<span class="sourceLineNo">873</span> LOG.info("ClusterId : " + clusterId);<a name="line.873"></a> -<span class="sourceLineNo">874</span> } catch (KeeperException e) {<a name="line.874"></a> -<span class="sourceLineNo">875</span> this.abort("Failed to retrieve Cluster ID", e);<a name="line.875"></a> -<span class="sourceLineNo">876</span> }<a name="line.876"></a> -<span class="sourceLineNo">877</span> }<a name="line.877"></a> -<span class="sourceLineNo">878</span><a name="line.878"></a> -<span class="sourceLineNo">879</span> // In case colocated master, wait here till it's active.<a name="line.879"></a> -<span class="sourceLineNo">880</span> // So backup masters won't start as regionservers.<a name="line.880"></a> -<span class="sourceLineNo">881</span> // This is to avoid showing backup masters as regionservers<a name="line.881"></a> -<span class="sourceLineNo">882</span> // in master web UI, or assigning any region to them.<a name="line.882"></a> +<span class="sourceLineNo">863</span> // Wait on cluster being up. Master will set this flag up in zookeeper<a name="line.863"></a> +<span class="sourceLineNo">864</span> // when ready.<a name="line.864"></a> +<span class="sourceLineNo">865</span> blockAndCheckIfStopped(this.clusterStatusTracker);<a name="line.865"></a> +<span class="sourceLineNo">866</span><a name="line.866"></a> +<span class="sourceLineNo">867</span> // If we are HMaster then the cluster id should have already been set.<a name="line.867"></a> +<span class="sourceLineNo">868</span> if (clusterId == null) {<a name="line.868"></a> +<span class="sourceLineNo">869</span> // Retrieve clusterId<a name="line.869"></a> +<span class="sourceLineNo">870</span> // Since cluster status is now up<a name="line.870"></a> +<span class="sourceLineNo">871</span> // ID should have already been set by HMaster<a name="line.871"></a> +<span class="sourceLineNo">872</span> try {<a name="line.872"></a> +<span class="sourceLineNo">873</span> clusterId = ZKClusterId.readClusterIdZNode(this.zooKeeper);<a name="line.873"></a> +<span class="sourceLineNo">874</span> if (clusterId == null) {<a name="line.874"></a> +<span class="sourceLineNo">875</span> this.abort("Cluster ID has not been set");<a name="line.875"></a> +<span class="sourceLineNo">876</span> }<a name="line.876"></a> +<span class="sourceLineNo">877</span> LOG.info("ClusterId : " + clusterId);<a name="line.877"></a> +<span class="sourceLineNo">878</span> } catch (KeeperException e) {<a name="line.878"></a> +<span class="sourceLineNo">879</span> this.abort("Failed to retrieve Cluster ID", e);<a name="line.879"></a> +<span class="sourceLineNo">880</span> }<a name="line.880"></a> +<span class="sourceLineNo">881</span> }<a name="line.881"></a> +<span class="sourceLineNo">882</span><a name="line.882"></a> <span class="sourceLineNo">883</span> waitForMasterActive();<a name="line.883"></a> <span class="sourceLineNo">884</span> if (isStopped() || isAborted()) {<a name="line.884"></a> <span class="sourceLineNo">885</span> return; // No need for further initialization<a name="line.885"></a> http://git-wip-us.apache.org/repos/asf/hbase-site/blob/738e976e/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionInfo.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionInfo.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionInfo.html index e074a8c..8cc5add 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionInfo.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/HRegionServer.MovedRegionInfo.html @@ -722,172 +722,172 @@ <span class="sourceLineNo">714</span> "hbase.regionserver.kerberos.principal", host);<a name="line.714"></a> <span class="sourceLineNo">715</span> }<a name="line.715"></a> <span class="sourceLineNo">716</span><a name="line.716"></a> -<span class="sourceLineNo">717</span> protected void waitForMasterActive() {<a name="line.717"></a> -<span class="sourceLineNo">718</span> }<a name="line.718"></a> -<span class="sourceLineNo">719</span><a name="line.719"></a> -<span class="sourceLineNo">720</span> protected String getProcessName() {<a name="line.720"></a> -<span class="sourceLineNo">721</span> return REGIONSERVER;<a name="line.721"></a> -<span class="sourceLineNo">722</span> }<a name="line.722"></a> +<span class="sourceLineNo">717</span><a name="line.717"></a> +<span class="sourceLineNo">718</span> /**<a name="line.718"></a> +<span class="sourceLineNo">719</span> * Wait for an active Master.<a name="line.719"></a> +<span class="sourceLineNo">720</span> * See override in Master superclass for how it is used.<a name="line.720"></a> +<span class="sourceLineNo">721</span> */<a name="line.721"></a> +<span class="sourceLineNo">722</span> protected void waitForMasterActive() {}<a name="line.722"></a> <span class="sourceLineNo">723</span><a name="line.723"></a> -<span class="sourceLineNo">724</span> protected boolean canCreateBaseZNode() {<a name="line.724"></a> -<span class="sourceLineNo">725</span> return this.masterless;<a name="line.725"></a> +<span class="sourceLineNo">724</span> protected String getProcessName() {<a name="line.724"></a> +<span class="sourceLineNo">725</span> return REGIONSERVER;<a name="line.725"></a> <span class="sourceLineNo">726</span> }<a name="line.726"></a> <span class="sourceLineNo">727</span><a name="line.727"></a> -<span class="sourceLineNo">728</span> protected boolean canUpdateTableDescriptor() {<a name="line.728"></a> -<span class="sourceLineNo">729</span> return false;<a name="line.729"></a> +<span class="sourceLineNo">728</span> protected boolean canCreateBaseZNode() {<a name="line.728"></a> +<span class="sourceLineNo">729</span> return this.masterless;<a name="line.729"></a> <span class="sourceLineNo">730</span> }<a name="line.730"></a> <span class="sourceLineNo">731</span><a name="line.731"></a> -<span class="sourceLineNo">732</span> protected RSRpcServices createRpcServices() throws IOException {<a name="line.732"></a> -<span class="sourceLineNo">733</span> return new RSRpcServices(this);<a name="line.733"></a> +<span class="sourceLineNo">732</span> protected boolean canUpdateTableDescriptor() {<a name="line.732"></a> +<span class="sourceLineNo">733</span> return false;<a name="line.733"></a> <span class="sourceLineNo">734</span> }<a name="line.734"></a> <span class="sourceLineNo">735</span><a name="line.735"></a> -<span class="sourceLineNo">736</span> protected void configureInfoServer() {<a name="line.736"></a> -<span class="sourceLineNo">737</span> infoServer.addServlet("rs-status", "/rs-status", RSStatusServlet.class);<a name="line.737"></a> -<span class="sourceLineNo">738</span> infoServer.setAttribute(REGIONSERVER, this);<a name="line.738"></a> -<span class="sourceLineNo">739</span> }<a name="line.739"></a> -<span class="sourceLineNo">740</span><a name="line.740"></a> -<span class="sourceLineNo">741</span> protected Class<? extends HttpServlet> getDumpServlet() {<a name="line.741"></a> -<span class="sourceLineNo">742</span> return RSDumpServlet.class;<a name="line.742"></a> +<span class="sourceLineNo">736</span> protected RSRpcServices createRpcServices() throws IOException {<a name="line.736"></a> +<span class="sourceLineNo">737</span> return new RSRpcServices(this);<a name="line.737"></a> +<span class="sourceLineNo">738</span> }<a name="line.738"></a> +<span class="sourceLineNo">739</span><a name="line.739"></a> +<span class="sourceLineNo">740</span> protected void configureInfoServer() {<a name="line.740"></a> +<span class="sourceLineNo">741</span> infoServer.addServlet("rs-status", "/rs-status", RSStatusServlet.class);<a name="line.741"></a> +<span class="sourceLineNo">742</span> infoServer.setAttribute(REGIONSERVER, this);<a name="line.742"></a> <span class="sourceLineNo">743</span> }<a name="line.743"></a> <span class="sourceLineNo">744</span><a name="line.744"></a> -<span class="sourceLineNo">745</span> @Override<a name="line.745"></a> -<span class="sourceLineNo">746</span> public boolean registerService(com.google.protobuf.Service instance) {<a name="line.746"></a> -<span class="sourceLineNo">747</span> /*<a name="line.747"></a> -<span class="sourceLineNo">748</span> * No stacking of instances is allowed for a single executorService name<a name="line.748"></a> -<span class="sourceLineNo">749</span> */<a name="line.749"></a> -<span class="sourceLineNo">750</span> com.google.protobuf.Descriptors.ServiceDescriptor serviceDesc =<a name="line.750"></a> -<span class="sourceLineNo">751</span> instance.getDescriptorForType();<a name="line.751"></a> -<span class="sourceLineNo">752</span> String serviceName = CoprocessorRpcUtils.getServiceName(serviceDesc);<a name="line.752"></a> -<span class="sourceLineNo">753</span> if (coprocessorServiceHandlers.containsKey(serviceName)) {<a name="line.753"></a> -<span class="sourceLineNo">754</span> LOG.error("Coprocessor executorService " + serviceName<a name="line.754"></a> -<span class="sourceLineNo">755</span> + " already registered, rejecting request from " + instance);<a name="line.755"></a> -<span class="sourceLineNo">756</span> return false;<a name="line.756"></a> -<span class="sourceLineNo">757</span> }<a name="line.757"></a> -<span class="sourceLineNo">758</span><a name="line.758"></a> -<span class="sourceLineNo">759</span> coprocessorServiceHandlers.put(serviceName, instance);<a name="line.759"></a> -<span class="sourceLineNo">760</span> if (LOG.isDebugEnabled()) {<a name="line.760"></a> -<span class="sourceLineNo">761</span> LOG.debug("Registered regionserver coprocessor executorService: executorService=" + serviceName);<a name="line.761"></a> -<span class="sourceLineNo">762</span> }<a name="line.762"></a> -<span class="sourceLineNo">763</span> return true;<a name="line.763"></a> -<span class="sourceLineNo">764</span> }<a name="line.764"></a> -<span class="sourceLineNo">765</span><a name="line.765"></a> -<span class="sourceLineNo">766</span> /**<a name="line.766"></a> -<span class="sourceLineNo">767</span> * Create a 'smarter' Connection, one that is capable of by-passing RPC if the request is to<a name="line.767"></a> -<span class="sourceLineNo">768</span> * the local server; i.e. a short-circuit Connection. Safe to use going to local or remote<a name="line.768"></a> -<span class="sourceLineNo">769</span> * server. Create this instance in a method can be intercepted and mocked in tests.<a name="line.769"></a> -<span class="sourceLineNo">770</span> * @throws IOException<a name="line.770"></a> -<span class="sourceLineNo">771</span> */<a name="line.771"></a> -<span class="sourceLineNo">772</span> @VisibleForTesting<a name="line.772"></a> -<span class="sourceLineNo">773</span> protected ClusterConnection createClusterConnection() throws IOException {<a name="line.773"></a> -<span class="sourceLineNo">774</span> Configuration conf = this.conf;<a name="line.774"></a> -<span class="sourceLineNo">775</span> if (conf.get(HConstants.CLIENT_ZOOKEEPER_QUORUM) != null) {<a name="line.775"></a> -<span class="sourceLineNo">776</span> // Use server ZK cluster for server-issued connections, so we clone<a name="line.776"></a> -<span class="sourceLineNo">777</span> // the conf and unset the client ZK related properties<a name="line.777"></a> -<span class="sourceLineNo">778</span> conf = new Configuration(this.conf);<a name="line.778"></a> -<span class="sourceLineNo">779</span> conf.unset(HConstants.CLIENT_ZOOKEEPER_QUORUM);<a name="line.779"></a> -<span class="sourceLineNo">780</span> }<a name="line.780"></a> -<span class="sourceLineNo">781</span> // Create a cluster connection that when appropriate, can short-circuit and go directly to the<a name="line.781"></a> -<span class="sourceLineNo">782</span> // local server if the request is to the local server bypassing RPC. Can be used for both local<a name="line.782"></a> -<span class="sourceLineNo">783</span> // and remote invocations.<a name="line.783"></a> -<span class="sourceLineNo">784</span> return ConnectionUtils.createShortCircuitConnection(conf, null, userProvider.getCurrent(),<a name="line.784"></a> -<span class="sourceLineNo">785</span> serverName, rpcServices, rpcServices);<a name="line.785"></a> -<span class="sourceLineNo">786</span> }<a name="line.786"></a> -<span class="sourceLineNo">787</span><a name="line.787"></a> -<span class="sourceLineNo">788</span> /**<a name="line.788"></a> -<span class="sourceLineNo">789</span> * Run test on configured codecs to make sure supporting libs are in place.<a name="line.789"></a> -<span class="sourceLineNo">790</span> * @param c<a name="line.790"></a> -<span class="sourceLineNo">791</span> * @throws IOException<a name="line.791"></a> -<span class="sourceLineNo">792</span> */<a name="line.792"></a> -<span class="sourceLineNo">793</span> private static void checkCodecs(final Configuration c) throws IOException {<a name="line.793"></a> -<span class="sourceLineNo">794</span> // check to see if the codec list is available:<a name="line.794"></a> -<span class="sourceLineNo">795</span> String [] codecs = c.getStrings("hbase.regionserver.codecs", (String[])null);<a name="line.795"></a> -<span class="sourceLineNo">796</span> if (codecs == null) return;<a name="line.796"></a> -<span class="sourceLineNo">797</span> for (String codec : codecs) {<a name="line.797"></a> -<span class="sourceLineNo">798</span> if (!CompressionTest.testCompression(codec)) {<a name="line.798"></a> -<span class="sourceLineNo">799</span> throw new IOException("Compression codec " + codec +<a name="line.799"></a> -<span class="sourceLineNo">800</span> " not supported, aborting RS construction");<a name="line.800"></a> -<span class="sourceLineNo">801</span> }<a name="line.801"></a> -<span class="sourceLineNo">802</span> }<a name="line.802"></a> -<span class="sourceLineNo">803</span> }<a name="line.803"></a> -<span class="sourceLineNo">804</span><a name="line.804"></a> -<span class="sourceLineNo">805</span> public String getClusterId() {<a name="line.805"></a> -<span class="sourceLineNo">806</span> return this.clusterId;<a name="line.806"></a> +<span class="sourceLineNo">745</span> protected Class<? extends HttpServlet> getDumpServlet() {<a name="line.745"></a> +<span class="sourceLineNo">746</span> return RSDumpServlet.class;<a name="line.746"></a> +<span class="sourceLineNo">747</span> }<a name="line.747"></a> +<span class="sourceLineNo">748</span><a name="line.748"></a> +<span class="sourceLineNo">749</span> @Override<a name="line.749"></a> +<span class="sourceLineNo">750</span> public boolean registerService(com.google.protobuf.Service instance) {<a name="line.750"></a> +<span class="sourceLineNo">751</span> /*<a name="line.751"></a> +<span class="sourceLineNo">752</span> * No stacking of instances is allowed for a single executorService name<a name="line.752"></a> +<span class="sourceLineNo">753</span> */<a name="line.753"></a> +<span class="sourceLineNo">754</span> com.google.protobuf.Descriptors.ServiceDescriptor serviceDesc =<a name="line.754"></a> +<span class="sourceLineNo">755</span> instance.getDescriptorForType();<a name="line.755"></a> +<span class="sourceLineNo">756</span> String serviceName = CoprocessorRpcUtils.getServiceName(serviceDesc);<a name="line.756"></a> +<span class="sourceLineNo">757</span> if (coprocessorServiceHandlers.containsKey(serviceName)) {<a name="line.757"></a> +<span class="sourceLineNo">758</span> LOG.error("Coprocessor executorService " + serviceName<a name="line.758"></a> +<span class="sourceLineNo">759</span> + " already registered, rejecting request from " + instance);<a name="line.759"></a> +<span class="sourceLineNo">760</span> return false;<a name="line.760"></a> +<span class="sourceLineNo">761</span> }<a name="line.761"></a> +<span class="sourceLineNo">762</span><a name="line.762"></a> +<span class="sourceLineNo">763</span> coprocessorServiceHandlers.put(serviceName, instance);<a name="line.763"></a> +<span class="sourceLineNo">764</span> if (LOG.isDebugEnabled()) {<a name="line.764"></a> +<span class="sourceLineNo">765</span> LOG.debug("Registered regionserver coprocessor executorService: executorService=" + serviceName);<a name="line.765"></a> +<span class="sourceLineNo">766</span> }<a name="line.766"></a> +<span class="sourceLineNo">767</span> return true;<a name="line.767"></a> +<span class="sourceLineNo">768</span> }<a name="line.768"></a> +<span class="sourceLineNo">769</span><a name="line.769"></a> +<span class="sourceLineNo">770</span> /**<a name="line.770"></a> +<span class="sourceLineNo">771</span> * Create a 'smarter' Connection, one that is capable of by-passing RPC if the request is to<a name="line.771"></a> +<span class="sourceLineNo">772</span> * the local server; i.e. a short-circuit Connection. Safe to use going to local or remote<a name="line.772"></a> +<span class="sourceLineNo">773</span> * server. Create this instance in a method can be intercepted and mocked in tests.<a name="line.773"></a> +<span class="sourceLineNo">774</span> * @throws IOException<a name="line.774"></a> +<span class="sourceLineNo">775</span> */<a name="line.775"></a> +<span class="sourceLineNo">776</span> @VisibleForTesting<a name="line.776"></a> +<span class="sourceLineNo">777</span> protected ClusterConnection createClusterConnection() throws IOException {<a name="line.777"></a> +<span class="sourceLineNo">778</span> Configuration conf = this.conf;<a name="line.778"></a> +<span class="sourceLineNo">779</span> if (conf.get(HConstants.CLIENT_ZOOKEEPER_QUORUM) != null) {<a name="line.779"></a> +<span class="sourceLineNo">780</span> // Use server ZK cluster for server-issued connections, so we clone<a name="line.780"></a> +<span class="sourceLineNo">781</span> // the conf and unset the client ZK related properties<a name="line.781"></a> +<span class="sourceLineNo">782</span> conf = new Configuration(this.conf);<a name="line.782"></a> +<span class="sourceLineNo">783</span> conf.unset(HConstants.CLIENT_ZOOKEEPER_QUORUM);<a name="line.783"></a> +<span class="sourceLineNo">784</span> }<a name="line.784"></a> +<span class="sourceLineNo">785</span> // Create a cluster connection that when appropriate, can short-circuit and go directly to the<a name="line.785"></a> +<span class="sourceLineNo">786</span> // local server if the request is to the local server bypassing RPC. Can be used for both local<a name="line.786"></a> +<span class="sourceLineNo">787</span> // and remote invocations.<a name="line.787"></a> +<span class="sourceLineNo">788</span> return ConnectionUtils.createShortCircuitConnection(conf, null, userProvider.getCurrent(),<a name="line.788"></a> +<span class="sourceLineNo">789</span> serverName, rpcServices, rpcServices);<a name="line.789"></a> +<span class="sourceLineNo">790</span> }<a name="line.790"></a> +<span class="sourceLineNo">791</span><a name="line.791"></a> +<span class="sourceLineNo">792</span> /**<a name="line.792"></a> +<span class="sourceLineNo">793</span> * Run test on configured codecs to make sure supporting libs are in place.<a name="line.793"></a> +<span class="sourceLineNo">794</span> * @param c<a name="line.794"></a> +<span class="sourceLineNo">795</span> * @throws IOException<a name="line.795"></a> +<span class="sourceLineNo">796</span> */<a name="line.796"></a> +<span class="sourceLineNo">797</span> private static void checkCodecs(final Configuration c) throws IOException {<a name="line.797"></a> +<span class="sourceLineNo">798</span> // check to see if the codec list is available:<a name="line.798"></a> +<span class="sourceLineNo">799</span> String [] codecs = c.getStrings("hbase.regionserver.codecs", (String[])null);<a name="line.799"></a> +<span class="sourceLineNo">800</span> if (codecs == null) return;<a name="line.800"></a> +<span class="sourceLineNo">801</span> for (String codec : codecs) {<a name="line.801"></a> +<span class="sourceLineNo">802</span> if (!CompressionTest.testCompression(codec)) {<a name="line.802"></a> +<span class="sourceLineNo">803</span> throw new IOException("Compression codec " + codec +<a name="line.803"></a> +<span class="sourceLineNo">804</span> " not supported, aborting RS construction");<a name="line.804"></a> +<span class="sourceLineNo">805</span> }<a name="line.805"></a> +<span class="sourceLineNo">806</span> }<a name="line.806"></a> <span class="sourceLineNo">807</span> }<a name="line.807"></a> <span class="sourceLineNo">808</span><a name="line.808"></a> -<span class="sourceLineNo">809</span> /**<a name="line.809"></a> -<span class="sourceLineNo">810</span> * Setup our cluster connection if not already initialized.<a name="line.810"></a> -<span class="sourceLineNo">811</span> * @throws IOException<a name="line.811"></a> -<span class="sourceLineNo">812</span> */<a name="line.812"></a> -<span class="sourceLineNo">813</span> protected synchronized void setupClusterConnection() throws IOException {<a name="line.813"></a> -<span class="sourceLineNo">814</span> if (clusterConnection == null) {<a name="line.814"></a> -<span class="sourceLineNo">815</span> clusterConnection = createClusterConnection();<a name="line.815"></a> -<span class="sourceLineNo">816</span> metaTableLocator = new MetaTableLocator();<a name="line.816"></a> -<span class="sourceLineNo">817</span> }<a name="line.817"></a> -<span class="sourceLineNo">818</span> }<a name="line.818"></a> -<span class="sourceLineNo">819</span><a name="line.819"></a> -<span class="sourceLineNo">820</span> /**<a name="line.820"></a> -<span class="sourceLineNo">821</span> * All initialization needed before we go register with Master.<br><a name="line.821"></a> -<span class="sourceLineNo">822</span> * Do bare minimum. Do bulk of initializations AFTER we've connected to the Master.<br><a name="line.822"></a> -<span class="sourceLineNo">823</span> * In here we just put up the RpcServer, setup Connection, and ZooKeeper.<a name="line.823"></a> -<span class="sourceLineNo">824</span> */<a name="line.824"></a> -<span class="sourceLineNo">825</span> private void preRegistrationInitialization() {<a name="line.825"></a> -<span class="sourceLineNo">826</span> try {<a name="line.826"></a> -<span class="sourceLineNo">827</span> initializeZooKeeper();<a name="line.827"></a> -<span class="sourceLineNo">828</span> setupClusterConnection();<a name="line.828"></a> -<span class="sourceLineNo">829</span> // Setup RPC client for master communication<a name="line.829"></a> -<span class="sourceLineNo">830</span> this.rpcClient = RpcClientFactory.createClient(conf, clusterId, new InetSocketAddress(<a name="line.830"></a> -<span class="sourceLineNo">831</span> this.rpcServices.isa.getAddress(), 0), clusterConnection.getConnectionMetrics());<a name="line.831"></a> -<span class="sourceLineNo">832</span> } catch (Throwable t) {<a name="line.832"></a> -<span class="sourceLineNo">833</span> // Call stop if error or process will stick around for ever since server<a name="line.833"></a> -<span class="sourceLineNo">834</span> // puts up non-daemon threads.<a name="line.834"></a> -<span class="sourceLineNo">835</span> this.rpcServices.stop();<a name="line.835"></a> -<span class="sourceLineNo">836</span> abort("Initialization of RS failed. Hence aborting RS.", t);<a name="line.836"></a> -<span class="sourceLineNo">837</span> }<a name="line.837"></a> -<span class="sourceLineNo">838</span> }<a name="line.838"></a> -<span class="sourceLineNo">839</span><a name="line.839"></a> -<span class="sourceLineNo">840</span> /**<a name="line.840"></a> -<span class="sourceLineNo">841</span> * Bring up connection to zk ensemble and then wait until a master for this cluster and then after<a name="line.841"></a> -<span class="sourceLineNo">842</span> * that, wait until cluster 'up' flag has been set. This is the order in which master does things.<a name="line.842"></a> -<span class="sourceLineNo">843</span> * <p><a name="line.843"></a> -<span class="sourceLineNo">844</span> * Finally open long-living server short-circuit connection.<a name="line.844"></a> -<span class="sourceLineNo">845</span> */<a name="line.845"></a> -<span class="sourceLineNo">846</span> @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE",<a name="line.846"></a> -<span class="sourceLineNo">847</span> justification="cluster Id znode read would give us correct response")<a name="line.847"></a> -<span class="sourceLineNo">848</span> private void initializeZooKeeper() throws IOException, InterruptedException {<a name="line.848"></a> -<span class="sourceLineNo">849</span> // Nothing to do in here if no Master in the mix.<a name="line.849"></a> -<span class="sourceLineNo">850</span> if (this.masterless) {<a name="line.850"></a> -<span class="sourceLineNo">851</span> return;<a name="line.851"></a> -<span class="sourceLineNo">852</span> }<a name="line.852"></a> -<span class="sourceLineNo">853</span><a name="line.853"></a> -<span class="sourceLineNo">854</span> // Create the master address tracker, register with zk, and start it. Then<a name="line.854"></a> -<span class="sourceLineNo">855</span> // block until a master is available. No point in starting up if no master<a name="line.855"></a> -<span class="sourceLineNo">856</span> // running.<a name="line.856"></a> -<span class="sourceLineNo">857</span> blockAndCheckIfStopped(this.masterAddressTracker);<a name="line.857"></a> -<span class="sourceLineNo">858</span><a name="line.858"></a> -<span class="sourceLineNo">859</span> // Wait on cluster being up. Master will set this flag up in zookeeper<a name="line.859"></a> -<span class="sourceLineNo">860</span> // when ready.<a name="line.860"></a> -<span class="sourceLineNo">861</span> blockAndCheckIfStopped(this.clusterStatusTracker);<a name="line.861"></a> +<span class="sourceLineNo">809</span> public String getClusterId() {<a name="line.809"></a> +<span class="sourceLineNo">810</span> return this.clusterId;<a name="line.810"></a> +<span class="sourceLineNo">811</span> }<a name="line.811"></a> +<span class="sourceLineNo">812</span><a name="line.812"></a> +<span class="sourceLineNo">813</span> /**<a name="line.813"></a> +<span class="sourceLineNo">814</span> * Setup our cluster connection if not already initialized.<a name="line.814"></a> +<span class="sourceLineNo">815</span> * @throws IOException<a name="line.815"></a> +<span class="sourceLineNo">816</span> */<a name="line.816"></a> +<span class="sourceLineNo">817</span> protected synchronized void setupClusterConnection() throws IOException {<a name="line.817"></a> +<span class="sourceLineNo">818</span> if (clusterConnection == null) {<a name="line.818"></a> +<span class="sourceLineNo">819</span> clusterConnection = createClusterConnection();<a name="line.819"></a> +<span class="sourceLineNo">820</span> metaTableLocator = new MetaTableLocator();<a name="line.820"></a> +<span class="sourceLineNo">821</span> }<a name="line.821"></a> +<span class="sourceLineNo">822</span> }<a name="line.822"></a> +<span class="sourceLineNo">823</span><a name="line.823"></a> +<span class="sourceLineNo">824</span> /**<a name="line.824"></a> +<span class="sourceLineNo">825</span> * All initialization needed before we go register with Master.<br><a name="line.825"></a> +<span class="sourceLineNo">826</span> * Do bare minimum. Do bulk of initializations AFTER we've connected to the Master.<br><a name="line.826"></a> +<span class="sourceLineNo">827</span> * In here we just put up the RpcServer, setup Connection, and ZooKeeper.<a name="line.827"></a> +<span class="sourceLineNo">828</span> */<a name="line.828"></a> +<span class="sourceLineNo">829</span> private void preRegistrationInitialization() {<a name="line.829"></a> +<span class="sourceLineNo">830</span> try {<a name="line.830"></a> +<span class="sourceLineNo">831</span> initializeZooKeeper();<a name="line.831"></a> +<span class="sourceLineNo">832</span> setupClusterConnection();<a name="line.832"></a> +<span class="sourceLineNo">833</span> // Setup RPC client for master communication<a name="line.833"></a> +<span class="sourceLineNo">834</span> this.rpcClient = RpcClientFactory.createClient(conf, clusterId, new InetSocketAddress(<a name="line.834"></a> +<span class="sourceLineNo">835</span> this.rpcServices.isa.getAddress(), 0), clusterConnection.getConnectionMetrics());<a name="line.835"></a> +<span class="sourceLineNo">836</span> } catch (Throwable t) {<a name="line.836"></a> +<span class="sourceLineNo">837</span> // Call stop if error or process will stick around for ever since server<a name="line.837"></a> +<span class="sourceLineNo">838</span> // puts up non-daemon threads.<a name="line.838"></a> +<span class="sourceLineNo">839</span> this.rpcServices.stop();<a name="line.839"></a> +<span class="sourceLineNo">840</span> abort("Initialization of RS failed. Hence aborting RS.", t);<a name="line.840"></a> +<span class="sourceLineNo">841</span> }<a name="line.841"></a> +<span class="sourceLineNo">842</span> }<a name="line.842"></a> +<span class="sourceLineNo">843</span><a name="line.843"></a> +<span class="sourceLineNo">844</span> /**<a name="line.844"></a> +<span class="sourceLineNo">845</span> * Bring up connection to zk ensemble and then wait until a master for this cluster and then after<a name="line.845"></a> +<span class="sourceLineNo">846</span> * that, wait until cluster 'up' flag has been set. This is the order in which master does things.<a name="line.846"></a> +<span class="sourceLineNo">847</span> * <p><a name="line.847"></a> +<span class="sourceLineNo">848</span> * Finally open long-living server short-circuit connection.<a name="line.848"></a> +<span class="sourceLineNo">849</span> */<a name="line.849"></a> +<span class="sourceLineNo">850</span> @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="RV_RETURN_VALUE_IGNORED_BAD_PRACTICE",<a name="line.850"></a> +<span class="sourceLineNo">851</span> justification="cluster Id znode read would give us correct response")<a name="line.851"></a> +<span class="sourceLineNo">852</span> private void initializeZooKeeper() throws IOException, InterruptedException {<a name="line.852"></a> +<span class="sourceLineNo">853</span> // Nothing to do in here if no Master in the mix.<a name="line.853"></a> +<span class="sourceLineNo">854</span> if (this.masterless) {<a name="line.854"></a> +<span class="sourceLineNo">855</span> return;<a name="line.855"></a> +<span class="sourceLineNo">856</span> }<a name="line.856"></a> +<span class="sourceLineNo">857</span><a name="line.857"></a> +<span class="sourceLineNo">858</span> // Create the master address tracker, register with zk, and start it. Then<a name="line.858"></a> +<span class="sourceLineNo">859</span> // block until a master is available. No point in starting up if no master<a name="line.859"></a> +<span class="sourceLineNo">860</span> // running.<a name="line.860"></a> +<span class="sourceLineNo">861</span> blockAndCheckIfStopped(this.masterAddressTracker);<a name="line.861"></a> <span class="sourceLineNo">862</span><a name="line.862"></a> -<span class="sourceLineNo">863</span> // If we are HMaster then the cluster id should have already been set.<a name="line.863"></a> -<span class="sourceLineNo">864</span> if (clusterId == null) {<a name="line.864"></a> -<span class="sourceLineNo">865</span> // Retrieve clusterId<a name="line.865"></a> -<span class="sourceLineNo">866</span> // Since cluster status is now up<a name="line.866"></a> -<span class="sourceLineNo">867</span> // ID should have already been set by HMaster<a name="line.867"></a> -<span class="sourceLineNo">868</span> try {<a name="line.868"></a> -<span class="sourceLineNo">869</span> clusterId = ZKClusterId.readClusterIdZNode(this.zooKeeper);<a name="line.869"></a> -<span class="sourceLineNo">870</span> if (clusterId == null) {<a name="line.870"></a> -<span class="sourceLineNo">871</span> this.abort("Cluster ID has not been set");<a name="line.871"></a> -<span class="sourceLineNo">872</span> }<a name="line.872"></a> -<span class="sourceLineNo">873</span> LOG.info("ClusterId : " + clusterId);<a name="line.873"></a> -<span class="sourceLineNo">874</span> } catch (KeeperException e) {<a name="line.874"></a> -<span class="sourceLineNo">875</span> this.abort("Failed to retrieve Cluster ID", e);<a name="line.875"></a> -<span class="sourceLineNo">876</span> }<a name="line.876"></a> -<span class="sourceLineNo">877</span> }<a name="line.877"></a> -<span class="sourceLineNo">878</span><a name="line.878"></a> -<span class="sourceLineNo">879</span> // In case colocated master, wait here till it's active.<a name="line.879"></a> -<span class="sourceLineNo">880</span> // So backup masters won't start as regionservers.<a name="line.880"></a> -<span class="sourceLineNo">881</span> // This is to avoid showing backup masters as regionservers<a name="line.881"></a> -<span class="sourceLineNo">882</span> // in master web UI, or assigning any region to them.<a name="line.882"></a> +<span class="sourceLineNo">863</span> // Wait on cluster being up. Master will set this flag up in zookeeper<a name="line.863"></a> +<span class="sourceLineNo">864</span> // when ready.<a name="line.864"></a> +<span class="sourceLineNo">865</span> blockAndCheckIfStopped(this.clusterStatusTracker);<a name="line.865"></a> +<span class="sourceLineNo">866</span><a name="line.866"></a> +<span class="sourceLineNo">867</span> // If we are HMaster then the cluster id should have already been set.<a name="line.867"></a> +<span class="sourceLineNo">868</span> if (clusterId == null) {<a name="line.868"></a> +<span class="sourceLineNo">869</span> // Retrieve clusterId<a name="line.869"></a> +<span class="sourceLineNo">870</span> // Since cluster status is now up<a name="line.870"></a> +<span class="sourceLineNo">871</span> // ID should have already been set by HMaster<a name="line.871"></a> +<span class="sourceLineNo">872</span> try {<a name="line.872"></a> +<span class="sourceLineNo">873</span> clusterId = ZKClusterId.readClusterIdZNode(this.zooKeeper);<a name="line.873"></a> +<span class="sourceLineNo">874</span> if (clusterId == null) {<a name="line.874"></a> +<span class="sourceLineNo">875</span> this.abort("Cluster ID has not been set");<a name="line.875"></a> +<span class="sourceLineNo">876</span> }<a name="line.876"></a> +<span class="sourceLineNo">877</span> LOG.info("ClusterId : " + clusterId);<a name="line.877"></a> +<span class="sourceLineNo">878</span> } catch (KeeperException e) {<a name="line.878"></a> +<span class="sourceLineNo">879</span> this.abort("Failed to retrieve Cluster ID", e);<a name="line.879"></a> +<span class="sourceLineNo">880</span> }<a name="line.880"></a> +<span class="sourceLineNo">881</span> }<a name="line.881"></a> +<span class="sourceLineNo">882</span><a name="line.882"></a> <span class="sourceLineNo">883</span> waitForMasterActive();<a name="line.883"></a> <span class="sourceLineNo">884</span> if (isStopped() || isAborted()) {<a name="line.884"></a> <span class="sourceLineNo">885</span> return; // No need for further initialization<a name="line.885"></a>