use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class StateChangeHandlerTest method markNodeBackIntoSlobrok.
private void markNodeBackIntoSlobrok(Node node, State state) {
final ClusterState stateBefore = currentClusterState();
log.info("Marking " + node + " back in slobrok");
cluster.getNodeInfo(node).markRpcAddressLive();
nodeStateChangeHandler.handleReturnedRpcAddress(cluster.getNodeInfo(node));
nodeStateChangeHandler.handleNewReportedNodeState(stateBefore, cluster.getNodeInfo(node), new NodeState(node.getType(), state), nodeStateUpdateListener);
cluster.getNodeInfo(node).setReportedState(new NodeState(node.getType(), state), clock.getCurrentTimeInMillis());
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class StateChangeHandlerTest method markNodeOutOfSlobrok.
private void markNodeOutOfSlobrok(Node node) {
final ClusterState stateBefore = currentClusterState();
log.info("Marking " + node + " out of slobrok");
cluster.getNodeInfo(node).markRpcAddressOutdated(clock);
nodeStateChangeHandler.handleMissingNode(stateBefore, cluster.getNodeInfo(node), nodeStateUpdateListener);
assertTrue(eventLog.toString(), eventLog.toString().contains("Node is no longer in slobrok"));
eventLog.clear();
}
use of com.yahoo.vdslib.state.ClusterState in project vespa by vespa-engine.
the class ContentClusterHtmlRendrerTest method before.
@Before
public void before() throws JSONException, ParseException {
final ClusterState state = new ClusterState("version:34633 bits:24 distributor:211 storage:211");
final EventLog eventLog = new EventLog(new FakeTimer(), null);
final VdsClusterHtmlRendrer.Table table = rendrer.createNewClusterHtmlTable(clusterName, slobrokGeneration);
final ContentCluster contentCluster = mock(ContentCluster.class);
for (int x = 0; x < 10; x++) {
NodeInfo nodeInfo = new DistributorNodeInfo(contentCluster, x, "dist " + x, null);
final Writer writer = new StringWriter();
new JSONWriter(writer).object().key("vtag").object().key("version").value("release1" + (x == 2 ? "bad" : "")).endObject().endObject();
nodeInfo.setHostInfo(HostInfo.createHostInfo(writer.toString()));
distributorNodeInfoByIndex.put(x, nodeInfo);
}
storageNodeInfoByIndex.put(2, new StorageNodeInfo(contentCluster, 2, false, "storage" + 2, null));
ClusterStatsAggregator statsAggregator = new ClusterStatsAggregator(Sets.newHashSet(2), Sets.newHashSet(2));
table.renderNodes(storageNodeInfoByIndex, distributorNodeInfoByIndex, new FakeTimer(), state, statsAggregator, 1.0, 10, eventLog, "pathPrefix", "name");
final StringBuilder stringBuilder = new StringBuilder();
table.addTable(stringBuilder, 34);
result = stringBuilder.toString();
}
use of com.yahoo.vdslib.state.ClusterState 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.vdslib.state.ClusterState 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 .*");
}
Aggregations