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.client; 019 020import org.apache.hadoop.hbase.TableName; 021import org.apache.yetus.audience.InterfaceAudience; 022 023/** 024 * The POJO equivalent of HBaseProtos.SnapshotDescription 025 */ 026@InterfaceAudience.Public 027public class SnapshotDescription { 028 private final String name; 029 private final TableName table; 030 private final SnapshotType snapShotType; 031 private final String owner; 032 private final long creationTime; 033 private final int version; 034 035 public SnapshotDescription(String name) { 036 this(name, (TableName)null); 037 } 038 039 /** 040 * @deprecated Use the version with the TableName instance instead 041 */ 042 @Deprecated 043 public SnapshotDescription(String name, String table) { 044 this(name, TableName.valueOf(table)); 045 } 046 047 public SnapshotDescription(String name, TableName table) { 048 this(name, table, SnapshotType.DISABLED, null); 049 } 050 051 /** 052 * @deprecated Use the version with the TableName instance instead 053 */ 054 @Deprecated 055 public SnapshotDescription(String name, String table, SnapshotType type) { 056 this(name, TableName.valueOf(table), type); 057 } 058 059 public SnapshotDescription(String name, TableName table, SnapshotType type) { 060 this(name, table, type, null); 061 } 062 063 /** 064 * @deprecated Use the version with the TableName instance instead 065 */ 066 @Deprecated 067 public SnapshotDescription(String name, String table, SnapshotType type, String owner) { 068 this(name, TableName.valueOf(table), type, owner); 069 } 070 071 public SnapshotDescription(String name, TableName table, SnapshotType type, String owner) { 072 this(name, table, type, owner, -1, -1); 073 } 074 075 /** 076 * @deprecated Use the version with the TableName instance instead 077 */ 078 @Deprecated 079 public SnapshotDescription(String name, String table, SnapshotType type, String owner, 080 long creationTime, int version) { 081 this(name, TableName.valueOf(table), type, owner, creationTime, version); 082 } 083 084 public SnapshotDescription(String name, TableName table, SnapshotType type, String owner, 085 long creationTime, int version) { 086 this.name = name; 087 this.table = table; 088 this.snapShotType = type; 089 this.owner = owner; 090 this.creationTime = creationTime; 091 this.version = version; 092 } 093 094 public String getName() { 095 return this.name; 096 } 097 098 /** 099 * @deprecated Use getTableName() or getTableNameAsString() instead. 100 */ 101 @Deprecated 102 public String getTable() { 103 return getTableNameAsString(); 104 } 105 106 public String getTableNameAsString() { 107 return this.table.getNameAsString(); 108 } 109 110 public TableName getTableName() { 111 return this.table; 112 } 113 114 public SnapshotType getType() { 115 return this.snapShotType; 116 } 117 118 public String getOwner() { 119 return this.owner; 120 } 121 122 public long getCreationTime() { 123 return this.creationTime; 124 } 125 126 public int getVersion() { 127 return this.version; 128 } 129 130 @Override 131 public String toString() { 132 return "SnapshotDescription: name = " + ((name != null) ? name : null) + "/table = " 133 + ((table != null) ? table : null) + " /owner = " + ((owner != null) ? owner : null) 134 + (creationTime != -1 ? ("/creationtime = " + creationTime) : "") 135 + (version != -1 ? ("/version = " + version) : ""); 136 } 137}