Search in sources :

Example 31 with Node

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));
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) UnitResponse(com.yahoo.vespa.clustercontroller.utils.staterestapi.response.UnitResponse) Node(com.yahoo.vdslib.state.Node) ContentCluster(com.yahoo.vespa.clustercontroller.core.ContentCluster) Test(org.junit.Test)

Example 32 with Node

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;
}
Also used : StorDistributionConfig(com.yahoo.vespa.config.content.StorDistributionConfig) NodeState(com.yahoo.vdslib.state.NodeState) Node(com.yahoo.vdslib.state.Node)

Example 33 with Node

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);
    }
}
Also used : ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Node(com.yahoo.vdslib.state.Node) HashSet(java.util.HashSet)

Example 34 with 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;
}
Also used : NodeInfo(com.yahoo.vespa.clustercontroller.core.NodeInfo) Node(com.yahoo.vdslib.state.Node)

Example 35 with Node

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;
}
Also used : Node(com.yahoo.vdslib.state.Node)

Aggregations

Node (com.yahoo.vdslib.state.Node)65 Test (org.junit.Test)34 NodeState (com.yahoo.vdslib.state.NodeState)32 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)31 ClusterFixture.storageNode (com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode)15 HasStateReasonForNode.hasStateReasonForNode (com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForNode.hasStateReasonForNode)15 ClusterState (com.yahoo.vdslib.state.ClusterState)9 NodeInfo (com.yahoo.vespa.clustercontroller.core.NodeInfo)6 NodeType (com.yahoo.vdslib.state.NodeType)5 PrintWriter (java.io.PrintWriter)5 StringWriter (java.io.StringWriter)5 Request (com.yahoo.jrt.Request)4 State (com.yahoo.vdslib.state.State)4 IOException (java.io.IOException)4 Spec (com.yahoo.jrt.Spec)3 StringValue (com.yahoo.jrt.StringValue)3 Supervisor (com.yahoo.jrt.Supervisor)3 Target (com.yahoo.jrt.Target)3 Transport (com.yahoo.jrt.Transport)3 TreeMap (java.util.TreeMap)3