aboutsummaryrefslogtreecommitdiffstats
path: root/config/src/main/java/com/yahoo/vespa/config/protocol/JRTConfigRequest.java
blob: 45ee82b3e6edb3882b9f436f06e8026dd46fed23 (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
100
101
102
103
104
105
106
107
108
109
110
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.protocol;

import com.yahoo.vespa.config.PayloadChecksums;
import com.yahoo.jrt.Request;
import com.yahoo.vespa.config.ConfigKey;

import java.util.Optional;

/**
 * Common interface for jrt config requests available both at server and client.
 *
 * @author Ulf Lilleengen
 */
public interface JRTConfigRequest {

    /**
     * Returns the config key of the config request.
     *
     * @return a {@link ConfigKey}.
     */
    ConfigKey<?> getConfigKey();

    /**
     * Performs request parameter validation of this config request. This method should be called before fetching
     * any kind of config protocol-specific parameter.
     *
     * @return true if valid, false if not.
     */
    boolean validateParameters();

    /**
     * Returns the md5 of the config definition in the request.
     *
     * @return an md5 of config definition in request.
     */
    String getRequestDefMd5();

    /**
     * Returns the generation of the requested config. If none has been given, 0 should be returned.
     * Returns the checksum of the config request. Return an empty string if no response has been returned.
     *
     * @return a config checksum.
     */
    PayloadChecksums getRequestConfigChecksums();

    /**
     * Returns the generation of the requested config. If none has been given, 0 should be returned.
     *
     * @return the generation in the request.
     */
    long getRequestGeneration();

    /**
     * Returns the JRT request object for this config request.
     * TODO: This method leaks the internal jrt stuff :(
     *
     * @return a {@link Request} object.
     */
    Request getRequest();

    /**
     * Returns a short hand description of this request.
     *
     * @return a short description
     */
    String getShortDescription();

    /**
     * Returns the error code of this request
     *
     * @return the error code as defined in {@link com.yahoo.vespa.config.ErrorCode}.
     */
    int errorCode();

    /**
     * Return the error message of this request, mostly corresponding to the {@link com.yahoo.vespa.config.ErrorCode}.
     *
     * @return the error message.
     */
    String errorMessage();

    /**
     * Returns the server timeout of this request.
     *
     * @return the timeout given to the server
     */
    long getTimeout();

    /**
     * Returns the config protocol version
     *
     * @return a protocol version number.
     */
    long getProtocolVersion();

    /**
     * Returns the host name of the client that is requesting config.
     * @return hostname of the client.
     */
    String getClientHostName();

    /**
     * Returns the Vespa version of the client that initiated the request
     *
     * @return Vespa version of the client
     */
    Optional<VespaVersion> getVespaVersion();

}