use of com.yahoo.vdslib.state.NodeState 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.vdslib.state.NodeState in project vespa by vespa-engine.
the class StateVersionTrackerTest method per_node_min_bits_changes_are_not_considered_different.
// For similarity purposes, only the cluster-wide bits matter, not the individual node state
// min used bits. The former is derived from the latter, but the latter is not visible in the
// published state (but _is_ visible in the internal ClusterState structures).
@Test
public void per_node_min_bits_changes_are_not_considered_different() {
final StateVersionTracker versionTracker = createWithMockedMetrics();
final AnnotatedClusterState stateWithMinBits = stateWithoutAnnotations("distributor:2 storage:2");
stateWithMinBits.getClusterState().setNodeState(new Node(NodeType.STORAGE, 0), new NodeState(NodeType.STORAGE, State.UP).setMinUsedBits(15));
updateAndPromote(versionTracker, stateWithMinBits, 123);
versionTracker.updateLatestCandidateStateBundle(stateBundleWithoutAnnotations("distributor:2 storage:2"));
assertFalse(versionTracker.candidateChangedEnoughFromCurrentToWarrantPublish());
}
use of com.yahoo.vdslib.state.NodeState in project vespa by vespa-engine.
the class NodeTest method testNodeNotSeenInSlobrok.
@Test
public void testNodeNotSeenInSlobrok() throws Exception {
setUp(true);
ContentCluster old = music.context.cluster;
music.context.cluster = new ContentCluster(old.getName(), old.getConfiguredNodes().values(), old.getDistribution(), 0, 0.0);
NodeState currentState = new NodeState(NodeType.STORAGE, State.DOWN);
currentState.setDescription("Not seen");
music.context.currentConsolidatedState.setNodeState(new Node(NodeType.STORAGE, 1), currentState);
UnitResponse response = restAPI.getState(new StateRequest("music/storage/1", 0));
String expected = "{\n" + " \"attributes\": {\"hierarchical-group\": \"east.g2\"},\n" + " \"state\": {\n" + " \"generated\": {\n" + " \"state\": \"down\",\n" + " \"reason\": \"Not seen\"\n" + " },\n" + " \"unit\": {\n" + " \"state\": \"down\",\n" + " \"reason\": \"Node not seen in slobrok.\"\n" + " },\n" + " \"user\": {\n" + " \"state\": \"up\",\n" + " \"reason\": \"\"\n" + " }\n" + " }\n" + "}";
assertEquals(expected, jsonWriter.createJson(response).toString(2));
}
use of com.yahoo.vdslib.state.NodeState in project vespa by vespa-engine.
the class DistributionTestFactory method recordResult.
Test recordResult(BucketId bucket) {
Test t = new Test(bucket);
Distribution d = new Distribution(new StorDistributionConfig(distributionConfig));
try {
if (nodeType.equals(NodeType.DISTRIBUTOR)) {
int node = d.getIdealDistributorNode(state, bucket, upStates);
t.nodes.add(node);
} else {
for (int i : d.getIdealStorageNodes(state, bucket, upStates)) {
t.nodes.add(i);
NodeState ns = state.getNodeState(new Node(nodeType, i));
if (ns.getDiskCount() != 0) {
t.disks.add(d.getIdealDisk(ns, i, bucket));
} else {
t.disks.add(-1);
}
}
}
} catch (Distribution.TooFewBucketBitsInUseException e) {
t.failure = Failure.TOO_FEW_BITS;
} catch (Distribution.NoDistributorsAvailableException e) {
t.failure = Failure.NO_DISTRIBUTORS_AVAILABLE;
}
if (results.size() > testsRecorded) {
verifySame(t, results.get(testsRecorded));
} else {
results.add(t);
}
++testsRecorded;
return t;
}
use of com.yahoo.vdslib.state.NodeState in project vespa by vespa-engine.
the class DistributionBitCountTest method setUpSystem.
private void setUpSystem(String testName) throws Exception {
List<ConfiguredNode> configuredNodes = new ArrayList<>();
for (int i = 0; i < 10; i++) {
configuredNodes.add(new ConfiguredNode(i, false));
}
FleetControllerOptions options = new FleetControllerOptions("mycluster", configuredNodes);
options.distributionBits = 17;
setUpFleetController(false, options);
startingTest(testName);
List<DummyVdsNode> nodes = setUpVdsNodes(false, new DummyVdsNodeOptions(), true, configuredNodes);
for (DummyVdsNode node : nodes) {
node.setNodeState(new NodeState(node.getType(), State.UP).setMinUsedBits(20));
node.connect();
}
waitForState("version:\\d+ bits:17 distributor:10 storage:10");
}
Aggregations