View Javadoc

1   /**
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *     http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  package org.apache.hadoop.hbase.master;
20  
21  import java.io.IOException;
22  import java.io.InterruptedIOException;
23  import java.util.ArrayList;
24  import java.util.HashSet;
25  import java.util.List;
26  import java.util.Set;
27  import java.util.concurrent.locks.Lock;
28  import java.util.concurrent.locks.ReentrantLock;
29  
30  import org.apache.commons.logging.Log;
31  import org.apache.commons.logging.LogFactory;
32  import org.apache.hadoop.hbase.classification.InterfaceAudience;
33  import org.apache.hadoop.conf.Configuration;
34  import org.apache.hadoop.fs.FileStatus;
35  import org.apache.hadoop.fs.FileSystem;
36  import org.apache.hadoop.fs.Path;
37  import org.apache.hadoop.fs.PathFilter;
38  import org.apache.hadoop.hbase.ClusterId;
39  import org.apache.hadoop.hbase.HColumnDescriptor;
40  import org.apache.hadoop.hbase.HConstants;
41  import org.apache.hadoop.hbase.HRegionInfo;
42  import org.apache.hadoop.hbase.HTableDescriptor;
43  import org.apache.hadoop.hbase.InvalidFamilyOperationException;
44  import org.apache.hadoop.hbase.Server;
45  import org.apache.hadoop.hbase.ServerName;
46  import org.apache.hadoop.hbase.TableDescriptor;
47  import org.apache.hadoop.hbase.TableName;
48  import org.apache.hadoop.hbase.backup.HFileArchiver;
49  import org.apache.hadoop.hbase.client.TableState;
50  import org.apache.hadoop.hbase.exceptions.DeserializationException;
51  import org.apache.hadoop.hbase.fs.HFileSystem;
52  import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.SplitLogTask.RecoveryMode;
53  import org.apache.hadoop.hbase.regionserver.HRegion;
54  import org.apache.hadoop.hbase.wal.DefaultWALProvider;
55  import org.apache.hadoop.hbase.wal.WALSplitter;
56  import org.apache.hadoop.hbase.util.Bytes;
57  import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
58  import org.apache.hadoop.hbase.util.FSTableDescriptors;
59  import org.apache.hadoop.hbase.util.FSUtils;
60  import org.apache.hadoop.ipc.RemoteException;
61  
62  /**
63   * This class abstracts a bunch of operations the HMaster needs to interact with
64   * the underlying file system, including splitting log files, checking file
65   * system status, etc.
66   */
67  @InterfaceAudience.Private
68  public class MasterFileSystem {
69    private static final Log LOG = LogFactory.getLog(MasterFileSystem.class.getName());
70    // HBase configuration
71    Configuration conf;
72    // master status
73    Server master;
74    // metrics for master
75    private final MetricsMasterFileSystem metricsMasterFilesystem = new MetricsMasterFileSystem();
76    // Persisted unique cluster ID
77    private ClusterId clusterId;
78    // Keep around for convenience.
79    private final FileSystem fs;
80    // Is the fileystem ok?
81    private volatile boolean fsOk = true;
82    // The Path to the old logs dir
83    private final Path oldLogDir;
84    // root hbase directory on the FS
85    private final Path rootdir;
86    // hbase temp directory used for table construction and deletion
87    private final Path tempdir;
88    // create the split log lock
89    final Lock splitLogLock = new ReentrantLock();
90    final boolean distributedLogReplay;
91    final SplitLogManager splitLogManager;
92    private final MasterServices services;
93  
94    final static PathFilter META_FILTER = new PathFilter() {
95      @Override
96      public boolean accept(Path p) {
97        return DefaultWALProvider.isMetaFile(p);
98      }
99    };
100 
101   final static PathFilter NON_META_FILTER = new PathFilter() {
102     @Override
103     public boolean accept(Path p) {
104       return !DefaultWALProvider.isMetaFile(p);
105     }
106   };
107 
108   public MasterFileSystem(Server master, MasterServices services)
109   throws IOException {
110     this.conf = master.getConfiguration();
111     this.master = master;
112     this.services = services;
113     // Set filesystem to be that of this.rootdir else we get complaints about
114     // mismatched filesystems if hbase.rootdir is hdfs and fs.defaultFS is
115     // default localfs.  Presumption is that rootdir is fully-qualified before
116     // we get to here with appropriate fs scheme.
117     this.rootdir = FSUtils.getRootDir(conf);
118     this.tempdir = new Path(this.rootdir, HConstants.HBASE_TEMP_DIRECTORY);
119     // Cover both bases, the old way of setting default fs and the new.
120     // We're supposed to run on 0.20 and 0.21 anyways.
121     this.fs = this.rootdir.getFileSystem(conf);
122     FSUtils.setFsDefault(conf, new Path(this.fs.getUri()));
123     // make sure the fs has the same conf
124     fs.setConf(conf);
125     // setup the filesystem variable
126     // set up the archived logs path
127     this.oldLogDir = createInitialFileSystemLayout();
128     HFileSystem.addLocationsOrderInterceptor(conf);
129     this.splitLogManager =
130         new SplitLogManager(master, master.getConfiguration(), master, services,
131             master.getServerName());
132     this.distributedLogReplay = this.splitLogManager.isLogReplaying();
133   }
134 
135   /**
136    * Create initial layout in filesystem.
137    * <ol>
138    * <li>Check if the meta region exists and is readable, if not create it.
139    * Create hbase.version and the hbase:meta directory if not one.
140    * </li>
141    * <li>Create a log archive directory for RS to put archived logs</li>
142    * </ol>
143    * Idempotent.
144    */
145   private Path createInitialFileSystemLayout() throws IOException {
146     // check if the root directory exists
147     checkRootDir(this.rootdir, conf, this.fs);
148 
149     // check if temp directory exists and clean it
150     checkTempDir(this.tempdir, conf, this.fs);
151 
152     Path oldLogDir = new Path(this.rootdir, HConstants.HREGION_OLDLOGDIR_NAME);
153 
154     // Make sure the region servers can archive their old logs
155     if(!this.fs.exists(oldLogDir)) {
156       this.fs.mkdirs(oldLogDir);
157     }
158 
159     return oldLogDir;
160   }
161 
162   public FileSystem getFileSystem() {
163     return this.fs;
164   }
165 
166   /**
167    * Get the directory where old logs go
168    * @return the dir
169    */
170   public Path getOldLogDir() {
171     return this.oldLogDir;
172   }
173 
174   /**
175    * Checks to see if the file system is still accessible.
176    * If not, sets closed
177    * @return false if file system is not available
178    */
179   public boolean checkFileSystem() {
180     if (this.fsOk) {
181       try {
182         FSUtils.checkFileSystemAvailable(this.fs);
183         FSUtils.checkDfsSafeMode(this.conf);
184       } catch (IOException e) {
185         master.abort("Shutting down HBase cluster: file system not available", e);
186         this.fsOk = false;
187       }
188     }
189     return this.fsOk;
190   }
191 
192   /**
193    * @return HBase root dir.
194    */
195   public Path getRootDir() {
196     return this.rootdir;
197   }
198 
199   /**
200    * @return HBase temp dir.
201    */
202   public Path getTempDir() {
203     return this.tempdir;
204   }
205 
206   /**
207    * @return The unique identifier generated for this cluster
208    */
209   public ClusterId getClusterId() {
210     return clusterId;
211   }
212 
213   /**
214    * Inspect the log directory to find dead servers which need recovery work
215    * @return A set of ServerNames which aren't running but still have WAL files left in file system
216    */
217   Set<ServerName> getFailedServersFromLogFolders() {
218     boolean retrySplitting = !conf.getBoolean("hbase.hlog.split.skip.errors",
219         WALSplitter.SPLIT_SKIP_ERRORS_DEFAULT);
220 
221     Set<ServerName> serverNames = new HashSet<ServerName>();
222     Path logsDirPath = new Path(this.rootdir, HConstants.HREGION_LOGDIR_NAME);
223 
224     do {
225       if (master.isStopped()) {
226         LOG.warn("Master stopped while trying to get failed servers.");
227         break;
228       }
229       try {
230         if (!this.fs.exists(logsDirPath)) return serverNames;
231         FileStatus[] logFolders = FSUtils.listStatus(this.fs, logsDirPath, null);
232         // Get online servers after getting log folders to avoid log folder deletion of newly
233         // checked in region servers . see HBASE-5916
234         Set<ServerName> onlineServers = ((HMaster) master).getServerManager().getOnlineServers()
235             .keySet();
236 
237         if (logFolders == null || logFolders.length == 0) {
238           LOG.debug("No log files to split, proceeding...");
239           return serverNames;
240         }
241         for (FileStatus status : logFolders) {
242           final ServerName serverName = DefaultWALProvider.getServerNameFromWALDirectoryName(
243               status.getPath());
244           if (null == serverName) {
245             LOG.warn("Log folder " + status.getPath() + " doesn't look like its name includes a " +
246                 "region server name; leaving in place. If you see later errors about missing " +
247                 "write ahead logs they may be saved in this location.");
248           } else if (!onlineServers.contains(serverName)) {
249             LOG.info("Log folder " + status.getPath() + " doesn't belong "
250                 + "to a known region server, splitting");
251             serverNames.add(serverName);
252           } else {
253             LOG.info("Log folder " + status.getPath() + " belongs to an existing region server");
254           }
255         }
256         retrySplitting = false;
257       } catch (IOException ioe) {
258         LOG.warn("Failed getting failed servers to be recovered.", ioe);
259         if (!checkFileSystem()) {
260           LOG.warn("Bad Filesystem, exiting");
261           Runtime.getRuntime().halt(1);
262         }
263         try {
264           if (retrySplitting) {
265             Thread.sleep(conf.getInt("hbase.hlog.split.failure.retry.interval", 30 * 1000));
266           }
267         } catch (InterruptedException e) {
268           LOG.warn("Interrupted, aborting since cannot return w/o splitting");
269           Thread.currentThread().interrupt();
270           retrySplitting = false;
271           Runtime.getRuntime().halt(1);
272         }
273       }
274     } while (retrySplitting);
275 
276     return serverNames;
277   }
278 
279   public void splitLog(final ServerName serverName) throws IOException {
280     Set<ServerName> serverNames = new HashSet<ServerName>();
281     serverNames.add(serverName);
282     splitLog(serverNames);
283   }
284 
285   /**
286    * Specialized method to handle the splitting for meta WAL
287    * @param serverName
288    * @throws IOException
289    */
290   public void splitMetaLog(final ServerName serverName) throws IOException {
291     Set<ServerName> serverNames = new HashSet<ServerName>();
292     serverNames.add(serverName);
293     splitMetaLog(serverNames);
294   }
295 
296   /**
297    * Specialized method to handle the splitting for meta WAL
298    * @param serverNames
299    * @throws IOException
300    */
301   public void splitMetaLog(final Set<ServerName> serverNames) throws IOException {
302     splitLog(serverNames, META_FILTER);
303   }
304 
305   @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="UL_UNRELEASED_LOCK", justification=
306       "We only release this lock when we set it. Updates to code that uses it should verify use " +
307       "of the guard boolean.")
308   private List<Path> getLogDirs(final Set<ServerName> serverNames) throws IOException {
309     List<Path> logDirs = new ArrayList<Path>();
310     boolean needReleaseLock = false;
311     if (!this.services.isInitialized()) {
312       // during master initialization, we could have multiple places splitting a same wal
313       this.splitLogLock.lock();
314       needReleaseLock = true;
315     }
316     try {
317       for (ServerName serverName : serverNames) {
318         Path logDir = new Path(this.rootdir,
319             DefaultWALProvider.getWALDirectoryName(serverName.toString()));
320         Path splitDir = logDir.suffix(DefaultWALProvider.SPLITTING_EXT);
321         // Rename the directory so a rogue RS doesn't create more WALs
322         if (fs.exists(logDir)) {
323           if (!this.fs.rename(logDir, splitDir)) {
324             throw new IOException("Failed fs.rename for log split: " + logDir);
325           }
326           logDir = splitDir;
327           LOG.debug("Renamed region directory: " + splitDir);
328         } else if (!fs.exists(splitDir)) {
329           LOG.info("Log dir for server " + serverName + " does not exist");
330           continue;
331         }
332         logDirs.add(splitDir);
333       }
334     } finally {
335       if (needReleaseLock) {
336         this.splitLogLock.unlock();
337       }
338     }
339     return logDirs;
340   }
341 
342   /**
343    * Mark regions in recovering state when distributedLogReplay are set true
344    * @param serverName Failed region server whose wals to be replayed
345    * @param regions Set of regions to be recovered
346    * @throws IOException
347    */
348   public void prepareLogReplay(ServerName serverName, Set<HRegionInfo> regions) throws IOException {
349     if (!this.distributedLogReplay) {
350       return;
351     }
352     // mark regions in recovering state
353     if (regions == null || regions.isEmpty()) {
354       return;
355     }
356     this.splitLogManager.markRegionsRecovering(serverName, regions);
357   }
358 
359   public void splitLog(final Set<ServerName> serverNames) throws IOException {
360     splitLog(serverNames, NON_META_FILTER);
361   }
362 
363   /**
364    * Wrapper function on {@link SplitLogManager#removeStaleRecoveringRegions(Set)}
365    * @param failedServers
366    * @throws IOException
367    */
368   void removeStaleRecoveringRegionsFromZK(final Set<ServerName> failedServers)
369       throws IOException, InterruptedIOException {
370     this.splitLogManager.removeStaleRecoveringRegions(failedServers);
371   }
372 
373   /**
374    * This method is the base split method that splits WAL files matching a filter. Callers should
375    * pass the appropriate filter for meta and non-meta WALs.
376    * @param serverNames logs belonging to these servers will be split; this will rename the log
377    *                    directory out from under a soft-failed server
378    * @param filter
379    * @throws IOException
380    */
381   public void splitLog(final Set<ServerName> serverNames, PathFilter filter) throws IOException {
382     long splitTime = 0, splitLogSize = 0;
383     List<Path> logDirs = getLogDirs(serverNames);
384 
385     splitLogManager.handleDeadWorkers(serverNames);
386     splitTime = EnvironmentEdgeManager.currentTime();
387     splitLogSize = splitLogManager.splitLogDistributed(serverNames, logDirs, filter);
388     splitTime = EnvironmentEdgeManager.currentTime() - splitTime;
389 
390     if (this.metricsMasterFilesystem != null) {
391       if (filter == META_FILTER) {
392         this.metricsMasterFilesystem.addMetaWALSplit(splitTime, splitLogSize);
393       } else {
394         this.metricsMasterFilesystem.addSplit(splitTime, splitLogSize);
395       }
396     }
397   }
398 
399   /**
400    * Get the rootdir.  Make sure its wholesome and exists before returning.
401    * @param rd
402    * @param c
403    * @param fs
404    * @return hbase.rootdir (after checks for existence and bootstrapping if
405    * needed populating the directory with necessary bootup files).
406    * @throws IOException
407    */
408   @SuppressWarnings("deprecation")
409   private Path checkRootDir(final Path rd, final Configuration c,
410     final FileSystem fs)
411   throws IOException {
412     // If FS is in safe mode wait till out of it.
413     FSUtils.waitOnSafeMode(c, c.getInt(HConstants.THREAD_WAKE_FREQUENCY, 10 * 1000));
414     // Filesystem is good. Go ahead and check for hbase.rootdir.
415     try {
416       if (!fs.exists(rd)) {
417         fs.mkdirs(rd);
418         // DFS leaves safe mode with 0 DNs when there are 0 blocks.
419         // We used to handle this by checking the current DN count and waiting until
420         // it is nonzero. With security, the check for datanode count doesn't work --
421         // it is a privileged op. So instead we adopt the strategy of the jobtracker
422         // and simply retry file creation during bootstrap indefinitely. As soon as
423         // there is one datanode it will succeed. Permission problems should have
424         // already been caught by mkdirs above.
425         FSUtils.setVersion(fs, rd, c.getInt(HConstants.THREAD_WAKE_FREQUENCY,
426           10 * 1000), c.getInt(HConstants.VERSION_FILE_WRITE_ATTEMPTS,
427             HConstants.DEFAULT_VERSION_FILE_WRITE_ATTEMPTS));
428       } else {
429         if (!fs.isDirectory(rd)) {
430           throw new IllegalArgumentException(rd.toString() + " is not a directory");
431         }
432         // as above
433         FSUtils.checkVersion(fs, rd, true, c.getInt(HConstants.THREAD_WAKE_FREQUENCY,
434           10 * 1000), c.getInt(HConstants.VERSION_FILE_WRITE_ATTEMPTS,
435             HConstants.DEFAULT_VERSION_FILE_WRITE_ATTEMPTS));
436       }
437     } catch (DeserializationException de) {
438       LOG.fatal("Please fix invalid configuration for " + HConstants.HBASE_DIR, de);
439       IOException ioe = new IOException();
440       ioe.initCause(de);
441       throw ioe;
442     } catch (IllegalArgumentException iae) {
443       LOG.fatal("Please fix invalid configuration for "
444         + HConstants.HBASE_DIR + " " + rd.toString(), iae);
445       throw iae;
446     }
447     // Make sure cluster ID exists
448     if (!FSUtils.checkClusterIdExists(fs, rd, c.getInt(
449         HConstants.THREAD_WAKE_FREQUENCY, 10 * 1000))) {
450       FSUtils.setClusterId(fs, rd, new ClusterId(), c.getInt(HConstants.THREAD_WAKE_FREQUENCY, 10 * 1000));
451     }
452     clusterId = FSUtils.getClusterId(fs, rd);
453 
454     // Make sure the meta region directory exists!
455     if (!FSUtils.metaRegionExists(fs, rd)) {
456       bootstrap(rd, c);
457     } else {
458       // Migrate table descriptor files if necessary
459       org.apache.hadoop.hbase.util.FSTableDescriptorMigrationToSubdir
460         .migrateFSTableDescriptorsIfNecessary(fs, rd);
461     }
462 
463     // Create tableinfo-s for hbase:meta if not already there.
464     // assume, created table descriptor is for enabling table
465     // meta table is a system table, so descriptors are predefined,
466     // we should get them from registry.
467     FSTableDescriptors fsd = new FSTableDescriptors(c, fs, rd);
468     fsd.createTableDescriptor(
469         new TableDescriptor(fsd.get(TableName.META_TABLE_NAME), TableState.State.ENABLING));
470 
471     return rd;
472   }
473 
474   /**
475    * Make sure the hbase temp directory exists and is empty.
476    * NOTE that this method is only executed once just after the master becomes the active one.
477    */
478   private void checkTempDir(final Path tmpdir, final Configuration c, final FileSystem fs)
479       throws IOException {
480     // If the temp directory exists, clear the content (left over, from the previous run)
481     if (fs.exists(tmpdir)) {
482       // Archive table in temp, maybe left over from failed deletion,
483       // if not the cleaner will take care of them.
484       for (Path tabledir: FSUtils.getTableDirs(fs, tmpdir)) {
485         for (Path regiondir: FSUtils.getRegionDirs(fs, tabledir)) {
486           HFileArchiver.archiveRegion(fs, this.rootdir, tabledir, regiondir);
487         }
488       }
489       if (!fs.delete(tmpdir, true)) {
490         throw new IOException("Unable to clean the temp directory: " + tmpdir);
491       }
492     }
493 
494     // Create the temp directory
495     if (!fs.mkdirs(tmpdir)) {
496       throw new IOException("HBase temp directory '" + tmpdir + "' creation failure.");
497     }
498   }
499 
500   private static void bootstrap(final Path rd, final Configuration c)
501   throws IOException {
502     LOG.info("BOOTSTRAP: creating hbase:meta region");
503     try {
504       // Bootstrapping, make sure blockcache is off.  Else, one will be
505       // created here in bootstrap and it'll need to be cleaned up.  Better to
506       // not make it in first place.  Turn off block caching for bootstrap.
507       // Enable after.
508       HRegionInfo metaHRI = new HRegionInfo(HRegionInfo.FIRST_META_REGIONINFO);
509       HTableDescriptor metaDescriptor = new FSTableDescriptors(c).get(TableName.META_TABLE_NAME);
510       setInfoFamilyCachingForMeta(metaDescriptor, false);
511       HRegion meta = HRegion.createHRegion(metaHRI, rd, c, metaDescriptor);
512       setInfoFamilyCachingForMeta(metaDescriptor, true);
513       HRegion.closeHRegion(meta);
514     } catch (IOException e) {
515         e = e instanceof RemoteException ?
516                 ((RemoteException)e).unwrapRemoteException() : e;
517       LOG.error("bootstrap", e);
518       throw e;
519     }
520   }
521 
522   /**
523    * Enable in memory caching for hbase:meta
524    */
525   public static void setInfoFamilyCachingForMeta(HTableDescriptor metaDescriptor, final boolean b) {
526     for (HColumnDescriptor hcd: metaDescriptor.getColumnFamilies()) {
527       if (Bytes.equals(hcd.getName(), HConstants.CATALOG_FAMILY)) {
528         hcd.setBlockCacheEnabled(b);
529         hcd.setInMemory(b);
530       }
531     }
532   }
533 
534 
535   public void deleteRegion(HRegionInfo region) throws IOException {
536     HFileArchiver.archiveRegion(conf, fs, region);
537   }
538 
539   public void deleteTable(TableName tableName) throws IOException {
540     fs.delete(FSUtils.getTableDir(rootdir, tableName), true);
541   }
542 
543   /**
544    * Move the specified table to the hbase temp directory
545    * @param tableName Table name to move
546    * @return The temp location of the table moved
547    * @throws IOException in case of file-system failure
548    */
549   public Path moveTableToTemp(TableName tableName) throws IOException {
550     Path srcPath = FSUtils.getTableDir(rootdir, tableName);
551     Path tempPath = FSUtils.getTableDir(this.tempdir, tableName);
552 
553     // Ensure temp exists
554     if (!fs.exists(tempPath.getParent()) && !fs.mkdirs(tempPath.getParent())) {
555       throw new IOException("HBase temp directory '" + tempPath.getParent() + "' creation failure.");
556     }
557 
558     if (!fs.rename(srcPath, tempPath)) {
559       throw new IOException("Unable to move '" + srcPath + "' to temp '" + tempPath + "'");
560     }
561 
562     return tempPath;
563   }
564 
565   public void updateRegionInfo(HRegionInfo region) {
566     // TODO implement this.  i think this is currently broken in trunk i don't
567     //      see this getting updated.
568     //      @see HRegion.checkRegioninfoOnFilesystem()
569   }
570 
571   public void deleteFamilyFromFS(HRegionInfo region, byte[] familyName)
572       throws IOException {
573     // archive family store files
574     Path tableDir = FSUtils.getTableDir(rootdir, region.getTable());
575     HFileArchiver.archiveFamily(fs, conf, region, tableDir, familyName);
576 
577     // delete the family folder
578     Path familyDir = new Path(tableDir,
579       new Path(region.getEncodedName(), Bytes.toString(familyName)));
580     if (fs.delete(familyDir, true) == false) {
581       throw new IOException("Could not delete family "
582           + Bytes.toString(familyName) + " from FileSystem for region "
583           + region.getRegionNameAsString() + "(" + region.getEncodedName()
584           + ")");
585     }
586   }
587 
588   public void stop() {
589     if (splitLogManager != null) {
590       this.splitLogManager.stop();
591     }
592   }
593 
594   /**
595    * Delete column of a table
596    * @param tableName
597    * @param familyName
598    * @return Modified HTableDescriptor with requested column deleted.
599    * @throws IOException
600    */
601   public HTableDescriptor deleteColumn(TableName tableName, byte[] familyName)
602       throws IOException {
603     LOG.info("DeleteColumn. Table = " + tableName
604         + " family = " + Bytes.toString(familyName));
605     HTableDescriptor htd = this.services.getTableDescriptors().get(tableName);
606     htd.removeFamily(familyName);
607     this.services.getTableDescriptors().add(htd);
608     return htd;
609   }
610 
611   /**
612    * Modify Column of a table
613    * @param tableName
614    * @param hcd HColumnDesciptor
615    * @return Modified HTableDescriptor with the column modified.
616    * @throws IOException
617    */
618   public HTableDescriptor modifyColumn(TableName tableName, HColumnDescriptor hcd)
619       throws IOException {
620     LOG.info("AddModifyColumn. Table = " + tableName
621         + " HCD = " + hcd.toString());
622 
623     HTableDescriptor htd = this.services.getTableDescriptors().get(tableName);
624     byte [] familyName = hcd.getName();
625     if(!htd.hasFamily(familyName)) {
626       throw new InvalidFamilyOperationException("Family '" +
627         Bytes.toString(familyName) + "' doesn't exists so cannot be modified");
628     }
629     htd.modifyFamily(hcd);
630     this.services.getTableDescriptors().add(htd);
631     return htd;
632   }
633 
634   /**
635    * Add column to a table
636    * @param tableName
637    * @param hcd
638    * @return Modified HTableDescriptor with new column added.
639    * @throws IOException
640    */
641   public HTableDescriptor addColumn(TableName tableName, HColumnDescriptor hcd)
642       throws IOException {
643     LOG.info("AddColumn. Table = " + tableName + " HCD = " +
644       hcd.toString());
645     HTableDescriptor htd = this.services.getTableDescriptors().get(tableName);
646     if (htd == null) {
647       throw new InvalidFamilyOperationException("Family '" +
648         hcd.getNameAsString() + "' cannot be modified as HTD is null");
649     }
650     htd.addFamily(hcd);
651     this.services.getTableDescriptors().add(htd);
652     return htd;
653   }
654 
655   /**
656    * The function is used in SSH to set recovery mode based on configuration after all outstanding
657    * log split tasks drained.
658    * @throws IOException
659    */
660   public void setLogRecoveryMode() throws IOException {
661       this.splitLogManager.setRecoveryMode(false);
662   }
663 
664   public RecoveryMode getLogRecoveryMode() {
665     return this.splitLogManager.getRecoveryMode();
666   }
667 }