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 since 2.0.0 and will be removed in 3.0.0. Use the version with the TableName
041   *   instance instead.
042   * @see #SnapshotDescription(String, TableName)
043   * @see <a href="https://issues.apache.org/jira/browse/HBASE-16892">HBASE-16892</a>
044   */
045  @Deprecated
046  public SnapshotDescription(String name, String table) {
047    this(name, TableName.valueOf(table));
048  }
049
050  public SnapshotDescription(String name, TableName table) {
051    this(name, table, SnapshotType.DISABLED, null);
052  }
053
054  /**
055   * @deprecated since 2.0.0 and will be removed in 3.0.0. Use the version with the TableName
056   *   instance instead.
057   * @see #SnapshotDescription(String, TableName, SnapshotType)
058   * @see <a href="https://issues.apache.org/jira/browse/HBASE-16892">HBASE-16892</a>
059   */
060  @Deprecated
061  public SnapshotDescription(String name, String table, SnapshotType type) {
062    this(name, TableName.valueOf(table), type);
063  }
064
065  public SnapshotDescription(String name, TableName table, SnapshotType type) {
066    this(name, table, type, null);
067  }
068
069  /**
070   * @deprecated since 2.0.0 and will be removed in 3.0.0. Use the version with the TableName
071   *   instance instead.
072   * @see #SnapshotDescription(String, TableName, SnapshotType, String)
073   * @see <a href="https://issues.apache.org/jira/browse/HBASE-16892">HBASE-16892</a>
074   */
075  @Deprecated
076  public SnapshotDescription(String name, String table, SnapshotType type, String owner) {
077    this(name, TableName.valueOf(table), type, owner);
078  }
079
080  public SnapshotDescription(String name, TableName table, SnapshotType type, String owner) {
081    this(name, table, type, owner, -1, -1);
082  }
083
084  /**
085   * @deprecated since 2.0.0 and will be removed in 3.0.0. Use the version with the TableName
086   *   instance instead.
087   * @see #SnapshotDescription(String, TableName, SnapshotType, String, long, int)
088   * @see <a href="https://issues.apache.org/jira/browse/HBASE-16892">HBASE-16892</a>
089   */
090  @Deprecated
091  public SnapshotDescription(String name, String table, SnapshotType type, String owner,
092      long creationTime, int version) {
093    this(name, TableName.valueOf(table), type, owner, creationTime, version);
094  }
095
096  public SnapshotDescription(String name, TableName table, SnapshotType type, String owner,
097      long creationTime, int version) {
098    this.name = name;
099    this.table = table;
100    this.snapShotType = type;
101    this.owner = owner;
102    this.creationTime = creationTime;
103    this.version = version;
104  }
105
106  public String getName() {
107    return this.name;
108  }
109
110  /**
111   * @deprecated since 2.0.0 and will be removed in 3.0.0. Use {@link #getTableName()} or
112   *   {@link #getTableNameAsString()} instead.
113   * @see #getTableName()
114   * @see #getTableNameAsString()
115   * @see <a href="https://issues.apache.org/jira/browse/HBASE-16892">HBASE-16892</a>
116   */
117  @Deprecated
118  public String getTable() {
119    return getTableNameAsString();
120  }
121
122  public String getTableNameAsString() {
123    return this.table.getNameAsString();
124  }
125
126  public TableName getTableName() {
127    return this.table;
128  }
129
130  public SnapshotType getType() {
131    return this.snapShotType;
132  }
133
134  public String getOwner() {
135    return this.owner;
136  }
137
138  public long getCreationTime() {
139    return this.creationTime;
140  }
141
142  public int getVersion() {
143    return this.version;
144  }
145
146  @Override
147  public String toString() {
148    return "SnapshotDescription: name = " + ((name != null) ? name : null) + "/table = "
149        + ((table != null) ? table : null) + " /owner = " + ((owner != null) ? owner : null)
150        + (creationTime != -1 ? ("/creationtime = " + creationTime) : "")
151        + (version != -1 ? ("/version = " + version) : "");
152  }
153}