diff --git a/hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp b/hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp index 9b1328a3a32b..e85cab95d7e5 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/snapshot.jsp @@ -25,6 +25,7 @@ import="org.apache.hadoop.hbase.http.InfoServer" import="org.apache.hadoop.hbase.master.HMaster" import="org.apache.hadoop.hbase.snapshot.SnapshotInfo" + import="org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils" import="org.apache.hadoop.util.StringUtils" import="org.apache.hadoop.hbase.TableName" %> @@ -98,6 +99,7 @@ Type Format Version State + Expired @@ -124,6 +126,9 @@ <% } else { %> ok <% } %> + + <%= SnapshotDescriptionUtils.isExpiredSnapshot(snapshotTtl, snapshot.getCreationTime(), System.currentTimeMillis()) ? "Yes" : "No" %> +
diff --git a/hbase-server/src/main/resources/hbase-webapps/master/snapshotsStats.jsp b/hbase-server/src/main/resources/hbase-webapps/master/snapshotsStats.jsp index becdc68442db..6202d7409b5c 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/snapshotsStats.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/snapshotsStats.jsp @@ -26,6 +26,7 @@ import="org.apache.hadoop.fs.Path" import="org.apache.hadoop.hbase.master.HMaster" import="org.apache.hadoop.hbase.snapshot.SnapshotInfo" + import="org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils" import="org.apache.hadoop.hbase.TableName" import="org.apache.hadoop.util.StringUtils" import="org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription" @@ -68,6 +69,7 @@ Creation Time Owner TTL + Expired Shared Storefile Size Mob Storefile Size Archived Storefile Size @@ -94,6 +96,9 @@ .format(String.valueOf(snapshotDesc.getTtl()), PrettyPrinter.Unit.TIME_INTERVAL)%> <% } %> + + <%= SnapshotDescriptionUtils.isExpiredSnapshot(snapshotDesc.getTtl(), snapshotDesc.getCreationTime(), System.currentTimeMillis()) ? "Yes" : "No" %> + <%= StringUtils.humanReadableInt(stats.getSharedStoreFilesSize()) %> <%= StringUtils.humanReadableInt(stats.getMobStoreFilesSize()) %> <%= StringUtils.humanReadableInt(stats.getArchivedStoreFileSize()) %> diff --git a/hbase-server/src/main/resources/hbase-webapps/master/userSnapshots.jsp b/hbase-server/src/main/resources/hbase-webapps/master/userSnapshots.jsp index 0b741e1089fd..97cd477f6d8d 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/userSnapshots.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/userSnapshots.jsp @@ -20,6 +20,7 @@ <%@ page contentType="text/plain;charset=UTF-8" import="java.util.List" import="java.util.Date" + import="org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils" import="org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription" import="org.apache.hadoop.hbase.master.HMaster" import="org.apache.hadoop.hbase.TableName" @@ -38,6 +39,7 @@ Creation Time Owner TTL + Expired <% for (SnapshotDescription snapshotDesc : snapshots){ %> <% TableName snapshotTable = TableName.valueOf(snapshotDesc.getTable()); %> @@ -51,6 +53,9 @@ <%= snapshotDesc.getTtl() == 0 ? "FOREVER": PrettyPrinter.format(String.valueOf(snapshotDesc.getTtl()), PrettyPrinter.Unit.TIME_INTERVAL) %> + + <%= SnapshotDescriptionUtils.isExpiredSnapshot(snapshotDesc.getTtl(), snapshotDesc.getCreationTime(), System.currentTimeMillis()) ? "Yes" : "No" %> + <% } %>

<%= snapshots.size() %> snapshot(s) in set. [Snapshot Storefile stats]

diff --git a/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb b/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb index 6a173993654a..3b34cb993e60 100644 --- a/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb +++ b/hbase-shell/src/main/ruby/shell/commands/list_snapshots.rb @@ -18,6 +18,8 @@ require 'time' +java_import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils + module Shell module Commands class ListSnapshots < Command @@ -34,12 +36,25 @@ def help end def command(regex = '.*') - formatter.header(['SNAPSHOT', 'TABLE + CREATION TIME']) + formatter.header(['SNAPSHOT', 'TABLE + CREATION TIME + TTL(Sec)']) list = admin.list_snapshot(regex) list.each do |snapshot| creation_time = Time.at(snapshot.getCreationTime / 1000).to_s - formatter.row([snapshot.getName, snapshot.getTableNameAsString + ' (' + creation_time + ')']) + ttl = snapshot.getTtl + if ttl == 0 + ttl_info = 'FOREVER' + else + now_timestamp = (Time.now.to_f * 1000).to_i + expired = SnapshotDescriptionUtils.isExpiredSnapshot(ttl, snapshot.getCreationTime(), now_timestamp) + if expired + ttl_info = ttl.to_s + ' (Expired) ' + else + ttl_info = ttl.to_s + end + end + info = snapshot.getTableNameAsString + ' (' + creation_time + ') ' + ttl_info + formatter.row([snapshot.getName, info]) end formatter.footer(list.size)