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;
019
020import org.apache.yetus.audience.InterfaceAudience;
021
022/**
023 * A HBase ReplicationLoad to present MetricsSource information
024 */
025@InterfaceAudience.Public
026public final class ReplicationLoadSource {
027  private final String peerID;
028  private final long ageOfLastShippedOp;
029  private final int sizeOfLogQueue;
030  private final long timestampOfLastShippedOp;
031  private final long replicationLag;
032  private long timeStampOfNextToReplicate;
033  private String queueId;
034  private boolean recovered;
035  private boolean running;
036  private boolean editsSinceRestart;
037  private long editsRead;
038  private long oPsShipped;
039
040  @InterfaceAudience.Private
041  private ReplicationLoadSource(String id, long age, int size, long timestamp,
042    long timeStampOfNextToReplicate, long lag, String queueId, boolean recovered, boolean running,
043    boolean editsSinceRestart, long editsRead, long oPsShipped) {
044    this.peerID = id;
045    this.ageOfLastShippedOp = age;
046    this.sizeOfLogQueue = size;
047    this.timestampOfLastShippedOp = timestamp;
048    this.replicationLag = lag;
049    this.timeStampOfNextToReplicate = timeStampOfNextToReplicate;
050    this.queueId = queueId;
051    this.recovered = recovered;
052    this.running = running;
053    this.editsSinceRestart = editsSinceRestart;
054    this.editsRead = editsRead;
055    this.oPsShipped = oPsShipped;
056  }
057
058  public String getPeerID() {
059    return this.peerID;
060  }
061
062  public long getAgeOfLastShippedOp() {
063    return this.ageOfLastShippedOp;
064  }
065
066  public long getSizeOfLogQueue() {
067    return this.sizeOfLogQueue;
068  }
069
070  public long getTimestampOfLastShippedOp() {
071    return this.timestampOfLastShippedOp;
072  }
073
074  public long getReplicationLag() {
075    return this.replicationLag;
076  }
077
078  public long getTimeStampOfNextToReplicate() {
079    return this.timeStampOfNextToReplicate;
080  }
081
082  public String getQueueId() {
083    return queueId;
084  }
085
086  public boolean isRecovered() {
087    return recovered;
088  }
089
090  public boolean isRunning() {
091    return running;
092  }
093
094  public boolean hasEditsSinceRestart() {
095    return editsSinceRestart;
096  }
097
098  public long getEditsRead() {
099    return editsRead;
100  }
101
102  public long getOPsShipped() {
103    return oPsShipped;
104  }
105
106  public static ReplicationLoadSourceBuilder newBuilder() {
107    return new ReplicationLoadSourceBuilder();
108  }
109
110  public static final class ReplicationLoadSourceBuilder {
111
112    private String peerID;
113    private long ageOfLastShippedOp;
114    private int sizeOfLogQueue;
115    private long timestampOfLastShippedOp;
116    private long replicationLag;
117    private long timeStampOfNextToReplicate;
118    private String queueId;
119    private boolean recovered;
120    private boolean running;
121    private boolean editsSinceRestart;
122    private long editsRead;
123    private long oPsShipped;
124
125    private ReplicationLoadSourceBuilder() {
126
127    }
128
129    public ReplicationLoadSourceBuilder
130      setTimeStampOfNextToReplicate(long timeStampOfNextToReplicate) {
131      this.timeStampOfNextToReplicate = timeStampOfNextToReplicate;
132      return this;
133    }
134
135    public ReplicationLoadSourceBuilder setPeerID(String peerID) {
136      this.peerID = peerID;
137      return this;
138    }
139
140    public ReplicationLoadSourceBuilder setAgeOfLastShippedOp(long ageOfLastShippedOp) {
141      this.ageOfLastShippedOp = ageOfLastShippedOp;
142      return this;
143    }
144
145    public ReplicationLoadSourceBuilder setSizeOfLogQueue(int sizeOfLogQueue) {
146      this.sizeOfLogQueue = sizeOfLogQueue;
147      return this;
148    }
149
150    public ReplicationLoadSourceBuilder setTimestampOfLastShippedOp(long timestampOfLastShippedOp) {
151      this.timestampOfLastShippedOp = timestampOfLastShippedOp;
152      return this;
153    }
154
155    public ReplicationLoadSourceBuilder setReplicationLag(long replicationLag) {
156      this.replicationLag = replicationLag;
157      return this;
158    }
159
160    public ReplicationLoadSourceBuilder setQueueId(String queueId) {
161      this.queueId = queueId;
162      return this;
163    }
164
165    public ReplicationLoadSourceBuilder setRecovered(boolean recovered) {
166      this.recovered = recovered;
167      return this;
168    }
169
170    public ReplicationLoadSourceBuilder setRunning(boolean running) {
171      this.running = running;
172      return this;
173    }
174
175    public ReplicationLoadSourceBuilder setEditsSinceRestart(boolean editsSinceRestart) {
176      this.editsSinceRestart = editsSinceRestart;
177      return this;
178    }
179
180    public ReplicationLoadSourceBuilder setEditsRead(long editsRead) {
181      this.editsRead = editsRead;
182      return this;
183    }
184
185    public ReplicationLoadSourceBuilder setoPsShipped(long oPsShipped) {
186      this.oPsShipped = oPsShipped;
187      return this;
188    }
189
190    public ReplicationLoadSource build() {
191      return new ReplicationLoadSource(peerID, ageOfLastShippedOp, sizeOfLogQueue,
192        timestampOfLastShippedOp, timeStampOfNextToReplicate, replicationLag, queueId, recovered,
193        running, editsSinceRestart, editsRead, oPsShipped);
194    }
195  }
196}