001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
003 * agreements. See the NOTICE file distributed with this work for additional information regarding
004 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
005 * "License"); you may not use this file except in compliance with the License. You may obtain a
006 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
007 * law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
008 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
009 * for the specific language governing permissions and limitations under the License.
010 */
011package org.apache.hadoop.hbase.replication;
012
013import org.apache.yetus.audience.InterfaceAudience;
014
015/**
016 * A HBase ReplicationLoad to present MetricsSource information
017 */
018@InterfaceAudience.Public
019public final class ReplicationLoadSource {
020  private final String peerID;
021  private final long ageOfLastShippedOp;
022  private final int sizeOfLogQueue;
023  private final long timestampOfLastShippedOp;
024  private final long replicationLag;
025  private long timeStampOfNextToReplicate;
026  private String queueId;
027  private boolean recovered;
028  private boolean running;
029  private boolean editsSinceRestart;
030  private long editsRead;
031  private long oPsShipped;
032
033  @InterfaceAudience.Private
034  private ReplicationLoadSource(String id, long age, int size, long timestamp,
035      long timeStampOfNextToReplicate, long lag, String queueId, boolean recovered, boolean running,
036      boolean editsSinceRestart, long editsRead, long oPsShipped) {
037    this.peerID = id;
038    this.ageOfLastShippedOp = age;
039    this.sizeOfLogQueue = size;
040    this.timestampOfLastShippedOp = timestamp;
041    this.replicationLag = lag;
042    this.timeStampOfNextToReplicate = timeStampOfNextToReplicate;
043    this.queueId = queueId;
044    this.recovered = recovered;
045    this.running = running;
046    this.editsSinceRestart = editsSinceRestart;
047    this.editsRead = editsRead;
048    this.oPsShipped = oPsShipped;
049  }
050
051  public String getPeerID() {
052    return this.peerID;
053  }
054
055  public long getAgeOfLastShippedOp() {
056    return this.ageOfLastShippedOp;
057  }
058
059  public long getSizeOfLogQueue() {
060    return this.sizeOfLogQueue;
061  }
062
063  public long getTimestampOfLastShippedOp() {
064    return this.timestampOfLastShippedOp;
065  }
066
067  public long getReplicationLag() {
068    return this.replicationLag;
069  }
070
071  public long getTimeStampOfNextToReplicate() {
072    return this.timeStampOfNextToReplicate;
073  }
074
075  public String getQueueId() {
076    return queueId;
077  }
078
079  public boolean isRecovered() {
080    return recovered;
081  }
082
083  public boolean isRunning() {
084    return running;
085  }
086
087  public boolean hasEditsSinceRestart() {
088    return editsSinceRestart;
089  }
090
091  public long getEditsRead() {
092    return editsRead;
093  }
094
095  public long getOPsShipped() {
096    return oPsShipped;
097  }
098
099  public static ReplicationLoadSourceBuilder newBuilder(){
100    return new ReplicationLoadSourceBuilder();
101  }
102
103  public static final class ReplicationLoadSourceBuilder {
104
105    private String peerID;
106    private long ageOfLastShippedOp;
107    private int sizeOfLogQueue;
108    private long timestampOfLastShippedOp;
109    private long replicationLag;
110    private long timeStampOfNextToReplicate;
111    private String queueId;
112    private boolean recovered;
113    private boolean running;
114    private boolean editsSinceRestart;
115    private long editsRead;
116    private long oPsShipped;
117
118    private ReplicationLoadSourceBuilder(){
119
120    }
121
122    public ReplicationLoadSourceBuilder setTimeStampOfNextToReplicate(
123        long timeStampOfNextToReplicate) {
124      this.timeStampOfNextToReplicate = timeStampOfNextToReplicate;
125      return this;
126    }
127
128    public ReplicationLoadSourceBuilder setPeerID(String peerID) {
129      this.peerID = peerID;
130      return this;
131    }
132
133    public ReplicationLoadSourceBuilder setAgeOfLastShippedOp(long ageOfLastShippedOp) {
134      this.ageOfLastShippedOp = ageOfLastShippedOp;
135      return this;
136    }
137
138    public ReplicationLoadSourceBuilder setSizeOfLogQueue(int sizeOfLogQueue) {
139      this.sizeOfLogQueue = sizeOfLogQueue;
140      return this;
141    }
142
143    public ReplicationLoadSourceBuilder setTimestampOfLastShippedOp(long timestampOfLastShippedOp) {
144      this.timestampOfLastShippedOp = timestampOfLastShippedOp;
145      return this;
146    }
147
148    public ReplicationLoadSourceBuilder setReplicationLag(long replicationLag) {
149      this.replicationLag = replicationLag;
150      return this;
151    }
152
153    public ReplicationLoadSourceBuilder setQueueId(String queueId) {
154      this.queueId = queueId;
155      return this;
156    }
157
158    public ReplicationLoadSourceBuilder setRecovered(boolean recovered) {
159      this.recovered = recovered;
160      return this;
161    }
162
163    public ReplicationLoadSourceBuilder setRunning(boolean running) {
164      this.running = running;
165      return this;
166    }
167
168    public ReplicationLoadSourceBuilder setEditsSinceRestart(boolean editsSinceRestart) {
169      this.editsSinceRestart = editsSinceRestart;
170      return this;
171    }
172
173    public ReplicationLoadSourceBuilder setEditsRead(long editsRead) {
174      this.editsRead = editsRead;
175      return this;
176    }
177
178    public ReplicationLoadSourceBuilder setoPsShipped(long oPsShipped) {
179      this.oPsShipped = oPsShipped;
180      return this;
181    }
182
183    public ReplicationLoadSource build(){
184      return new ReplicationLoadSource(peerID, ageOfLastShippedOp, sizeOfLogQueue,
185          timestampOfLastShippedOp, timeStampOfNextToReplicate, replicationLag, queueId, recovered,
186          running, editsSinceRestart, editsRead, oPsShipped);
187    }
188  }
189}