aboutsummaryrefslogtreecommitdiffstats
path: root/config/src/main/java/com/yahoo/vespa/config/protocol/JRTServerConfigRequest.java
blob: e62d8018323966baac109383fcedb37caa28f88e (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
// 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.vespa.config.GetConfigRequest;

/**
 * Interface for config requests at the server end point.
 *
 * @author Ulf Lilleengen
 */
public interface JRTServerConfigRequest extends JRTConfigRequest, GetConfigRequest {

    /**
     * Notify this request that its delayed due to no new config being available at this point. The value
     * provided in this function should be returned when calling {@link #isDelayedResponse()}.
     *
     * @param delayedResponse true if response is delayed, false if not.
     */
    void setDelayedResponse(boolean delayedResponse);

    /**
     * Signal error when handling this request. The error should be reflected in the request state and propagated
     * back to the client.
     *
     * @param errorCode error code, as described in {@link com.yahoo.vespa.config.ErrorCode}.
     * @param message message to display for this error, typically printed by client.
     */
    void addErrorResponse(int errorCode, String message);

    /**
     * Signal that the request was handled and provide return values typically needed by a client.
     *
     * @param payload The config payload that the client should receive.
     * @param generation The config generation of the given payload.
     * @param applyOnRestart true if this config should only be applied on the next restart,
     *                       false if it should be applied right away
     * @param payloadChecksums checksums of the given payload.
     */
    void addOkResponse(Payload payload, long generation, boolean applyOnRestart, PayloadChecksums payloadChecksums);

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

    /**
     * Get the current config generation of the client config.
     *
     * @return the current config generation.
     */
    long getRequestGeneration();

    /**
     * Check whether or not this request is delayed.
     *
     * @return true if delayed, false if not.
     */
    boolean isDelayedResponse();

    boolean applyOnRestart();

    /**
     * Get the request trace for this request. The trace can be used to trace config execution to provide useful
     * debug info in production environments.
     *
     * @return a {@link Trace} instance.
     */
    Trace getRequestTrace();

    /**
     * Extract the appropriate payload for this request type for a given config response.
     *
     * @param response {@link ConfigResponse} to get payload from.
     * @return A {@link Payload} that satisfies this request format.
     */
    Payload payloadFromResponse(ConfigResponse response);


    /**
     * Returns the payload checksums from the config request.
     *
     * @return the payload checksumss from request.
     */
    PayloadChecksums configPayloadChecksums();

}