View Javadoc

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.hbase.replication.regionserver;
19  
20  import org.apache.hadoop.fs.Path;
21  import org.apache.hadoop.hbase.classification.InterfaceAudience;
22  
23  @InterfaceAudience.Private
24  public final class ReplicationStatus {
25    private final String peerId;
26    private final String walGroup;
27    private final Path currentPath;
28    private final int queueSize;
29    private final long ageOfLastShippedOp;
30    private final long replicationDelay;
31    private final long currentPosition;
32    private final long fileSize;
33  
34    private ReplicationStatus(ReplicationStatusBuilder builder) {
35      this.peerId = builder.peerId;
36      this.walGroup = builder.walGroup;
37      this.currentPath = builder.currentPath;
38      this.queueSize = builder.queueSize;
39      this.ageOfLastShippedOp = builder.ageOfLastShippedOp;
40      this.replicationDelay = builder.replicationDelay;
41      this.currentPosition = builder.currentPosition;
42      this.fileSize = builder.fileSize;
43    }
44  
45    public long getCurrentPosition() {
46      return currentPosition;
47    }
48  
49    public long getFileSize() {
50      return fileSize;
51    }
52  
53    public String getPeerId() {
54      return peerId;
55    }
56  
57    public String getWalGroup() {
58      return walGroup;
59    }
60  
61    public int getQueueSize() {
62      return queueSize;
63    }
64  
65    public long getAgeOfLastShippedOp() {
66      return ageOfLastShippedOp;
67    }
68  
69    public long getReplicationDelay() {
70      return replicationDelay;
71    }
72  
73    public Path getCurrentPath() {
74      return currentPath;
75    }
76  
77    public static ReplicationStatusBuilder newBuilder() {
78      return new ReplicationStatusBuilder();
79    }
80  
81    public static class ReplicationStatusBuilder {
82      private String peerId = "UNKNOWN";
83      private String walGroup = "UNKNOWN";
84      private Path currentPath = new Path("UNKNOWN");
85      private int queueSize = -1;
86      private long ageOfLastShippedOp = -1;
87      private long replicationDelay = -1;
88      private long currentPosition = -1;
89      private long fileSize = -1;
90  
91      public ReplicationStatusBuilder withPeerId(String peerId) {
92        this.peerId = peerId;
93        return this;
94      }
95  
96      public ReplicationStatusBuilder withFileSize(long fileSize) {
97        this.fileSize = fileSize;
98        return this;
99      }
100 
101     public ReplicationStatusBuilder withWalGroup(String walGroup) {
102       this.walGroup = walGroup;
103       return this;
104     }
105 
106     public ReplicationStatusBuilder withCurrentPath(Path currentPath) {
107       this.currentPath = currentPath;
108       return this;
109     }
110 
111     public ReplicationStatusBuilder withQueueSize(int queueSize) {
112       this.queueSize = queueSize;
113       return this;
114     }
115 
116     public ReplicationStatusBuilder withAgeOfLastShippedOp(long ageOfLastShippedOp) {
117       this.ageOfLastShippedOp = ageOfLastShippedOp;
118       return this;
119     }
120 
121     public ReplicationStatusBuilder withReplicationDelay(long replicationDelay) {
122       this.replicationDelay = replicationDelay;
123       return this;
124     }
125 
126     public ReplicationStatusBuilder withCurrentPosition(long currentPosition) {
127       this.currentPosition = currentPosition;
128       return this;
129     }
130 
131     public ReplicationStatus build() {
132       return new ReplicationStatus(this);
133     }
134   }
135 }