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     */
018    package org.apache.hadoop.hdfs.protocol;
019    
020    import org.apache.hadoop.classification.InterfaceAudience;
021    import org.apache.hadoop.classification.InterfaceStability;
022    import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.FsPermissionProto;
023    import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot;
024    
025    /**
026     * SnapshotInfo maintains information for a snapshot
027     */
028    @InterfaceAudience.Private
029    @InterfaceStability.Evolving
030    public class SnapshotInfo {
031      private final String snapshotName;
032      private final String snapshotRoot;
033      private final String createTime;
034      private final FsPermissionProto permission;
035      private final String owner;
036      private final String group;
037    
038      public SnapshotInfo(String sname, String sroot, String ctime,
039          FsPermissionProto permission, String owner, String group) {
040        this.snapshotName = sname;
041        this.snapshotRoot = sroot;
042        this.createTime = ctime;
043        this.permission = permission;
044        this.owner = owner;
045        this.group = group;
046      }
047    
048      final public String getSnapshotName() {
049        return snapshotName;
050      }
051    
052      final public String getSnapshotRoot() {
053        return snapshotRoot;
054      }
055    
056      final public String getCreateTime() {
057        return createTime;
058      }
059      
060      final public FsPermissionProto getPermission() {
061        return permission;
062      }
063      
064      final public String getOwner() {
065        return owner;
066      }
067      
068      final public String getGroup() {
069        return group;
070      }
071      
072      @Override
073      public String toString() {
074        return getClass().getSimpleName()
075            + "{snapshotName=" + snapshotName
076            + "; snapshotRoot=" + snapshotRoot
077            + "; createTime=" + createTime
078            + "; permission=" + permission
079            + "; owner=" + owner
080            + "; group=" + group
081            + "}";
082      }
083    
084      public static class Bean {
085        private final String snapshotID;
086        private final String snapshotDirectory;
087        private final long modificationTime;
088    
089        public Bean(String snapshotID, String snapshotDirectory,
090            long modificationTime) {
091          this.snapshotID = snapshotID;
092          this.snapshotDirectory = snapshotDirectory;
093          this.modificationTime = modificationTime;
094        }
095    
096        public String getSnapshotID() {
097          return snapshotID;
098        }
099    
100        public String getSnapshotDirectory() {
101          return snapshotDirectory;
102        }
103    
104        public long getModificationTime() {
105          return modificationTime;
106        }
107      }
108    }