Best practice to deprecate old constructor

This commit is contained in:
eha sah 2025-04-11 16:56:13 -07:00
parent 94cda6bd79
commit 0d2161e3f8
2 changed files with 41 additions and 40 deletions

View file

@ -419,7 +419,7 @@ public class Scheduler implements Runnable {
leaseManagementConfig.failoverTimeMillis(), leaseManagementConfig.failoverTimeMillis(),
metricsFactory, metricsFactory,
lamThreadPool, lamThreadPool,
() -> System.nanoTime(), System::nanoTime,
leaseManagementConfig.maxLeasesForWorker(), leaseManagementConfig.maxLeasesForWorker(),
leaseManagementConfig.gracefulLeaseHandoffConfig(), leaseManagementConfig.gracefulLeaseHandoffConfig(),
leaseManagementConfig.leaseAssignmentIntervalMillis())) leaseManagementConfig.leaseAssignmentIntervalMillis()))

View file

@ -122,46 +122,19 @@ public final class LeaseAssignmentManager {
private int noOfContinuousFailedAttempts = 0; private int noOfContinuousFailedAttempts = 0;
private int lamRunCounter = 0; private int lamRunCounter = 0;
@Deprecated
public LeaseAssignmentManager( public LeaseAssignmentManager(
LeaseRefresher leaseRefresher, final LeaseRefresher leaseRefresher,
WorkerMetricStatsDAO workerMetricsDAO, final WorkerMetricStatsDAO workerMetricsDAO,
LeaderDecider leaderDecider, final LeaderDecider leaderDecider,
LeaseManagementConfig.WorkerUtilizationAwareAssignmentConfig config, final LeaseManagementConfig.WorkerUtilizationAwareAssignmentConfig config,
String workerIdentifier, final String workerIdentifier,
Long leaseDurationMillis, final Long leaseDurationMillis,
MetricsFactory metricsFactory, final MetricsFactory metricsFactory,
ScheduledExecutorService executorService, final ScheduledExecutorService executorService,
Supplier<Long> nanoTimeProvider, final Supplier<Long> nanoTimeProvider,
int maxLeasesForWorker, final int maxLeasesForWorker,
LeaseManagementConfig.GracefulLeaseHandoffConfig gracefulLeaseHandoffConfig) { final LeaseManagementConfig.GracefulLeaseHandoffConfig gracefulLeaseHandoffConfig,
this.leaseRefresher = leaseRefresher; final long leaseAssignmentIntervalMillis) {
this.workerMetricsDAO = workerMetricsDAO;
this.leaderDecider = leaderDecider;
this.config = config;
this.currentWorkerId = workerIdentifier;
this.leaseDurationMillis = leaseDurationMillis;
this.metricsFactory = metricsFactory;
this.executorService = executorService;
this.nanoTimeProvider = nanoTimeProvider;
this.maxLeasesForWorker = maxLeasesForWorker;
this.gracefulLeaseHandoffConfig = gracefulLeaseHandoffConfig;
this.leaseAssignmentIntervalMillis = leaseDurationMillis * DEFAULT_LEASE_ASSIGNMENT_MANAGER_FREQ_MULTIPLIER;
}
public LeaseAssignmentManager(
LeaseRefresher leaseRefresher,
WorkerMetricStatsDAO workerMetricsDAO,
LeaderDecider leaderDecider,
LeaseManagementConfig.WorkerUtilizationAwareAssignmentConfig config,
String workerIdentifier,
Long leaseDurationMillis,
MetricsFactory metricsFactory,
ScheduledExecutorService executorService,
Supplier<Long> nanoTimeProvider,
int maxLeasesForWorker,
LeaseManagementConfig.GracefulLeaseHandoffConfig gracefulLeaseHandoffConfig,
long leaseAssignmentIntervalMillis) {
this.leaseRefresher = leaseRefresher; this.leaseRefresher = leaseRefresher;
this.workerMetricsDAO = workerMetricsDAO; this.workerMetricsDAO = workerMetricsDAO;
this.leaderDecider = leaderDecider; this.leaderDecider = leaderDecider;
@ -176,6 +149,34 @@ public final class LeaseAssignmentManager {
this.leaseAssignmentIntervalMillis = leaseAssignmentIntervalMillis; this.leaseAssignmentIntervalMillis = leaseAssignmentIntervalMillis;
} }
@Deprecated
public LeaseAssignmentManager(
final LeaseRefresher leaseRefresher,
final WorkerMetricStatsDAO workerMetricsDAO,
final LeaderDecider leaderDecider,
final LeaseManagementConfig.WorkerUtilizationAwareAssignmentConfig config,
final String workerIdentifier,
final Long leaseDurationMillis,
final MetricsFactory metricsFactory,
final ScheduledExecutorService executorService,
final Supplier<Long> nanoTimeProvider,
final int maxLeasesForWorker,
final LeaseManagementConfig.GracefulLeaseHandoffConfig gracefulLeaseHandoffConfig) {
this(
leaseRefresher,
workerMetricsDAO,
leaderDecider,
config,
workerIdentifier,
leaseDurationMillis,
metricsFactory,
executorService,
nanoTimeProvider,
maxLeasesForWorker,
gracefulLeaseHandoffConfig,
leaseDurationMillis * DEFAULT_LEASE_ASSIGNMENT_MANAGER_FREQ_MULTIPLIER);
}
public synchronized void start() { public synchronized void start() {
if (isNull(managerFuture)) { if (isNull(managerFuture)) {
// LAM can be dynamically started/stopped and restarted during MigrationStateMachine execution // LAM can be dynamically started/stopped and restarted during MigrationStateMachine execution