use of com.yahoo.vdslib.state.Node 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.Node 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.Node in project vespa by vespa-engine.
the class ClusterInfo method setNodes.
/**
* Sets the nodes which belongs to this cluster
*/
void setNodes(Collection<ConfiguredNode> newNodes, ContentCluster owner, Distribution distribution) {
// Remove info for removed nodes
Set<ConfiguredNode> newNodesSet = new HashSet<>(newNodes);
for (ConfiguredNode existingNode : this.nodes.values()) {
if (!newNodesSet.contains(existingNode)) {
Node existingStorageNode = storageNodeInfo.remove(existingNode.index()).getNode();
Node existingDistributorNode = distributorNodeInfo.remove(existingNode.index()).getNode();
allNodeInfo.remove(existingDistributorNode);
allNodeInfo.remove(existingStorageNode);
}
}
// Add and update new nodes info
for (ConfiguredNode node : newNodes) {
if (!nodes.containsKey(node.index())) {
// add new node info
addNodeInfo(new DistributorNodeInfo(owner, node.index(), null, distribution));
addNodeInfo(new StorageNodeInfo(owner, node.index(), node.retired(), null, distribution));
} else {
getStorageNodeInfo(node.index()).setConfiguredRetired(node.retired());
}
}
// Update node set
nodes.clear();
for (ConfiguredNode node : newNodes) {
this.nodes.put(node.index(), node);
}
}
use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.
the class SlobrokClient method updateCluster.
public boolean updateCluster(ContentCluster cluster, NodeAddedOrRemovedListener listener) {
if (mirror == null)
return false;
int mirrorVersion = mirror.updates();
if (freshMirror) {
freshMirror = false;
} else if (cluster.getSlobrokGenerationCount() == mirrorVersion) {
if (log.isLoggable(LogLevel.SPAM)) {
log.log(LogLevel.SPAM, "Slobrok still at generation count " + cluster.getSlobrokGenerationCount() + ". Not updating.");
}
return false;
}
// Set to unused value until we are done processing info.
cluster.setSlobrokGenerationCount(0);
Map<Node, SlobrokData> distributorRpc = getSlobrokData("storage/cluster." + cluster.getName() + "/distributor/*");
Map<Node, SlobrokData> distributorMbus = getSlobrokData("storage/cluster." + cluster.getName() + "/distributor/*/default");
Map<Node, SlobrokData> storageRpc = getSlobrokData("storage/cluster." + cluster.getName() + "/storage/*");
Map<Node, SlobrokData> storageMbus = getSlobrokData("storage/cluster." + cluster.getName() + "/storage/*/default");
Map<Node, SlobrokData> slobrokNodes = new TreeMap<>();
for (SlobrokData data : distributorRpc.values()) {
if (distributorMbus.containsKey(data.node)) {
slobrokNodes.put(data.node, data);
}
}
for (SlobrokData data : storageRpc.values()) {
if (storageMbus.containsKey(data.node)) {
slobrokNodes.put(data.node, data);
}
}
List<SlobrokData> newNodes = new LinkedList<>();
List<NodeInfo> missingNodeInfos = new LinkedList<>();
List<SlobrokData> alteredRpcAddressNodes = new LinkedList<>();
List<NodeInfo> returningNodeInfos = new LinkedList<>();
detectNewAndMissingNodes(cluster, slobrokNodes, newNodes, missingNodeInfos, alteredRpcAddressNodes, returningNodeInfos);
for (SlobrokData data : newNodes) {
// XXX we really would like to cross-check the actual RPC address against what's configured,
// but this information does not seem to be available to the cluster controller currently.
NodeInfo nodeInfo = cluster.clusterInfo().getNodeInfo(data.node);
// slobrok may contain nonconfigured nodes during state transitions
if (nodeInfo == null)
continue;
cluster.clusterInfo().setRpcAddress(data.node, data.rpcAddress);
if (listener != null)
// TODO: We'll never add new nodes here, move this to where clusterInfo.setNodes is called?
listener.handleNewNode(nodeInfo);
}
for (NodeInfo nodeInfo : missingNodeInfos) {
nodeInfo.markRpcAddressOutdated(timer);
if (listener != null)
listener.handleMissingNode(nodeInfo);
}
for (SlobrokData data : alteredRpcAddressNodes) {
// TODO: Abort the current node state requests? See NodeInfo.abortCurrentNodeStateRequests()
NodeInfo nodeInfo = cluster.clusterInfo().setRpcAddress(data.node, data.rpcAddress);
if (listener != null) {
// TODO: We'll never add new nodes here, move this to where clusterInfo.setNodes is called?
listener.handleNewRpcAddress(nodeInfo);
}
}
for (NodeInfo nodeInfo : returningNodeInfos) {
nodeInfo.markRpcAddressLive();
nodeInfo.abortCurrentNodeStateRequests();
if (listener != null) {
listener.handleReturnedRpcAddress(nodeInfo);
}
}
cluster.setSlobrokGenerationCount(mirrorVersion);
for (NodeInfo nodeInfo : cluster.getNodeInfo()) {
if (slobrokNodes.containsKey(nodeInfo.getNode()) && nodeInfo.isRpcAddressOutdated()) {
log.log(LogLevel.WARNING, "Node " + nodeInfo + " was tagged NOT in slobrok even though it is. It was in the following lists:" + (newNodes.contains(nodeInfo.getNode()) ? " newNodes" : "") + (missingNodeInfos.contains(nodeInfo) ? " missingNodes" : "") + (alteredRpcAddressNodes.contains(nodeInfo.getNode()) ? " alteredNodes" : "") + (returningNodeInfos.contains(nodeInfo) ? " returningNodes" : ""));
nodeInfo.markRpcAddressLive();
}
}
log.log(LogLevel.SPAM, "Slobrok information updated to generation " + cluster.getSlobrokGenerationCount());
return true;
}
use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.
the class DummyCommunicator method updateCluster.
@Override
public boolean updateCluster(ContentCluster cluster, NodeAddedOrRemovedListener listener) {
if (newNodes != null) {
List<Node> tmp = newNodes;
for (Node node : tmp) cluster.clusterInfo().setRpcAddress(node, "foo");
for (NodeInfo info : cluster.getNodeInfo()) {
if (!tmp.contains(info.getNode())) {
info.markRpcAddressOutdated(timer);
listener.handleMissingNode(info);
}
}
newNodes = null;
return true;
}
return false;
}
Aggregations