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.server.blockmanagement;
19 
20 /**
21  * A immutable object that stores the number of live replicas and
22  * the number of decommissined Replicas.
23  */
24 public class NumberReplicas {
25   private int liveReplicas;
26   private int decommissionedReplicas;
27   private int corruptReplicas;
28   private int excessReplicas;
29   private int replicasOnStaleNodes;
30 
NumberReplicas()31   NumberReplicas() {
32     initialize(0, 0, 0, 0, 0);
33   }
34 
NumberReplicas(int live, int decommissioned, int corrupt, int excess, int stale)35   NumberReplicas(int live, int decommissioned, int corrupt, int excess, int stale) {
36     initialize(live, decommissioned, corrupt, excess, stale);
37   }
38 
initialize(int live, int decommissioned, int corrupt, int excess, int stale)39   void initialize(int live, int decommissioned, int corrupt, int excess, int stale) {
40     liveReplicas = live;
41     decommissionedReplicas = decommissioned;
42     corruptReplicas = corrupt;
43     excessReplicas = excess;
44     replicasOnStaleNodes = stale;
45   }
46 
liveReplicas()47   public int liveReplicas() {
48     return liveReplicas;
49   }
decommissionedReplicas()50   public int decommissionedReplicas() {
51     return decommissionedReplicas;
52   }
corruptReplicas()53   public int corruptReplicas() {
54     return corruptReplicas;
55   }
excessReplicas()56   public int excessReplicas() {
57     return excessReplicas;
58   }
59 
60   /**
61    * @return the number of replicas which are on stale nodes.
62    * This is not mutually exclusive with the other counts -- ie a
63    * replica may count as both "live" and "stale".
64    */
replicasOnStaleNodes()65   public int replicasOnStaleNodes() {
66     return replicasOnStaleNodes;
67   }
68 }
69