Search in sources :

Example 16 with ConfiguredNode

use of com.yahoo.vdslib.distribution.ConfiguredNode in project vespa by vespa-engine.

the class FleetControllerTest method setUpVdsNodes.

// TODO: Replace all usages of the above setUp methods with this one, and remove the nodes field
/**
 * Creates dummy vds nodes for the list of configured nodes and returns them.
 * As two dummy nodes are created for each configured node - one distributor and one storage node -
 * the returned list is twice as large as configuredNodes.
 */
protected List<DummyVdsNode> setUpVdsNodes(boolean useFakeTimer, DummyVdsNodeOptions options, boolean startDisconnected, List<ConfiguredNode> configuredNodes) throws Exception {
    String[] connectionSpecs = new String[1];
    connectionSpecs[0] = "tcp/localhost:" + slobrok.port();
    nodes = new ArrayList<>();
    final boolean distributor = true;
    for (ConfiguredNode configuredNode : configuredNodes) {
        nodes.add(new DummyVdsNode(useFakeTimer ? timer : new RealTimer(), options, connectionSpecs, this.options.clusterName, distributor, configuredNode.index()));
        if (!startDisconnected)
            nodes.get(nodes.size() - 1).connect();
        nodes.add(new DummyVdsNode(useFakeTimer ? timer : new RealTimer(), options, connectionSpecs, this.options.clusterName, !distributor, configuredNode.index()));
        if (!startDisconnected)
            nodes.get(nodes.size() - 1).connect();
    }
    return nodes;
}
Also used : ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode)

Example 17 with ConfiguredNode

use of com.yahoo.vdslib.distribution.ConfiguredNode in project vespa by vespa-engine.

the class NodeStateChangeCheckerTest method createStorageNodeInfo.

private StorageNodeInfo createStorageNodeInfo(int index, State state) {
    Distribution distribution = mock(Distribution.class);
    Group group = new Group(2, "to");
    when(distribution.getRootGroup()).thenReturn(group);
    String clusterName = "Clustername";
    Set<ConfiguredNode> configuredNodeIndexes = new HashSet<>();
    ContentCluster cluster = new ContentCluster(clusterName, configuredNodeIndexes, distribution, minStorageNodesUp, 0.0);
    String rpcAddress = "";
    StorageNodeInfo storageNodeInfo = new StorageNodeInfo(cluster, index, false, rpcAddress, distribution);
    storageNodeInfo.setReportedState(new NodeState(NodeType.STORAGE, state), 3);
    return storageNodeInfo;
}
Also used : Group(com.yahoo.vdslib.distribution.Group) NodeState(com.yahoo.vdslib.state.NodeState) Distribution(com.yahoo.vdslib.distribution.Distribution) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) StringContains.containsString(org.hamcrest.core.StringContains.containsString) HashSet(java.util.HashSet)

Example 18 with ConfiguredNode

use of com.yahoo.vdslib.distribution.ConfiguredNode in project vespa by vespa-engine.

the class RpcVersionAutoDowngradeTest method setUpFakeCluster.

private void setUpFakeCluster(int nodeRpcVersion) 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);
    setUpFleetController(false, options);
    DummyVdsNodeOptions nodeOptions = new DummyVdsNodeOptions();
    nodeOptions.stateCommunicationVersion = nodeRpcVersion;
    List<DummyVdsNode> nodes = setUpVdsNodes(false, nodeOptions, true, configuredNodes);
    for (DummyVdsNode node : nodes) {
        node.setNodeState(new NodeState(node.getType(), State.UP).setMinUsedBits(20));
        node.connect();
    }
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ArrayList(java.util.ArrayList)

Example 19 with ConfiguredNode

use of com.yahoo.vdslib.distribution.ConfiguredNode in project vespa by vespa-engine.

the class StateChangeHandlerTest method startWithStableStateClusterWithNodesUp.

private void startWithStableStateClusterWithNodesUp() {
    for (NodeType type : NodeType.getTypes()) {
        for (ConfiguredNode i : configuredNodes) {
            NodeInfo nodeInfo = cluster.clusterInfo().setRpcAddress(new Node(type, i.index()), null);
            nodeInfo.markRpcAddressLive();
            nodeStateChangeHandler.handleNewReportedNodeState(currentClusterState(), nodeInfo, new NodeState(type, State.UP), null);
            nodeInfo.setReportedState(new NodeState(type, State.UP), clock.getCurrentTimeInMillis());
        }
    }
    for (NodeType type : NodeType.getTypes()) {
        for (ConfiguredNode i : configuredNodes) {
            Node n = new Node(type, i.index());
            assertEquals(State.UP, currentClusterState().getNodeState(n).getState());
        }
    }
    clock.advanceTime(config.stableStateTime);
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) NodeType(com.yahoo.vdslib.state.NodeType) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Node(com.yahoo.vdslib.state.Node)

Example 20 with ConfiguredNode

use of com.yahoo.vdslib.distribution.ConfiguredNode in project vespa by vespa-engine.

the class DistributionBuilder method forHierarchicCluster.

public static Distribution forHierarchicCluster(GroupBuilder root) {
    List<ConfiguredNode> nodes = buildConfiguredNodes(root.totalNodeCount());
    StorDistributionConfig.Builder configBuilder = new StorDistributionConfig.Builder();
    configBuilder.redundancy(2);
    StorDistributionConfig.Group.Builder rootBuilder = new StorDistributionConfig.Group.Builder();
    rootBuilder.name("invalid");
    rootBuilder.index("invalid");
    rootBuilder.partitions(root.groupDistributionSpec());
    configBuilder.group(rootBuilder);
    int offset = 0;
    for (int group = 0; group < root.groupsWithNodeCount.size(); ++group) {
        int nodeCount = root.groupsWithNodeCount.get(group);
        StorDistributionConfig.Group.Builder groupBuilder = configuredGroup("group_" + (group + 1), group + 1, nodes.subList(offset, offset + nodeCount));
        configBuilder.group(groupBuilder);
        offset += nodeCount;
    }
    return new Distribution(new StorDistributionConfig(configBuilder));
}
Also used : StorDistributionConfig(com.yahoo.vespa.config.content.StorDistributionConfig) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Distribution(com.yahoo.vdslib.distribution.Distribution)

Aggregations

ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)26 Test (org.junit.Test)8 NodeState (com.yahoo.vdslib.state.NodeState)7 Distribution (com.yahoo.vdslib.distribution.Distribution)6 HashSet (java.util.HashSet)5 Node (com.yahoo.vdslib.state.Node)3 ArrayList (java.util.ArrayList)3 Group (com.yahoo.vdslib.distribution.Group)2 ClusterState (com.yahoo.vdslib.state.ClusterState)2 NodeType (com.yahoo.vdslib.state.NodeType)2 StorDistributionConfig (com.yahoo.vespa.config.content.StorDistributionConfig)2 Int32Value (com.yahoo.jrt.Int32Value)1 Request (com.yahoo.jrt.Request)1 Spec (com.yahoo.jrt.Spec)1 StringValue (com.yahoo.jrt.StringValue)1 Supervisor (com.yahoo.jrt.Supervisor)1 Target (com.yahoo.jrt.Target)1 Transport (com.yahoo.jrt.Transport)1 DatabaseHandler (com.yahoo.vespa.clustercontroller.core.database.DatabaseHandler)1 VdsClusterHtmlRendrer (com.yahoo.vespa.clustercontroller.core.status.statuspage.VdsClusterHtmlRendrer)1