HBASE-26688 Threads shared EMPTY_RESULT may lead to unexpected client job down. ...
[hbase.git] / hbase-client / src / main / java / org / apache / hadoop / hbase / client / SnapshotDescription.java
blobbbc6a503a3e3a24c22ab3663ce2825d3fab76f1d
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase.client;
20 import java.util.Map;
22 import org.apache.commons.lang3.builder.ToStringBuilder;
23 import org.apache.hadoop.hbase.TableName;
24 import org.apache.yetus.audience.InterfaceAudience;
26 import org.apache.hbase.thirdparty.org.apache.commons.collections4.MapUtils;
28 /**
29 * The POJO equivalent of HBaseProtos.SnapshotDescription
31 @InterfaceAudience.Public
32 public class SnapshotDescription {
33 private final String name;
34 private final TableName table;
35 private final SnapshotType snapShotType;
36 private final String owner;
37 private final long creationTime;
38 private final long ttl;
39 private final int version;
41 private final long maxFileSize;
43 public SnapshotDescription(String name) {
44 this(name, null);
47 public SnapshotDescription(String name, TableName table) {
48 this(name, table, SnapshotType.DISABLED, null, -1, -1, null);
51 public SnapshotDescription(String name, TableName table, SnapshotType type) {
52 this(name, table, type, null, -1, -1, null);
55 public SnapshotDescription(String name, TableName table, SnapshotType type, String owner) {
56 this(name, table, type, owner, -1, -1, null);
59 /**
60 * SnapshotDescription Parameterized Constructor
62 * @param name Name of the snapshot
63 * @param table TableName associated with the snapshot
64 * @param type Type of the snapshot - enum SnapshotType
65 * @param owner Snapshot Owner
66 * @param creationTime Creation time for Snapshot
67 * @param version Snapshot Version
68 * @deprecated since 2.3.0 and will be removed in 4.0.0. Use
69 * {@link #SnapshotDescription(String, TableName, SnapshotType, String, long, int, Map)}
71 @Deprecated
72 public SnapshotDescription(String name, TableName table, SnapshotType type, String owner,
73 long creationTime, int version) {
74 this(name, table, type, owner, creationTime, version, null);
77 /**
78 * SnapshotDescription Parameterized Constructor
80 * @param name Name of the snapshot
81 * @param table TableName associated with the snapshot
82 * @param type Type of the snapshot - enum SnapshotType
83 * @param owner Snapshot Owner
84 * @param creationTime Creation time for Snapshot
85 * @param version Snapshot Version
86 * @param snapshotProps Additional properties for snapshot e.g. TTL
88 public SnapshotDescription(String name, TableName table, SnapshotType type, String owner,
89 long creationTime, int version, Map<String, Object> snapshotProps) {
90 this.name = name;
91 this.table = table;
92 this.snapShotType = type;
93 this.owner = owner;
94 this.creationTime = creationTime;
95 this.ttl = getLongFromSnapshotProps(snapshotProps, "TTL");
96 this.version = version;
97 this.maxFileSize = getLongFromSnapshotProps(snapshotProps, TableDescriptorBuilder.MAX_FILESIZE);
100 private long getLongFromSnapshotProps(Map<String, Object> snapshotProps, String property) {
101 return MapUtils.getLongValue(snapshotProps, property, -1);
107 * SnapshotDescription Parameterized Constructor
109 * @param snapshotName Name of the snapshot
110 * @param tableName TableName associated with the snapshot
111 * @param type Type of the snapshot - enum SnapshotType
112 * @param snapshotProps Additional properties for snapshot e.g. TTL
114 public SnapshotDescription(String snapshotName, TableName tableName, SnapshotType type,
115 Map<String, Object> snapshotProps) {
116 this(snapshotName, tableName, type, null, -1, -1, snapshotProps);
119 public String getName() {
120 return this.name;
123 public String getTableNameAsString() {
124 return this.table.getNameAsString();
127 public TableName getTableName() {
128 return this.table;
131 public SnapshotType getType() {
132 return this.snapShotType;
135 public String getOwner() {
136 return this.owner;
139 public long getCreationTime() {
140 return this.creationTime;
143 // get snapshot ttl in sec
144 public long getTtl() {
145 return ttl;
148 public int getVersion() {
149 return this.version;
152 public long getMaxFileSize() { return maxFileSize; }
154 @Override
155 public String toString() {
156 return new ToStringBuilder(this)
157 .append("name", name)
158 .append("table", table)
159 .append("snapShotType", snapShotType)
160 .append("owner", owner)
161 .append("creationTime", creationTime)
162 .append("ttl", ttl)
163 .append("version", version)
164 .append("maxFileSize", maxFileSize)
165 .toString();