use of com.yahoo.jrt.Transport in project vespa by vespa-engine.
the class RpcServerTest method testGetSystemState.
@Test
public void testGetSystemState() throws Exception {
LogFormatter.initializeLogging();
startingTest("RpcServerTest::testGetSystemState");
FleetControllerOptions options = new FleetControllerOptions("mycluster");
setUpFleetController(true, options);
setUpVdsNodes(true, new DummyVdsNodeOptions());
waitForStableSystem();
assertEquals(true, nodes.get(0).isDistributor());
log.log(LogLevel.INFO, "Disconnecting distributor 0. Waiting for state to reflect change.");
nodes.get(0).disconnect();
nodes.get(19).disconnect();
fleetController.waitForNodesInSlobrok(9, 9, timeoutMS);
timer.advanceTime(options.nodeStateRequestTimeoutMS + options.maxSlobrokDisconnectGracePeriod);
wait(new WaitCondition.StateWait(fleetController, fleetController.getMonitor()) {
@Override
public String isConditionMet() {
if (currentState == null) {
return "No cluster state defined yet";
}
NodeState distState = currentState.getNodeState(new Node(NodeType.DISTRIBUTOR, 0));
if (distState.getState() != State.DOWN) {
return "Distributor not detected down yet: " + currentState.toString();
}
NodeState storState = currentState.getNodeState(new Node(NodeType.STORAGE, 9));
if (!storState.getState().oneOf("md")) {
return "Storage node not detected down yet: " + currentState.toString();
}
return null;
}
}, null, timeoutMS);
int rpcPort = fleetController.getRpcPort();
supervisor = new Supervisor(new Transport());
Target connection = supervisor.connect(new Spec("localhost", rpcPort));
assertTrue(connection.isValid());
Request req = new Request("getSystemState");
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("ss"));
String systemState = req.returnValues().get(1).asString();
ClusterState retrievedClusterState = new ClusterState(systemState);
assertEquals(systemState, State.DOWN, retrievedClusterState.getNodeState(new Node(NodeType.DISTRIBUTOR, 0)).getState());
assertTrue(systemState, retrievedClusterState.getNodeState(new Node(NodeType.STORAGE, 9)).getState().oneOf("md"));
}
use of com.yahoo.jrt.Transport in project vespa by vespa-engine.
the class RpcServerTest method testSetNodeState.
@Test
public void testSetNodeState() throws Exception {
startingTest("RpcServerTest::testSetNodeState");
FleetControllerOptions options = new FleetControllerOptions("mycluster");
Set<Integer> nodeIndexes = new TreeSet<>(Arrays.asList(new Integer[] { 4, 6, 9, 10, 14, 16, 21, 22, 23, 25 }));
options.setStorageDistribution(new Distribution(getDistConfig(nodeIndexes)));
setUpFleetController(true, options);
setUpVdsNodes(true, new DummyVdsNodeOptions(), false, nodeIndexes);
waitForState("version:\\d+ distributor:26 .0.s:d .1.s:d .2.s:d .3.s:d .5.s:d .7.s:d .8.s:d .11.s:d .12.s:d .13.s:d .15.s:d .17.s:d .18.s:d .19.s:d .20.s:d .24.s:d storage:26 .0.s:d .1.s:d .2.s:d .3.s:d .5.s:d .7.s:d .8.s:d .11.s:d .12.s:d .13.s:d .15.s:d .17.s:d .18.s:d .19.s:d .20.s:d .24.s:d");
int rpcPort = fleetController.getRpcPort();
supervisor = new Supervisor(new Transport());
Target connection = supervisor.connect(new Spec("localhost", rpcPort));
assertTrue(connection.isValid());
Request req = new Request("setNodeState");
req.parameters().add(new StringValue("storage/cluster.mycluster/storage/14"));
req.parameters().add(new StringValue("s:r"));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("s"));
waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:r .*");
req = new Request("setNodeState");
req.parameters().add(new StringValue("storage/cluster.mycluster/storage/16"));
req.parameters().add(new StringValue("s:m"));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
assertTrue(req.toString(), req.checkReturnTypes("s"));
ClusterState state = waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:r.* .16.s:m .*");
nodes.get(5 * 2 + 1).disconnect();
waitForCompleteCycle();
timer.advanceTime(100000000);
waitForCompleteCycle();
assertEquals(State.MAINTENANCE, fleetController.getSystemState().getNodeState(new Node(NodeType.STORAGE, 16)).getState());
nodes.get(4 * 2 + 1).disconnect();
waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:m.* .16.s:m .*");
nodes.get(4 * 2 + 1).connect();
timer.advanceTime(100000000);
// Might need to pass more actual time while waiting below?
waitForState("version:\\d+ distributor:26 .* storage:26 .* .14.s:r.* .16.s:m .*");
}
use of com.yahoo.jrt.Transport in project vespa by vespa-engine.
the class RpcServerTest method testSetNodeStateOutOfRange.
@Test
public void testSetNodeStateOutOfRange() throws Exception {
startingTest("RpcServerTest::testSetNodeStateOutOfRange");
FleetControllerOptions options = new FleetControllerOptions("mycluster");
options.setStorageDistribution(new Distribution(Distribution.getDefaultDistributionConfig(2, 10)));
setUpFleetController(true, options);
setUpVdsNodes(true, new DummyVdsNodeOptions());
waitForStableSystem();
int rpcPort = fleetController.getRpcPort();
supervisor = new Supervisor(new Transport());
Target connection = supervisor.connect(new Spec("localhost", rpcPort));
assertTrue(connection.isValid());
Request req = new Request("setNodeState");
req.parameters().add(new StringValue("storage/cluster.mycluster/storage/10"));
req.parameters().add(new StringValue("s:m"));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.METHOD_FAILED, req.errorCode());
assertEquals(req.toString(), "Cannot set wanted state of node storage.10. Index does not correspond to a configured node.", req.errorMessage());
req = new Request("setNodeState");
req.parameters().add(new StringValue("storage/cluster.mycluster/distributor/10"));
req.parameters().add(new StringValue("s:m"));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.METHOD_FAILED, req.errorCode());
assertEquals(req.toString(), "Cannot set wanted state of node distributor.10. Index does not correspond to a configured node.", req.errorMessage());
req = new Request("setNodeState");
req.parameters().add(new StringValue("storage/cluster.mycluster/storage/9"));
req.parameters().add(new StringValue("s:m"));
connection.invokeSync(req, timeoutS);
assertEquals(req.toString(), ErrorCode.NONE, req.errorCode());
waitForState("version:\\d+ distributor:10 storage:10 .9.s:m");
}
use of com.yahoo.jrt.Transport in project vespa by vespa-engine.
the class RpcServer method connect.
public void connect() throws ListenFailedException, UnknownHostException {
disconnect();
log.log(LogLevel.DEBUG, "Fleetcontroller " + fleetControllerIndex + ": Connecting RPC server.");
if (supervisor != null)
disconnect();
supervisor = new Supervisor(new Transport());
addMethods();
log.log(LogLevel.DEBUG, "Fleetcontroller " + fleetControllerIndex + ": Attempting to bind to port " + port);
acceptor = supervisor.listen(new Spec(port));
log.log(LogLevel.DEBUG, "Fleetcontroller " + fleetControllerIndex + ": RPC server listening to port " + acceptor.port());
StringBuffer slobroks = new StringBuffer("(");
for (String s : slobrokConnectionSpecs) {
slobroks.append(" ").append(s);
}
slobroks.append(" )");
SlobrokList slist = new SlobrokList();
slist.setup(slobrokConnectionSpecs);
Spec spec = new Spec(HostName.getLocalhost(), acceptor.port());
log.log(LogLevel.INFO, "Registering " + spec + " with slobrok at " + slobroks);
if (slobrokBackOffPolicy != null) {
register = new Register(supervisor, slist, spec, slobrokBackOffPolicy);
} else {
register = new Register(supervisor, slist, spec);
}
register.registerName(getSlobrokName());
}
use of com.yahoo.jrt.Transport in project vespa by vespa-engine.
the class SlobrokClient method setSlobrokConnectionSpecs.
public void setSlobrokConnectionSpecs(String[] slobrokConnectionSpecs) {
if (equalsExistingSpec(slobrokConnectionSpecs))
return;
this.connectionSpecs = slobrokConnectionSpecs;
shutdown();
supervisor = new Supervisor(new Transport());
SlobrokList slist = new SlobrokList();
slist.setup(slobrokConnectionSpecs);
mirror = new Mirror(supervisor, slist);
freshMirror = true;
}
Aggregations