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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 package org
.apache
.hadoop
.hbase
.rsgroup
;
20 import java
.io
.IOException
;
21 import java
.util
.Optional
;
22 import org
.apache
.hadoop
.hbase
.TableName
;
23 import org
.apache
.hadoop
.hbase
.client
.TableDescriptor
;
24 import org
.apache
.hadoop
.hbase
.client
.TableDescriptorBuilder
;
25 import org
.apache
.hadoop
.hbase
.master
.procedure
.MasterProcedureEnv
;
26 import org
.apache
.hadoop
.hbase
.master
.procedure
.ModifyTableDescriptorProcedure
;
27 import org
.apache
.yetus
.audience
.InterfaceAudience
;
28 import org
.slf4j
.Logger
;
29 import org
.slf4j
.LoggerFactory
;
32 * Procedure for migrating rs group information to table descriptor.
34 @InterfaceAudience.Private
35 public class MigrateRSGroupProcedure
extends ModifyTableDescriptorProcedure
{
37 private static final Logger LOG
= LoggerFactory
.getLogger(MigrateRSGroupProcedure
.class);
39 public MigrateRSGroupProcedure() {
42 public MigrateRSGroupProcedure(MasterProcedureEnv env
, TableName tableName
) {
43 super(env
, tableName
);
47 protected Optional
<TableDescriptor
> modify(MasterProcedureEnv env
, TableDescriptor current
)
49 if (current
.getRegionServerGroup().isPresent()) {
50 // usually this means user has set the rs group using the new code which will set the group
51 // directly on table descriptor, skip.
52 LOG
.debug("Skip migrating {} since it is already in group {}", current
.getTableName(),
53 current
.getRegionServerGroup().get());
54 return Optional
.empty();
57 env
.getMasterServices().getRSGroupInfoManager().getRSGroupForTable(current
.getTableName());
59 LOG
.debug("RSGroup for table {} is empty when migrating, usually this should not happen" +
60 " unless we have removed the RSGroup, ignore...", current
.getTableName());
61 return Optional
.empty();
64 .of(TableDescriptorBuilder
.newBuilder(current
).setRegionServerGroup(group
.getName()).build());