com.yahoo.vespa.hosted.provision.persistence.JobControlFlags Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of node-repository Show documentation
Show all versions of node-repository Show documentation
Keeps track of node assignment in a multi-application setup.
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.persistence;
import com.yahoo.concurrent.maintenance.JobControlState;
import com.yahoo.transaction.Mutex;
import com.yahoo.vespa.flags.FlagSource;
import com.yahoo.vespa.flags.ListFlag;
import com.yahoo.vespa.flags.PermanentFlags;
import java.util.Set;
/**
* An implementation of {@link JobControlState} that uses a feature flag to control maintenance jobs.
*
* @author mpolden
*/
public class JobControlFlags implements JobControlState {
private final CuratorDb curator;
private final ListFlag inactiveJobsFlag;
public JobControlFlags(CuratorDb curator, FlagSource flagSource) {
this.curator = curator;
this.inactiveJobsFlag = PermanentFlags.INACTIVE_MAINTENANCE_JOBS.bindTo(flagSource);
}
@Override
public Set readInactiveJobs() {
return Set.copyOf(inactiveJobsFlag.value());
}
@Override
public Mutex lockMaintenanceJob(String job) {
return curator.lockMaintenanceJob(job);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy