aboutsummaryrefslogtreecommitdiffstats
path: root/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/SetClusterStateRequest.java
blob: 836876b5642d21061973a05605fd81c0671caf14 (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core;

public abstract class SetClusterStateRequest {

    private final NodeInfo nodeInfo;
    private final int systemStateVersion;
    private Reply reply;

    public SetClusterStateRequest(NodeInfo nodeInfo, int systemStateVersion) {
        this.nodeInfo = nodeInfo;
        this.systemStateVersion = systemStateVersion;
    }

    public NodeInfo getNodeInfo() { return nodeInfo; }

    public int getSystemStateVersion() { return systemStateVersion; }

    public void setReply(Reply reply) { this.reply = reply; }

    public Reply getReply() { return reply; }

    public static class Reply {

        final int returnCode;
        final String returnMessage;

        public Reply() {
            this(0, null);
        }

        public Reply(int returnCode, String returnMessage) {
            this.returnCode = returnCode;
            this.returnMessage = returnMessage;
        }

        /** Returns whether this is an error response */
        public boolean isError() { return returnCode != 0; }

        /** Returns the return code, which is 0 if this request was successful */
        public int getReturnCode() { return returnCode; }

        /** Returns the message returned, or null if none */
        public String getReturnMessage() { return returnMessage; }

    }

}