aboutsummaryrefslogtreecommitdiffstats
path: root/configserver/src/main/java/com/yahoo/vespa/config/server/RequestHandler.java
blob: 20b16614a5306a365166154080220e1e8f2a409c (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server;

import com.yahoo.component.Version;
import com.yahoo.config.FileReference;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.config.ConfigKey;
import com.yahoo.vespa.config.GetConfigRequest;
import com.yahoo.vespa.config.protocol.ConfigResponse;

import java.util.Optional;
import java.util.Set;

/**
 * Instances of this can serve misc config related requests
 * 
 * @author Ulf Lilleengen
 */
public interface RequestHandler {

    /**
     * Resolves a config. Mandatory subclass hook for getConfig().
     *
     * @param appId The application id to use
     * @param req a config request
     * @param vespaVersion vespa version
     * @return The resolved config if it exists, else null.
     */
    ConfigResponse resolveConfig(ApplicationId appId, GetConfigRequest req, Optional<Version> vespaVersion);

    /**
     * Lists all configs (name, configKey) in the config model.
     *
     * @param appId application id to use
     * @param vespaVersion optional vespa version
     * @param recursive If true descend into all levels
     * @return set of keys
     */
    Set<ConfigKey<?>> listConfigs(ApplicationId appId, Optional<Version> vespaVersion, boolean recursive);
    
    /**
     * Lists all configs (name, configKey) of the given key. The config id of the key is interpreted as a prefix to match.
     *
     * @param appId application id to use
     * @param vespaVersion optional vespa version
     * @param key def key to match
     * @param recursive If true descend into all levels
     * @return set of keys
     */
    Set<ConfigKey<?>> listNamedConfigs(ApplicationId appId, Optional<Version> vespaVersion, ConfigKey<?> key, boolean recursive);

    /**
     * Lists all available configs produced
     *
     * @param appId application id to use
     * @param vespaVersion optional vespa version
     * @return set of keys
     */
    Set<ConfigKey<?>> allConfigsProduced(ApplicationId appId, Optional<Version> vespaVersion);
    
    /**
     * List all config ids present
     *
     * @param appId application id to use
     * @param vespaVersion optional vespa version
     * @return a Set containing all config ids available
     */
    Set<String> allConfigIds(ApplicationId appId, Optional<Version> vespaVersion);

    /**
     * True if application loaded
     *
     * @param appId The application id to use
     * @param vespaVersion optional vespa version
     * @return true if app loaded
     */
    boolean hasApplication(ApplicationId appId, Optional<Version> vespaVersion);

    /**
     * Resolve {@link ApplicationId} for a given hostname. Returns a default {@link ApplicationId} if no applications
     * are found for that host.
     *
     * @param hostName hostname of client.
     * @return an {@link ApplicationId} instance.
     */
    ApplicationId resolveApplicationId(String hostName);

    /**
     * Returns the set of file references from the application's Vespa models, aggregated across all application versions.
     *
     * @param applicationId application id to use
     * @return set of file references that is owned by the application
     */
    Set<FileReference> listFileReferences(ApplicationId applicationId);

    /** Returns whether the latest deployed version of application is compatible with given vespaVersion */
    boolean compatibleWith(Optional<Version> vespaVersion, ApplicationId application);

}