Search in sources :

Example 1 with ConfiguredNode

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

the class ContentCluster method writeHtmlState.

public void writeHtmlState(final VdsClusterHtmlRendrer vdsClusterHtmlRendrer, final StringBuilder sb, final Timer timer, final ClusterState state, final ClusterStatsAggregator statsAggregator, final Distribution distribution, final FleetControllerOptions options, final EventLog eventLog) {
    final VdsClusterHtmlRendrer.Table table = vdsClusterHtmlRendrer.createNewClusterHtmlTable(clusterName, slobrokGenerationCount);
    final List<Group> groups = LeafGroups.enumerateFrom(distribution.getRootGroup());
    for (int j = 0; j < groups.size(); ++j) {
        final Group group = groups.get(j);
        assert (group != null);
        final String localName = group.getUnixStylePath();
        assert (localName != null);
        final TreeMap<Integer, NodeInfo> storageNodeInfoByIndex = new TreeMap<>();
        final TreeMap<Integer, NodeInfo> distributorNodeInfoByIndex = new TreeMap<>();
        for (ConfiguredNode configuredNode : group.getNodes()) {
            storeNodeInfo(configuredNode.index(), NodeType.STORAGE, storageNodeInfoByIndex);
            storeNodeInfo(configuredNode.index(), NodeType.DISTRIBUTOR, distributorNodeInfoByIndex);
        }
        table.renderNodes(storageNodeInfoByIndex, distributorNodeInfoByIndex, timer, state, statsAggregator, options.minMergeCompletionRatio, options.maxPrematureCrashes, eventLog, clusterName, localName);
    }
    table.addTable(sb, options.stableStateTimePeriod);
}
Also used : Group(com.yahoo.vdslib.distribution.Group) VdsClusterHtmlRendrer(com.yahoo.vespa.clustercontroller.core.status.statuspage.VdsClusterHtmlRendrer) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode)

Example 2 with ConfiguredNode

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

the class GroupAutoTakedownTest method downed_config_retired_node_transitions_back_to_retired_on_up_edge.

@Test
public void downed_config_retired_node_transitions_back_to_retired_on_up_edge() {
    ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.49);
    assertEquals("distributor:6 storage:6 .4.s:d", stateAfterStorageTransition(fixture, 4, State.DOWN));
    assertEquals("distributor:6 storage:4", stateAfterStorageTransition(fixture, 5, State.DOWN));
    // Node 5 gets config-retired under our feet.
    Set<ConfiguredNode> nodes = new HashSet<>(fixture.cluster.clusterInfo().getConfiguredNodes().values());
    nodes.remove(new ConfiguredNode(5, false));
    nodes.add(new ConfiguredNode(5, true));
    // TODO this should ideally also set the retired flag in the distribution
    // config, but only the ConfiguredNodes are actually looked at currently.
    fixture.cluster.setNodes(nodes);
    assertEquals("distributor:6 storage:6 .4.s:d .5.s:r", stateAfterStorageTransition(fixture, 5, State.UP));
}
Also used : ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with ConfiguredNode

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

the class GroupAutoTakedownTest method previously_cleared_start_timestamps_are_not_reintroduced_on_up_edge.

@Test
public void previously_cleared_start_timestamps_are_not_reintroduced_on_up_edge() throws Exception {
    ClusterFixture fixture = createFixtureForAllUpHierarchicCluster(DistributionBuilder.withGroups(3).eachWithNodeCount(2), 0.51);
    final NodeState newState = new NodeState(NodeType.STORAGE, State.UP);
    newState.setStartTimestamp(123456);
    fixture.reportStorageNodeState(4, newState);
    assertEquals("distributor:6 storage:6 .4.t:123456", fixture.generatedClusterState());
    DatabaseHandler handler = mock(DatabaseHandler.class);
    DatabaseHandler.Context context = mock(DatabaseHandler.Context.class);
    when(context.getCluster()).thenReturn(fixture.cluster);
    Set<ConfiguredNode> nodes = new HashSet<>(fixture.cluster.clusterInfo().getConfiguredNodes().values());
    fixture.nodeStateChangeHandler.handleAllDistributorsInSync(fixture.annotatedGeneratedClusterState().getClusterState(), nodes, handler, context);
    // Timestamp should now be cleared from state
    assertEquals("distributor:6 storage:6", fixture.generatedClusterState());
    // Trigger a group down+up edge. Timestamp should _not_ be reintroduced since it was previously cleared.
    assertEquals("distributor:6 storage:4", stateAfterStorageTransition(fixture, 5, State.DOWN));
    assertEquals("distributor:6 storage:6", stateAfterStorageTransition(fixture, 5, State.UP));
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) DatabaseHandler(com.yahoo.vespa.clustercontroller.core.database.DatabaseHandler) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with ConfiguredNode

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

the class StateChangeHandlerTest method initialize.

private void initialize(Config config) {
    Distribution distribution = new Distribution(Distribution.getDefaultDistributionConfig(2, 100));
    this.config = config;
    for (int i = 0; i < config.nodeCount; ++i) configuredNodes.add(new ConfiguredNode(i, false));
    cluster = new ContentCluster("testcluster", configuredNodes, distribution, 0, 0.0);
    nodeStateChangeHandler = new StateChangeHandler(clock, eventLog, null);
    params.minStorageNodesUp(1).minDistributorNodesUp(1).minRatioOfStorageNodesUp(0.0).minRatioOfDistributorNodesUp(0.0).maxPrematureCrashes(config.maxPrematureCrashes).transitionTimes(5000).cluster(cluster);
    nodeStateUpdateListener = new TestNodeStateOrHostInfoChangeHandler();
}
Also used : Distribution(com.yahoo.vdslib.distribution.Distribution) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode)

Example 5 with ConfiguredNode

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

the class StateChangeHandler method handleAllDistributorsInSync.

public void handleAllDistributorsInSync(final ClusterState currentState, final Set<ConfiguredNode> nodes, final DatabaseHandler database, final DatabaseHandler.Context dbContext) throws InterruptedException {
    int startTimestampsReset = 0;
    log.log(LogLevel.DEBUG, String.format("handleAllDistributorsInSync invoked for state version %d", currentState.getVersion()));
    for (NodeType nodeType : NodeType.getTypes()) {
        for (ConfiguredNode configuredNode : nodes) {
            final Node node = new Node(nodeType, configuredNode.index());
            final NodeInfo nodeInfo = dbContext.getCluster().getNodeInfo(node);
            final NodeState nodeState = currentState.getNodeState(node);
            if (nodeInfo != null && nodeState != null) {
                if (nodeState.getStartTimestamp() > nodeInfo.getStartTimestamp()) {
                    if (log.isLoggable(LogLevel.DEBUG)) {
                        log.log(LogLevel.DEBUG, String.format("Storing away new start timestamp for node %s (%d)", node, nodeState.getStartTimestamp()));
                    }
                    nodeInfo.setStartTimestamp(nodeState.getStartTimestamp());
                }
                if (nodeState.getStartTimestamp() > 0) {
                    if (log.isLoggable(LogLevel.DEBUG)) {
                        log.log(LogLevel.DEBUG, String.format("Resetting timestamp in cluster state for node %s", node));
                    }
                    ++startTimestampsReset;
                }
            } else if (log.isLoggable(LogLevel.DEBUG)) {
                log.log(LogLevel.DEBUG, node + ": " + (nodeInfo == null ? "null" : nodeInfo.getStartTimestamp()) + ", " + (nodeState == null ? "null" : nodeState.getStartTimestamp()));
            }
        }
    }
    if (startTimestampsReset > 0) {
        eventLog.add(new ClusterEvent(ClusterEvent.Type.SYSTEMSTATE, "Reset " + startTimestampsReset + " start timestamps as all available distributors have seen newest cluster state.", timer.getCurrentTimeInMillis()));
        stateMayHaveChanged = true;
        database.saveStartTimestamps(dbContext);
    } else {
        log.log(LogLevel.DEBUG, "Found no start timestamps to reset in cluster state.");
    }
}
Also used : ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode)

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