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