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.hbase.replication.regionserver;
019
020import org.apache.hadoop.fs.Path;
021import org.apache.yetus.audience.InterfaceAudience;
022
023@InterfaceAudience.Private
024public final class ReplicationStatus {
025  private final String peerId;
026  private final String walGroup;
027  private final Path currentPath;
028  private final int queueSize;
029  private final long ageOfLastShippedOp;
030  private final long replicationDelay;
031  private final long currentPosition;
032  private final long fileSize;
033
034  private ReplicationStatus(ReplicationStatusBuilder builder) {
035    this.peerId = builder.peerId;
036    this.walGroup = builder.walGroup;
037    this.currentPath = builder.currentPath;
038    this.queueSize = builder.queueSize;
039    this.ageOfLastShippedOp = builder.ageOfLastShippedOp;
040    this.replicationDelay = builder.replicationDelay;
041    this.currentPosition = builder.currentPosition;
042    this.fileSize = builder.fileSize;
043  }
044
045  public long getCurrentPosition() {
046    return currentPosition;
047  }
048
049  public long getFileSize() {
050    return fileSize;
051  }
052
053  public String getPeerId() {
054    return peerId;
055  }
056
057  public String getWalGroup() {
058    return walGroup;
059  }
060
061  public int getQueueSize() {
062    return queueSize;
063  }
064
065  public long getAgeOfLastShippedOp() {
066    return ageOfLastShippedOp;
067  }
068
069  public long getReplicationDelay() {
070    return replicationDelay;
071  }
072
073  public Path getCurrentPath() {
074    return currentPath;
075  }
076
077  public static ReplicationStatusBuilder newBuilder() {
078    return new ReplicationStatusBuilder();
079  }
080
081  public static class ReplicationStatusBuilder {
082    private String peerId = "UNKNOWN";
083    private String walGroup = "UNKNOWN";
084    private Path currentPath = new Path("UNKNOWN");
085    private int queueSize = -1;
086    private long ageOfLastShippedOp = -1;
087    private long replicationDelay = -1;
088    private long currentPosition = -1;
089    private long fileSize = -1;
090
091    public ReplicationStatusBuilder withPeerId(String peerId) {
092      this.peerId = peerId;
093      return this;
094    }
095
096    public ReplicationStatusBuilder withFileSize(long fileSize) {
097      this.fileSize = fileSize;
098      return this;
099    }
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}