View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.hadoop.hbase.coordination;
19  
20  import org.apache.hadoop.hbase.classification.InterfaceAudience;
21  import org.apache.hadoop.hbase.HRegionInfo;
22  import org.apache.hadoop.hbase.ServerName;
23  import org.apache.hadoop.hbase.protobuf.generated.AdminProtos;
24  import org.apache.hadoop.hbase.regionserver.HRegion;
25  
26  /**
27   * Coordinated operations for close region handlers.
28   */
29  @InterfaceAudience.Private
30  public interface CloseRegionCoordination {
31  
32    /**
33     * Called before actual region closing to check that we can do close operation
34     * on this region.
35     * @param regionInfo region being closed
36     * @param crd details about closing operation
37     * @return true if caller shall proceed and close, false if need to abort closing.
38     */
39    boolean checkClosingState(HRegionInfo regionInfo, CloseRegionDetails crd);
40  
41    /**
42     * Called after region is closed to notify all interesting parties / "register"
43     * region as finally closed.
44     * @param region region being closed
45     * @param sn ServerName on which task runs
46     * @param crd details about closing operation
47     */
48    void setClosedState(HRegion region, ServerName sn, CloseRegionDetails crd);
49  
50    /**
51     * Construct CloseRegionDetails instance from CloseRegionRequest.
52     * @return instance of CloseRegionDetails
53     */
54    CloseRegionDetails parseFromProtoRequest(AdminProtos.CloseRegionRequest request);
55  
56    /**
57     * Get details object with params for case when we're closing on
58     * regionserver side internally (not because of RPC call from master),
59     * so we don't parse details from protobuf request.
60     */
61    CloseRegionDetails getDetaultDetails();
62  
63    /**
64     * Marker interface for region closing tasks. Used to carry implementation details in
65     * encapsulated way through Handlers to the consensus API.
66     */
67    static interface CloseRegionDetails {
68    }
69  }