Skip to content

Commit

Permalink
Port the #4058 changes to the branch-4.15 (#4147)
Browse files Browse the repository at this point in the history
---

### Motivation

#4058
  • Loading branch information
zymap authored Dec 12, 2023
1 parent 9f3be1c commit 34d6b12
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,9 @@ boolean initializeLostBookieRecoveryDelay(int lostBookieRecoveryDelay)
* @param cb
* @throws ReplicationException.UnavailableException
*/
void notifyUnderReplicationLedgerChanged(GenericCallback<Void> cb)
throws ReplicationException.UnavailableException;
@Deprecated
default void notifyUnderReplicationLedgerChanged(GenericCallback<Void> cb)
throws ReplicationException.UnavailableException {}

/**
* Receive notification asynchronously when the lostBookieRecoveryDelay value is Changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,5 @@ public String getReplicationWorkerIdRereplicatingLedger(long ledgerId)
throws ReplicationException.UnavailableException {
throw new ReplicationException.UnavailableException("null");
}
@Override
public void notifyUnderReplicationLedgerChanged(GenericCallback<Void> cb) {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ public int getLostBookieRecoveryDelay() throws UnavailableException {
}
}

@SuppressWarnings("deprecation")
@Override
public void notifyUnderReplicationLedgerChanged(GenericCallback<Void> cb) throws UnavailableException {
LOG.debug("notifyUnderReplicationLedgerChanged()");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_LEDGERS_HAVING_NO_REPLICA_OF_AN_ENTRY;
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_LEDGERS_NOT_ADHERING_TO_PLACEMENT_POLICY;
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_LEDGERS_SOFTLY_ADHERING_TO_PLACEMENT_POLICY;
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_REPLICATED_LEDGERS;
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_UNDERREPLICATED_LEDGERS_ELAPSED_RECOVERY_GRACE_PERIOD;
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_UNDER_REPLICATED_LEDGERS;
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_UNDER_REPLICATED_LEDGERS_GUAGE;
import static org.apache.bookkeeper.replication.ReplicationStats.PLACEMENT_POLICY_CHECK_TIME;
import static org.apache.bookkeeper.replication.ReplicationStats.REPLICAS_CHECK_TIME;
import static org.apache.bookkeeper.replication.ReplicationStats.UNDER_REPLICATED_LEDGERS_TOTAL_SIZE;
Expand All @@ -47,7 +45,6 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Stopwatch;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.google.common.collect.Multiset;
import com.google.common.collect.Sets;
Expand Down Expand Up @@ -239,11 +236,6 @@ public class Auditor implements AutoCloseable {
help = "the number of delayed-bookie-audits cancelled"
)
private final Counter numDelayedBookieAuditsCancelled;
@StatsDoc(
name = NUM_REPLICATED_LEDGERS,
help = "the number of replicated ledgers"
)
private final Counter numReplicatedLedgers;
@StatsDoc(
name = NUM_LEDGERS_NOT_ADHERING_TO_PLACEMENT_POLICY,
help = "Gauge for number of ledgers not adhering to placement policy found in placement policy check"
Expand Down Expand Up @@ -276,11 +268,6 @@ public class Auditor implements AutoCloseable {
+ ", this doesn't include ledgers counted towards numLedgersHavingLessThanAQReplicasOfAnEntry"
)
private final Gauge<Integer> numLedgersHavingLessThanWQReplicasOfAnEntry;
@StatsDoc(
name = NUM_UNDER_REPLICATED_LEDGERS_GUAGE,
help = "Gauge for num of underreplicated ledgers"
)
private final Gauge<Integer> numUnderReplicatedLedgers;

static BookKeeper createBookKeeperClient(ServerConfiguration conf) throws InterruptedException, IOException {
return createBookKeeperClient(conf, NullStatsLogger.INSTANCE);
Expand Down Expand Up @@ -395,7 +382,6 @@ public Auditor(final String bookieIdentifier,
numBookieAuditsDelayed = this.statsLogger.getCounter(ReplicationStats.NUM_BOOKIE_AUDITS_DELAYED);
numDelayedBookieAuditsCancelled = this.statsLogger
.getCounter(ReplicationStats.NUM_DELAYED_BOOKIE_AUDITS_DELAYES_CANCELLED);
numReplicatedLedgers = this.statsLogger.getCounter(NUM_REPLICATED_LEDGERS);
numLedgersNotAdheringToPlacementPolicy = new Gauge<Integer>() {
@Override
public Integer getDefaultValue() {
Expand Down Expand Up @@ -476,18 +462,6 @@ public Integer getSample() {
};
this.statsLogger.registerGauge(ReplicationStats.NUM_LEDGERS_HAVING_LESS_THAN_WQ_REPLICAS_OF_AN_ENTRY,
numLedgersHavingLessThanWQReplicasOfAnEntry);
numUnderReplicatedLedgers = new Gauge<Integer>() {
@Override
public Integer getDefaultValue() {
return 0;
}

@Override
public Integer getSample() {
return underReplicatedLedgersGuageValue.get();
}
};
this.statsLogger.registerGauge(NUM_UNDER_REPLICATED_LEDGERS_GUAGE, numUnderReplicatedLedgers);

this.bkc = bkc;
this.ownBkc = ownBkc;
Expand Down Expand Up @@ -740,15 +714,6 @@ public void start() {
submitShutdownTask();
}

try {
this.ledgerUnderreplicationManager.notifyUnderReplicationLedgerChanged(
new UnderReplicatedLedgersChangedCb());
} catch (UnavailableException ue) {
LOG.error("Exception while registering for under-replicated ledgers change notification, so exiting",
ue);
submitShutdownTask();
}

scheduleBookieCheckTask();
scheduleCheckAllLedgersTask();
schedulePlacementPolicyCheckTask();
Expand Down Expand Up @@ -1089,16 +1054,6 @@ public void run() {
}), initialDelay, interval, TimeUnit.SECONDS);
}

private class UnderReplicatedLedgersChangedCb implements GenericCallback<Void> {
@Override
public void operationComplete(int rc, Void result) {
Iterator<UnderreplicatedLedger> underreplicatedLedgersInfo = ledgerUnderreplicationManager
.listLedgersToRereplicate(null);
underReplicatedLedgersGuageValue.set(Iterators.size(underreplicatedLedgersInfo));
numReplicatedLedgers.inc();
}
}

private class LostBookieRecoveryDelayChangedCb implements GenericCallback<Void> {
@Override
public void operationComplete(int rc, Void result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,4 @@ public interface ReplicationStats {
String REPLICATE_EXCEPTION = "exceptions";
String NUM_DEFER_LEDGER_LOCK_RELEASE_OF_FAILED_LEDGER = "NUM_DEFER_LEDGER_LOCK_RELEASE_OF_FAILED_LEDGER";
String NUM_ENTRIES_UNABLE_TO_READ_FOR_REPLICATION = "NUM_ENTRIES_UNABLE_TO_READ_FOR_REPLICATION";
String NUM_UNDER_REPLICATED_LEDGERS_GUAGE = "NUM_UNDER_REPLICATED_LEDGERS_GUAGE";
String NUM_REPLICATED_LEDGERS = "NUM_REPLICATED_LEDGERS";
}

0 comments on commit 34d6b12

Please sign in to comment.