Skip to content

Commit ffa1564

Browse files
horizonzyzymap
authored andcommitted
Remove underreplicaiton callback (#4058)
### Motivation Address https://lists.apache.org/thread/1xl3hr2cpyd5xh9kozbx5xlfsjsg3f4h Deprecate underreplicaiton callback to relieve zookeeper pressure. (cherry picked from commit 84a80f5)
1 parent f8a0501 commit ffa1564

File tree

4 files changed

+3
-46
lines changed

4 files changed

+3
-46
lines changed

Diff for: bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerUnderreplicationManager.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,9 @@ boolean initializeLostBookieRecoveryDelay(int lostBookieRecoveryDelay)
240240
* @param cb
241241
* @throws ReplicationException.UnavailableException
242242
*/
243-
void notifyUnderReplicationLedgerChanged(GenericCallback<Void> cb)
244-
throws ReplicationException.UnavailableException;
243+
@Deprecated
244+
default void notifyUnderReplicationLedgerChanged(GenericCallback<Void> cb)
245+
throws ReplicationException.UnavailableException {}
245246

246247
/**
247248
* Receive notification asynchronously when the lostBookieRecoveryDelay value is Changed.

Diff for: bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java

-17
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@
2121
package org.apache.bookkeeper.replication;
2222

2323
import com.google.common.annotations.VisibleForTesting;
24-
import com.google.common.collect.Iterators;
2524
import com.google.common.collect.Lists;
2625
import com.google.common.collect.Sets;
2726
import com.google.common.util.concurrent.SettableFuture;
2827
import java.io.IOException;
2928
import java.util.ArrayList;
3029
import java.util.Collection;
31-
import java.util.Iterator;
3230
import java.util.List;
3331
import java.util.Set;
3432
import java.util.concurrent.Executors;
@@ -46,7 +44,6 @@
4644
import org.apache.bookkeeper.meta.LedgerManager;
4745
import org.apache.bookkeeper.meta.LedgerManagerFactory;
4846
import org.apache.bookkeeper.meta.LedgerUnderreplicationManager;
49-
import org.apache.bookkeeper.meta.UnderreplicatedLedger;
5047
import org.apache.bookkeeper.net.BookieId;
5148
import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
5249
import org.apache.bookkeeper.replication.ReplicationException.BKAuditException;
@@ -183,7 +180,6 @@ public Auditor(final String bookieIdentifier,
183180
conf, auditorStats, admin, ledgerManager,
184181
ledgerUnderreplicationManager, shutdownTaskHandler, hasAuditCheckTask);
185182
allAuditorTasks.add(auditorReplicasCheckTask);
186-
187183
executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
188184
@Override
189185
public Thread newThread(Runnable r) {
@@ -393,8 +389,6 @@ public void start() {
393389
knownBookies = getAvailableBookies();
394390
this.ledgerUnderreplicationManager
395391
.notifyLostBookieRecoveryDelayChanged(new LostBookieRecoveryDelayChangedCb());
396-
this.ledgerUnderreplicationManager.notifyUnderReplicationLedgerChanged(
397-
new UnderReplicatedLedgersChangedCb());
398392
} catch (BKException bke) {
399393
LOG.error("Couldn't get bookie list, so exiting", bke);
400394
submitShutdownTask();
@@ -404,7 +398,6 @@ public void start() {
404398
submitShutdownTask();
405399
return;
406400
}
407-
408401
scheduleBookieCheckTask();
409402
scheduleCheckAllLedgersTask();
410403
schedulePlacementPolicyCheckTask();
@@ -558,16 +551,6 @@ private void scheduleReplicasCheckTask() {
558551
executor.scheduleAtFixedRate(auditorReplicasCheckTask, initialDelay, interval, TimeUnit.SECONDS);
559552
}
560553

561-
private class UnderReplicatedLedgersChangedCb implements GenericCallback<Void> {
562-
@Override
563-
public void operationComplete(int rc, Void result) {
564-
Iterator<UnderreplicatedLedger> underreplicatedLedgersInfo = ledgerUnderreplicationManager
565-
.listLedgersToRereplicate(null);
566-
auditorStats.getUnderReplicatedLedgersGuageValue().set(Iterators.size(underreplicatedLedgersInfo));
567-
auditorStats.getNumReplicatedLedgers().inc();
568-
}
569-
}
570-
571554
private class LostBookieRecoveryDelayChangedCb implements GenericCallback<Void> {
572555
@Override
573556
public void operationComplete(int rc, Void result) {

Diff for: bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorStats.java

-25
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@
3131
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_LEDGERS_HAVING_NO_REPLICA_OF_AN_ENTRY;
3232
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_LEDGERS_NOT_ADHERING_TO_PLACEMENT_POLICY;
3333
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_LEDGERS_SOFTLY_ADHERING_TO_PLACEMENT_POLICY;
34-
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_REPLICATED_LEDGERS;
3534
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_UNDERREPLICATED_LEDGERS_ELAPSED_RECOVERY_GRACE_PERIOD;
3635
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_UNDER_REPLICATED_LEDGERS;
37-
import static org.apache.bookkeeper.replication.ReplicationStats.NUM_UNDER_REPLICATED_LEDGERS_GUAGE;
3836
import static org.apache.bookkeeper.replication.ReplicationStats.PLACEMENT_POLICY_CHECK_TIME;
3937
import static org.apache.bookkeeper.replication.ReplicationStats.REPLICAS_CHECK_TIME;
4038
import static org.apache.bookkeeper.replication.ReplicationStats.UNDER_REPLICATED_LEDGERS_TOTAL_SIZE;
@@ -129,11 +127,6 @@ public class AuditorStats {
129127
help = "the number of delayed-bookie-audits cancelled"
130128
)
131129
private final Counter numDelayedBookieAuditsCancelled;
132-
@StatsDoc(
133-
name = NUM_REPLICATED_LEDGERS,
134-
help = "the number of replicated ledgers"
135-
)
136-
private final Counter numReplicatedLedgers;
137130
@StatsDoc(
138131
name = NUM_LEDGERS_NOT_ADHERING_TO_PLACEMENT_POLICY,
139132
help = "Gauge for number of ledgers not adhering to placement policy found in placement policy check"
@@ -166,11 +159,6 @@ public class AuditorStats {
166159
+ ", this doesn't include ledgers counted towards numLedgersHavingLessThanAQReplicasOfAnEntry"
167160
)
168161
private final Gauge<Integer> numLedgersHavingLessThanWQReplicasOfAnEntry;
169-
@StatsDoc(
170-
name = NUM_UNDER_REPLICATED_LEDGERS_GUAGE,
171-
help = "Gauge for num of underreplicated ledgers"
172-
)
173-
private final Gauge<Integer> numUnderReplicatedLedgers;
174162

175163
public AuditorStats(StatsLogger statsLogger) {
176164
this.statsLogger = statsLogger;
@@ -197,7 +185,6 @@ public AuditorStats(StatsLogger statsLogger) {
197185
numBookieAuditsDelayed = this.statsLogger.getCounter(ReplicationStats.NUM_BOOKIE_AUDITS_DELAYED);
198186
numDelayedBookieAuditsCancelled = this.statsLogger
199187
.getCounter(ReplicationStats.NUM_DELAYED_BOOKIE_AUDITS_DELAYES_CANCELLED);
200-
numReplicatedLedgers = this.statsLogger.getCounter(NUM_REPLICATED_LEDGERS);
201188
numLedgersNotAdheringToPlacementPolicy = new Gauge<Integer>() {
202189
@Override
203190
public Integer getDefaultValue() {
@@ -278,17 +265,5 @@ public Integer getSample() {
278265
};
279266
this.statsLogger.registerGauge(ReplicationStats.NUM_LEDGERS_HAVING_LESS_THAN_WQ_REPLICAS_OF_AN_ENTRY,
280267
numLedgersHavingLessThanWQReplicasOfAnEntry);
281-
numUnderReplicatedLedgers = new Gauge<Integer>() {
282-
@Override
283-
public Integer getDefaultValue() {
284-
return 0;
285-
}
286-
287-
@Override
288-
public Integer getSample() {
289-
return underReplicatedLedgersGuageValue.get();
290-
}
291-
};
292-
this.statsLogger.registerGauge(NUM_UNDER_REPLICATED_LEDGERS_GUAGE, numUnderReplicatedLedgers);
293268
}
294269
}

Diff for: bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationStats.java

-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,5 @@ public interface ReplicationStats {
6464
String REPLICATE_EXCEPTION = "exceptions";
6565
String NUM_DEFER_LEDGER_LOCK_RELEASE_OF_FAILED_LEDGER = "NUM_DEFER_LEDGER_LOCK_RELEASE_OF_FAILED_LEDGER";
6666
String NUM_ENTRIES_UNABLE_TO_READ_FOR_REPLICATION = "NUM_ENTRIES_UNABLE_TO_READ_FOR_REPLICATION";
67-
String NUM_UNDER_REPLICATED_LEDGERS_GUAGE = "NUM_UNDER_REPLICATED_LEDGERS_GUAGE";
68-
String NUM_REPLICATED_LEDGERS = "NUM_REPLICATED_LEDGERS";
6967
String NUM_NOT_ADHERING_PLACEMENT_LEDGERS_REPLICATED = "NUM_NOT_ADHERING_PLACEMENT_LEDGERS_REPLICATED";
7068
}

0 commit comments

Comments
 (0)