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
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  */
18 package org.apache.hadoop.hdfs.protocol;
19 
20 import org.apache.hadoop.classification.InterfaceAudience;
21 import org.apache.hadoop.classification.InterfaceStability;
22 import org.apache.hadoop.fs.StorageType;
23 import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
24 
25 @InterfaceAudience.Private
26 @InterfaceStability.Evolving
27 public class DatanodeInfoWithStorage extends DatanodeInfo {
28   private final String storageID;
29   private final StorageType storageType;
30 
DatanodeInfoWithStorage(DatanodeInfo from, String storageID, StorageType storageType)31   public DatanodeInfoWithStorage(DatanodeInfo from, String storageID,
32                                  StorageType storageType) {
33     super(from);
34     this.storageID = storageID;
35     this.storageType = storageType;
36     setSoftwareVersion(from.getSoftwareVersion());
37     setDependentHostNames(from.getDependentHostNames());
38     setLevel(from.getLevel());
39     setParent(from.getParent());
40   }
41 
getStorageID()42   public String getStorageID() {
43     return storageID;
44   }
45 
getStorageType()46   public StorageType getStorageType() {
47     return storageType;
48   }
49 
50   @Override
equals(Object o)51   public boolean equals(Object o) {
52     // allows this class to be used interchangeably with DatanodeInfo
53     return super.equals(o);
54   }
55 
56   @Override
hashCode()57   public int hashCode() {
58     // allows this class to be used interchangeably with DatanodeInfo
59     return super.hashCode();
60   }
61 
62   @Override
toString()63   public String toString() {
64     return "DatanodeInfoWithStorage[" + super.toString() + "," + storageID +
65         "," + storageType + "]";
66   }
67 }
68