aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib/src/test/java/com/yahoo/concurrent/maintenance/JobControlStateMock.java
blob: 59855e9eb034ef296f45533e2ef29825615b36f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.concurrent.maintenance;

import com.yahoo.transaction.Mutex;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 * @author mpolden
 */
class JobControlStateMock implements JobControlState {

    private final Set<String> inactiveJobs = new HashSet<>();

    @Override
    public Set<String> readInactiveJobs() {
        return Collections.unmodifiableSet(inactiveJobs);
    }

    @Override
    public Mutex lockMaintenanceJob(String job) {
        return () -> {};
    }

    public void setActive(String job, boolean active) {
        if (active) {
            inactiveJobs.remove(job);
        } else {
            inactiveJobs.add(job);
        }
    }

}