blob: eaeec8abae7059183fce46bd8415426850fe06d5 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.clustercontroller.core.rpc;
import com.yahoo.jrt.ErrorCode;
import com.yahoo.jrt.Request;
import com.yahoo.jrt.RequestWaiter;
import com.yahoo.vespa.clustercontroller.core.Communicator;
import com.yahoo.vespa.clustercontroller.core.NodeInfo;
import com.yahoo.vespa.clustercontroller.core.SetClusterStateRequest;
/**
* Waiter class for set cluster state RPC commands.
*/
public class RPCSetClusterStateWaiter implements RequestWaiter {
SetClusterStateRequest request;
Communicator.Waiter<SetClusterStateRequest> waiter;
public RPCSetClusterStateWaiter(Communicator.Waiter<SetClusterStateRequest> waiter) {
this.waiter = waiter;
}
public void setRequest(RPCSetClusterStateRequest request) {
this.request = request;
}
public SetClusterStateRequest.Reply getReply(Request req) {
NodeInfo info = request.getNodeInfo();
if (req.methodName().equals(RPCCommunicator.SET_DISTRIBUTION_STATES_RPC_METHOD_NAME)) {
if (req.isError()) {
return new SetClusterStateRequest.Reply(req.errorCode(), req.errorMessage());
} else if (!req.checkReturnTypes("")) {
return new SetClusterStateRequest.Reply(ErrorCode.BAD_REPLY, "Got RPC response with invalid return types from " + info);
}
} else {
return new SetClusterStateRequest.Reply(ErrorCode.BAD_REPLY, "Unknown method " + req.methodName());
}
return new SetClusterStateRequest.Reply();
}
@Override
public void handleRequestDone(Request request) {
SetClusterStateRequest.Reply reply = getReply(request);
this.request.setReply(reply);
waiter.done(this.request);
}
}
|