001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.backup; 019 020import org.apache.hadoop.conf.Configuration; 021import org.apache.hadoop.hbase.backup.mapreduce.MapReduceBackupCopyJob; 022import org.apache.hadoop.hbase.backup.mapreduce.MapReduceBackupMergeJob; 023import org.apache.hadoop.hbase.backup.mapreduce.MapReduceRestoreJob; 024import org.apache.hadoop.util.ReflectionUtils; 025import org.apache.yetus.audience.InterfaceAudience; 026 027/** 028 * Factory implementation for backup/restore related jobs 029 */ 030@InterfaceAudience.Private 031public final class BackupRestoreFactory { 032 public final static String HBASE_INCR_RESTORE_IMPL_CLASS = "hbase.incremental.restore.class"; 033 public final static String HBASE_BACKUP_COPY_IMPL_CLASS = "hbase.backup.copy.class"; 034 public final static String HBASE_BACKUP_MERGE_IMPL_CLASS = "hbase.backup.merge.class"; 035 036 private BackupRestoreFactory() { 037 throw new AssertionError("Instantiating utility class..."); 038 } 039 040 /** 041 * Gets backup restore job 042 * @param conf configuration 043 * @return backup restore job instance 044 */ 045 public static RestoreJob getRestoreJob(Configuration conf) { 046 Class<? extends RestoreJob> cls = 047 conf.getClass(HBASE_INCR_RESTORE_IMPL_CLASS, MapReduceRestoreJob.class, RestoreJob.class); 048 RestoreJob service = ReflectionUtils.newInstance(cls, conf); 049 service.setConf(conf); 050 return service; 051 } 052 053 /** 054 * Gets backup copy job 055 * @param conf configuration 056 * @return backup copy job instance 057 */ 058 public static BackupCopyJob getBackupCopyJob(Configuration conf) { 059 Class<? extends BackupCopyJob> cls = conf.getClass(HBASE_BACKUP_COPY_IMPL_CLASS, 060 MapReduceBackupCopyJob.class, BackupCopyJob.class); 061 BackupCopyJob service = ReflectionUtils.newInstance(cls, conf); 062 service.setConf(conf); 063 return service; 064 } 065 066 /** 067 * Gets backup merge job 068 * @param conf configuration 069 * @return backup merge job instance 070 */ 071 public static BackupMergeJob getBackupMergeJob(Configuration conf) { 072 Class<? extends BackupMergeJob> cls = conf.getClass(HBASE_BACKUP_MERGE_IMPL_CLASS, 073 MapReduceBackupMergeJob.class, BackupMergeJob.class); 074 BackupMergeJob service = ReflectionUtils.newInstance(cls, conf); 075 service.setConf(conf); 076 return service; 077 } 078}