View Javadoc

1   /**
2    * Copyright 2010 The Apache Software Foundation
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  package org.apache.hadoop.hbase.master.handler;
21  
22  import java.io.IOException;
23  import java.util.List;
24  
25  import org.apache.hadoop.hbase.HRegionInfo;
26  import org.apache.hadoop.hbase.HTableDescriptor;
27  import org.apache.hadoop.hbase.Server;
28  import org.apache.hadoop.hbase.master.MasterServices;
29  
30  public class ModifyTableHandler extends TableEventHandler {
31    private final HTableDescriptor htd;
32  
33    public ModifyTableHandler(final byte [] tableName,
34        final HTableDescriptor htd, final Server server,
35        final MasterServices masterServices)
36    throws IOException {
37      super(EventType.C_M_MODIFY_TABLE, tableName, server, masterServices);
38      // Check table exists.
39      getTableDescriptor();
40      // This is the new schema we are going to write out as this modification.
41      this.htd = htd;
42    }
43  
44    @Override
45    protected void handleTableOperation(List<HRegionInfo> hris)
46    throws IOException {
47      // Update descriptor
48      this.masterServices.getTableDescriptors().add(this.htd);
49    }
50  
51    @Override
52    public String toString() {
53      String name = "UnknownServerName";
54      if(server != null && server.getServerName() != null) {
55        name = server.getServerName().toString();
56      }
57      return getClass().getSimpleName() + "-" + name + "-" + getSeqid() + "-" +
58        tableNameStr;
59    }
60  }