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.hbase.TableName; 021import org.apache.yetus.audience.InterfaceAudience; 022 023import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; 024import org.apache.hadoop.hbase.shaded.protobuf.generated.BackupProtos; 025 026/** 027 * Backup related information encapsulated for a table. At this moment only target directory, 028 * snapshot name and table name are encapsulated here. 029 */ 030 031@InterfaceAudience.Private 032public class BackupTableInfo { 033 /* 034 * Table name for backup 035 */ 036 private TableName table; 037 038 /* 039 * Snapshot name for offline/online snapshot 040 */ 041 private String snapshotName = null; 042 043 public BackupTableInfo() { 044 } 045 046 public BackupTableInfo(TableName table, String targetRootDir, String backupId) { 047 this.table = table; 048 } 049 050 public String getSnapshotName() { 051 return snapshotName; 052 } 053 054 public void setSnapshotName(String snapshotName) { 055 this.snapshotName = snapshotName; 056 } 057 058 public TableName getTable() { 059 return table; 060 } 061 062 public static BackupTableInfo convert(BackupProtos.BackupTableInfo proto) { 063 BackupTableInfo bs = new BackupTableInfo(); 064 bs.table = ProtobufUtil.toTableName(proto.getTableName()); 065 if (proto.hasSnapshotName()) { 066 bs.snapshotName = proto.getSnapshotName(); 067 } 068 return bs; 069 } 070 071 public BackupProtos.BackupTableInfo toProto() { 072 BackupProtos.BackupTableInfo.Builder builder = BackupProtos.BackupTableInfo.newBuilder(); 073 if (snapshotName != null) { 074 builder.setSnapshotName(snapshotName); 075 } 076 builder.setTableName(ProtobufUtil.toProtoTableName(table)); 077 return builder.build(); 078 } 079}