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 MetricsSink information 024 */ 025@InterfaceAudience.Public 026public class ReplicationLoadSink { 027 private final long ageOfLastAppliedOp; 028 private final long timestampsOfLastAppliedOp; 029 private final long timestampStarted; 030 private final long totalOpsProcessed; 031 032 public ReplicationLoadSink(long age, long timestamp, long timestampStarted, 033 long totalOpsProcessed) { 034 this.ageOfLastAppliedOp = age; 035 this.timestampsOfLastAppliedOp = timestamp; 036 this.timestampStarted = timestampStarted; 037 this.totalOpsProcessed = totalOpsProcessed; 038 } 039 040 public long getAgeOfLastAppliedOp() { 041 return this.ageOfLastAppliedOp; 042 } 043 044 /** 045 * Get the timestamp of the last applied operation. 046 * @deprecated Since hbase-2.0.0. Will be removed in 3.0.0. 047 * @see #getTimestampsOfLastAppliedOp() 048 */ 049 @Deprecated 050 public long getTimeStampsOfLastAppliedOp() { 051 return getTimestampsOfLastAppliedOp(); 052 } 053 054 public long getTimestampsOfLastAppliedOp() { 055 return this.timestampsOfLastAppliedOp; 056 } 057 058 public long getTimestampStarted() { 059 return timestampStarted; 060 } 061 062 public long getTotalOpsProcessed() { 063 return totalOpsProcessed; 064 } 065 066 @InterfaceAudience.Private 067 public static ReplicationLoadSinkBuilder newBuilder() { 068 return new ReplicationLoadSinkBuilder(); 069 } 070 071 @InterfaceAudience.Private 072 public static final class ReplicationLoadSinkBuilder { 073 private long ageOfLastAppliedOp; 074 private long timestampsOfLastAppliedOp; 075 private long timestampStarted; 076 private long totalOpsProcessed; 077 078 private ReplicationLoadSinkBuilder() { 079 } 080 081 public ReplicationLoadSinkBuilder setAgeOfLastAppliedOp(long ageOfLastAppliedOp) { 082 this.ageOfLastAppliedOp = ageOfLastAppliedOp; 083 return this; 084 } 085 086 public ReplicationLoadSinkBuilder setTimestampsOfLastAppliedOp(long timestampsOfLastAppliedOp) { 087 this.timestampsOfLastAppliedOp = timestampsOfLastAppliedOp; 088 return this; 089 } 090 091 public ReplicationLoadSinkBuilder setTimestampStarted(long timestampStarted) { 092 this.timestampStarted = timestampStarted; 093 return this; 094 } 095 096 public ReplicationLoadSinkBuilder setTotalOpsProcessed(long totalOpsProcessed) { 097 this.totalOpsProcessed = totalOpsProcessed; 098 return this; 099 } 100 101 public ReplicationLoadSink build() { 102 return new ReplicationLoadSink(ageOfLastAppliedOp, timestampsOfLastAppliedOp, 103 timestampStarted, totalOpsProcessed); 104 } 105 } 106}