private Mutex lock(Node node, Optional<Duration> timeout) {
        Optional<ApplicationId> application = applicationIdForLock(node);
        if (application.isPresent())
            return timeout.map(t -> applications.lock(application.get(), t))
                          .orElseGet(() -> applications.lock(application.get()));
        else
            return timeout.map(db::lockInactive).orElseGet(db::lockInactive);
    }
Returns the unallocated/application lock, and the node acquired under that lock.
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/Nodes.java