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 /** 071 * @deprecated Since 2.0.0. Will be removed in 3.0.0. 072 * @see #getTimestampOfLastShippedOp() 073 */ 074 @Deprecated 075 public long getTimeStampOfLastShippedOp() { 076 return getTimestampOfLastShippedOp(); 077 } 078 079 public long getTimestampOfLastShippedOp() { 080 return this.timestampOfLastShippedOp; 081 } 082 083 public long getReplicationLag() { 084 return this.replicationLag; 085 } 086 087 public long getTimeStampOfNextToReplicate() { 088 return this.timeStampOfNextToReplicate; 089 } 090 091 public String getQueueId() { 092 return queueId; 093 } 094 095 public boolean isRecovered() { 096 return recovered; 097 } 098 099 public boolean isRunning() { 100 return running; 101 } 102 103 public boolean hasEditsSinceRestart() { 104 return editsSinceRestart; 105 } 106 107 public long getEditsRead() { 108 return editsRead; 109 } 110 111 public long getOPsShipped() { 112 return oPsShipped; 113 } 114 115 public static ReplicationLoadSourceBuilder newBuilder() { 116 return new ReplicationLoadSourceBuilder(); 117 } 118 119 public static final class ReplicationLoadSourceBuilder { 120 121 private String peerID; 122 private long ageOfLastShippedOp; 123 private int sizeOfLogQueue; 124 private long timestampOfLastShippedOp; 125 private long replicationLag; 126 private long timeStampOfNextToReplicate; 127 private String queueId; 128 private boolean recovered; 129 private boolean running; 130 private boolean editsSinceRestart; 131 private long editsRead; 132 private long oPsShipped; 133 134 private ReplicationLoadSourceBuilder() { 135 136 } 137 138 public ReplicationLoadSourceBuilder 139 setTimeStampOfNextToReplicate(long timeStampOfNextToReplicate) { 140 this.timeStampOfNextToReplicate = timeStampOfNextToReplicate; 141 return this; 142 } 143 144 public ReplicationLoadSourceBuilder setPeerID(String peerID) { 145 this.peerID = peerID; 146 return this; 147 } 148 149 public ReplicationLoadSourceBuilder setAgeOfLastShippedOp(long ageOfLastShippedOp) { 150 this.ageOfLastShippedOp = ageOfLastShippedOp; 151 return this; 152 } 153 154 public ReplicationLoadSourceBuilder setSizeOfLogQueue(int sizeOfLogQueue) { 155 this.sizeOfLogQueue = sizeOfLogQueue; 156 return this; 157 } 158 159 public ReplicationLoadSourceBuilder setTimestampOfLastShippedOp(long timestampOfLastShippedOp) { 160 this.timestampOfLastShippedOp = timestampOfLastShippedOp; 161 return this; 162 } 163 164 public ReplicationLoadSourceBuilder setReplicationLag(long replicationLag) { 165 this.replicationLag = replicationLag; 166 return this; 167 } 168 169 public ReplicationLoadSourceBuilder setQueueId(String queueId) { 170 this.queueId = queueId; 171 return this; 172 } 173 174 public ReplicationLoadSourceBuilder setRecovered(boolean recovered) { 175 this.recovered = recovered; 176 return this; 177 } 178 179 public ReplicationLoadSourceBuilder setRunning(boolean running) { 180 this.running = running; 181 return this; 182 } 183 184 public ReplicationLoadSourceBuilder setEditsSinceRestart(boolean editsSinceRestart) { 185 this.editsSinceRestart = editsSinceRestart; 186 return this; 187 } 188 189 public ReplicationLoadSourceBuilder setEditsRead(long editsRead) { 190 this.editsRead = editsRead; 191 return this; 192 } 193 194 public ReplicationLoadSourceBuilder setoPsShipped(long oPsShipped) { 195 this.oPsShipped = oPsShipped; 196 return this; 197 } 198 199 public ReplicationLoadSource build() { 200 return new ReplicationLoadSource(peerID, ageOfLastShippedOp, sizeOfLogQueue, 201 timestampOfLastShippedOp, timeStampOfNextToReplicate, replicationLag, queueId, recovered, 202 running, editsSinceRestart, editsRead, oPsShipped); 203 } 204 } 205}