summaryrefslogtreecommitdiffstats
path: root/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/LockedNodeList.java
blob: e6186b8eb775eb10d79a3d4ebf63b2b835436467 (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
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision;

import com.yahoo.transaction.Mutex;

import java.util.List;
import java.util.Objects;

/**
 * A type-safe wrapper for {@link NodeList}. Callers that have a reference to this can safely be assumed to be holding
 * the allocation lock for the node repository.
 *
 * This is typically used in situations where modifying a node object depends on inspecting a consistent state of all
 * nodes in the repository.
 *
 * @author mpolden
 */
public final class LockedNodeList extends NodeList {

    public LockedNodeList(List<Node> nodes, Mutex lock) {
        super(nodes, false);
        Objects.requireNonNull(lock, "lock must be non-null");
    }

}