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.hdfs.server.datanode;
019
020import java.io.File;
021
022import org.apache.hadoop.hdfs.protocol.Block;
023import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.ReplicaState;
024import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi;
025
026/**
027 * This class describes a replica that has been finalized.
028 */
029public class FinalizedReplica extends ReplicaInfo {
030
031  /**
032   * Constructor
033   * @param blockId block id
034   * @param len replica length
035   * @param genStamp replica generation stamp
036   * @param vol volume where replica is located
037   * @param dir directory path where block and meta files are located
038   */
039  public FinalizedReplica(long blockId, long len, long genStamp,
040      FsVolumeSpi vol, File dir) {
041    super(blockId, len, genStamp, vol, dir);
042  }
043  
044  /**
045   * Constructor
046   * @param block a block
047   * @param vol volume where replica is located
048   * @param dir directory path where block and meta files are located
049   */
050  public FinalizedReplica(Block block, FsVolumeSpi vol, File dir) {
051    super(block, vol, dir);
052  }
053
054  /**
055   * Copy constructor.
056   * @param from where to copy construct from
057   */
058  public FinalizedReplica(FinalizedReplica from) {
059    super(from);
060  }
061
062  @Override  // ReplicaInfo
063  public ReplicaState getState() {
064    return ReplicaState.FINALIZED;
065  }
066  
067  @Override
068  public long getVisibleLength() {
069    return getNumBytes();       // all bytes are visible
070  }
071
072  @Override
073  public long getBytesOnDisk() {
074    return getNumBytes();
075  }
076
077  @Override  // Object
078  public boolean equals(Object o) {
079    return super.equals(o);
080  }
081  
082  @Override  // Object
083  public int hashCode() {
084    return super.hashCode();
085  }
086  
087  @Override
088  public String toString() {
089    return super.toString();
090  }
091}