use of com.yahoo.jrt.StringValue in project vespa by vespa-engine.
the class RpcServerTest method testGetNodeState.
@Test
public void testGetNodeState() throws Exception {
startingTest("RpcServerTest::testGetNodeState");
Set<ConfiguredNode> configuredNodes = new TreeSet<>();
for (int i = 0; i < 10; i++) configuredNodes.add(new ConfiguredNode(i, false));
FleetControllerOptions options = new FleetControllerOptions("mycluster", configuredNodes);
options.minRatioOfStorageNodesUp = 0;
options.maxInitProgressTime = 30000;
options.stableStateTimePeriod = 60000;
setUpFleetController(true, options);
setUpVdsNodes(true, new DummyVdsNodeOptions());
waitForStableSystem();
setWantedNodeState(State.DOWN, NodeType.DISTRIBUTOR, 2);
setWantedNodeState(State.RETIRED, NodeType.STORAGE, 2);
setWantedNodeState(State.MAINTENANCE, NodeType.STORAGE, 7);
waitForCompleteCycle();
timer.advanceTime(1000000);
// Make fleet controller notice that time has changed before any disconnects
waitForCompleteCycle();
nodes.get(0).disconnect();
nodes.get(3).disconnect();
nodes.get(5).disconnect();
waitForState("version:\\d+ distributor:10 .0.s:d .2.s:d storage:10 .1.s:m .2.s:m .7.s:m");
timer.advanceTime(1000000);
waitForState("version:\\d+ distributor:10 .0.s:d .2.s:d storage:10 .1.s:d .2.s:d .7.s:m");
timer.advanceTime(1000000);
// Make fleet controller notice that time has changed before any disconnects
waitForCompleteCycle();
nodes.get(3).setNodeState(new NodeState(nodes.get(3).getType(), State.INITIALIZING).setInitProgress(0.2));
nodes.get(3).connect();
waitForState("version:\\d+ distributor:10 .0.s:d .2.s:d storage:10 .1.s:i .1.i:0.2 .2.s:d .7.s:m");
int rpcPort = fleetController.getRpcPort();
supervisor = new Supervisor(new Transport());
Target connection = supervisor.connect(new Spec("localhost", rpcPort));
assertTrue(connection.isValid());
Request req = new Request("getNodeState");
req.parameters().add(new StringValue("distributor"));
req.parameters().add(new Int32Value(0));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("ssss"));
assertEquals(State.DOWN, NodeState.deserialize(NodeType.DISTRIBUTOR, req.returnValues().get(0).asString()).getState());
NodeState reported = NodeState.deserialize(NodeType.DISTRIBUTOR, req.returnValues().get(1).asString());
assertTrue(req.returnValues().get(1).asString(), reported.getState().oneOf("d-"));
assertEquals("", req.returnValues().get(2).asString());
req = new Request("getNodeState");
req.parameters().add(new StringValue("distributor"));
req.parameters().add(new Int32Value(2));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("ssss"));
assertEquals(State.DOWN, NodeState.deserialize(NodeType.DISTRIBUTOR, req.returnValues().get(0).asString()).getState());
assertEquals("t:946080000", req.returnValues().get(1).asString());
assertEquals(State.DOWN, NodeState.deserialize(NodeType.DISTRIBUTOR, req.returnValues().get(2).asString()).getState());
req = new Request("getNodeState");
req.parameters().add(new StringValue("distributor"));
req.parameters().add(new Int32Value(4));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("ssss"));
assertEquals("", req.returnValues().get(0).asString());
assertEquals("t:946080000", req.returnValues().get(1).asString());
assertEquals("", req.returnValues().get(2).asString());
req = new Request("getNodeState");
req.parameters().add(new StringValue("distributor"));
req.parameters().add(new Int32Value(15));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.METHOD_FAILED, req.errorCode());
assertEquals("No node distributor.15 exists in cluster mycluster", req.errorMessage());
assertFalse(req.toString(), req.checkReturnTypes("ssss"));
req = new Request("getNodeState");
req.parameters().add(new StringValue("storage"));
req.parameters().add(new Int32Value(1));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("ssss"));
assertEquals("s:i i:0.2", req.returnValues().get(0).asString());
assertEquals("s:i i:0.2", req.returnValues().get(1).asString());
assertEquals("", req.returnValues().get(2).asString());
req = new Request("getNodeState");
req.parameters().add(new StringValue("storage"));
req.parameters().add(new Int32Value(2));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("ssss"));
assertEquals(State.DOWN, NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(0).asString()).getState());
reported = NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(1).asString());
assertTrue(req.returnValues().get(1).asString(), reported.getState().oneOf("d-"));
assertEquals(State.RETIRED, NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(2).asString()).getState());
req = new Request("getNodeState");
req.parameters().add(new StringValue("storage"));
req.parameters().add(new Int32Value(5));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("ssss"));
assertEquals("", req.returnValues().get(0).asString());
assertEquals("t:946080000", req.returnValues().get(1).asString());
assertEquals("", req.returnValues().get(2).asString());
req = new Request("getNodeState");
req.parameters().add(new StringValue("storage"));
req.parameters().add(new Int32Value(7));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("ssss"));
assertEquals(State.MAINTENANCE, NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(0).asString()).getState());
assertEquals("t:946080000", req.returnValues().get(1).asString());
assertEquals(State.MAINTENANCE, NodeState.deserialize(NodeType.STORAGE, req.returnValues().get(2).asString()).getState());
}
use of com.yahoo.jrt.StringValue in project vespa by vespa-engine.
the class RpcServerTest method setWantedNodeState.
private void setWantedNodeState(State newState, NodeType nodeType, int nodeIndex) {
int rpcPort = fleetController.getRpcPort();
if (supervisor == null) {
supervisor = new Supervisor(new Transport());
}
Target connection = supervisor.connect(new Spec("localhost", rpcPort));
assertTrue(connection.isValid());
Node node = new Node(nodeType, nodeIndex);
NodeState newNodeState = new NodeState(nodeType, newState);
Request req = new Request("setNodeState");
req.parameters().add(new StringValue("storage/cluster.mycluster/" + node.getType().toString() + "/" + node.getIndex()));
req.parameters().add(new StringValue(newNodeState.serialize(true)));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("s"));
}
use of com.yahoo.jrt.StringValue in project vespa by vespa-engine.
the class DummyVdsNode method rpc_getNodeState.
public void rpc_getNodeState(Request req) {
synchronized (timer) {
if (!negotiatedHandle) {
req.setError(75000, "Connection not bound to a handle");
return;
}
String stateString = nodeState.serialize(-1, true);
log.log(LogLevel.DEBUG, "Dummy node " + this + " got old type get node state request, answering: " + stateString);
req.returnValues().add(new Int32Value(1));
req.returnValues().add(new StringValue(""));
req.returnValues().add(new StringValue(stateString));
req.returnValues().add(new Int32Value(0));
}
}
use of com.yahoo.jrt.StringValue in project vespa by vespa-engine.
the class DummyVdsNode method rpc_setSystemState.
public void rpc_setSystemState(Request req) {
try {
if (shouldFailSetSystemStateRequests()) {
req.setError(ErrorCode.GENERAL_ERROR, "Dummy node configured to fail setSystemState() calls");
return;
}
if (!negotiatedHandle) {
req.setError(75000, "Connection not bound to a handle");
return;
}
ClusterState newState = new ClusterState(req.parameters().get(0).asString());
synchronized (timer) {
updateStartTimestamps(newState);
systemState.add(0, newState);
timer.notifyAll();
}
req.returnValues().add(new Int32Value(1));
req.returnValues().add(new StringValue("OK"));
log.log(LogLevel.DEBUG, "Dummy node " + this + ": Got new system state (through old setsystemstate call) " + newState);
} catch (Exception e) {
log.log(LogLevel.ERROR, "Dummy node " + this + ": An error occured when answering setsystemstate request: " + e.getMessage());
e.printStackTrace(System.err);
req.returnValues().add(new Int32Value(ErrorCode.METHOD_FAILED));
req.returnValues().add(new StringValue(e.getMessage()));
}
}
use of com.yahoo.jrt.StringValue in project vespa by vespa-engine.
the class DummyVdsNode method replyToPendingNodeStateRequests.
public void replyToPendingNodeStateRequests() {
for (Req req : waitingRequests) {
log.log(LogLevel.DEBUG, "Dummy node " + this + " answering pending node state request.");
req.request.returnValues().add(new StringValue(nodeState.serialize()));
if (req.request.methodName().equals("getnodestate3")) {
req.request.returnValues().add(new StringValue("Dummy node host info"));
}
req.request.returnRequest();
++setNodeStateReplies;
}
waitingRequests.clear();
}
Aggregations