
com.yahoo.vespa.hosted.provision.applications.Applications 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 Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.applications;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.transaction.Mutex;
import java.util.concurrent.ConcurrentHashMap;
/**
* An (in-memory, for now) repository of the node repo's view of applications.
*
* This is multithread safe.
*
* @author bratseth
*/
public class Applications {
private final ConcurrentHashMap applications = new ConcurrentHashMap<>();
/** Returns the application with the given id, or null if it does not exist and should not be created */
public Application get(ApplicationId applicationId, boolean create) {
return applications.computeIfAbsent(applicationId, id -> create ? new Application() : null);
}
public void set(ApplicationId id, Application application, Mutex applicationLock) {
applications.put(id, application);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy