HBASE-26490 Add builder for class ReplicationLoadSink (#3883)
Signed-off-by: Reid Chan <reidchan@apache.org> Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
parent
45347bb81a
commit
02fa0903a2
|
@ -22,9 +22,7 @@ public class ReplicationLoadSink {
|
|||
private final long timestampStarted;
|
||||
private final long totalOpsProcessed;
|
||||
|
||||
// TODO: add the builder for this class
|
||||
@InterfaceAudience.Private
|
||||
public ReplicationLoadSink(long age, long timestamp, long timestampStarted,
|
||||
private ReplicationLoadSink(long age, long timestamp, long timestampStarted,
|
||||
long totalOpsProcessed) {
|
||||
this.ageOfLastAppliedOp = age;
|
||||
this.timestampsOfLastAppliedOp = timestamp;
|
||||
|
@ -56,4 +54,44 @@ public class ReplicationLoadSink {
|
|||
public long getTotalOpsProcessed() {
|
||||
return totalOpsProcessed;
|
||||
}
|
||||
|
||||
@InterfaceAudience.Private
|
||||
public static ReplicationLoadSinkBuilder newBuilder() {
|
||||
return new ReplicationLoadSinkBuilder();
|
||||
}
|
||||
|
||||
@InterfaceAudience.Private
|
||||
public static final class ReplicationLoadSinkBuilder {
|
||||
private long ageOfLastAppliedOp;
|
||||
private long timestampsOfLastAppliedOp;
|
||||
private long timestampStarted;
|
||||
private long totalOpsProcessed;
|
||||
|
||||
private ReplicationLoadSinkBuilder() {}
|
||||
|
||||
public ReplicationLoadSinkBuilder setAgeOfLastAppliedOp(long ageOfLastAppliedOp) {
|
||||
this.ageOfLastAppliedOp = ageOfLastAppliedOp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplicationLoadSinkBuilder setTimestampsOfLastAppliedOp(long timestampsOfLastAppliedOp) {
|
||||
this.timestampsOfLastAppliedOp = timestampsOfLastAppliedOp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplicationLoadSinkBuilder setTimestampStarted(long timestampStarted) {
|
||||
this.timestampStarted = timestampStarted;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplicationLoadSinkBuilder setTotalOpsProcessed(long totalOpsProcessed) {
|
||||
this.totalOpsProcessed = totalOpsProcessed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ReplicationLoadSink build() {
|
||||
return new ReplicationLoadSink(ageOfLastAppliedOp, timestampsOfLastAppliedOp,
|
||||
timestampStarted, totalOpsProcessed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2796,10 +2796,12 @@ public final class ProtobufUtil {
|
|||
|
||||
public static ReplicationLoadSink toReplicationLoadSink(
|
||||
ClusterStatusProtos.ReplicationLoadSink rls) {
|
||||
return new ReplicationLoadSink(rls.getAgeOfLastAppliedOp(),
|
||||
rls.getTimeStampsOfLastAppliedOp(),
|
||||
rls.hasTimestampStarted()? rls.getTimestampStarted(): -1L,
|
||||
rls.hasTotalOpsProcessed()? rls.getTotalOpsProcessed(): -1L);
|
||||
ReplicationLoadSink.ReplicationLoadSinkBuilder builder = ReplicationLoadSink.newBuilder();
|
||||
builder.setAgeOfLastAppliedOp(rls.getAgeOfLastAppliedOp()).
|
||||
setTimestampsOfLastAppliedOp(rls.getTimeStampsOfLastAppliedOp()).
|
||||
setTimestampStarted(rls.hasTimestampStarted()? rls.getTimestampStarted(): -1L).
|
||||
setTotalOpsProcessed(rls.hasTotalOpsProcessed()? rls.getTotalOpsProcessed(): -1L);
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static ReplicationLoadSource toReplicationLoadSource(
|
||||
|
|
Loading…
Reference in New Issue