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);
}
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));
}
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));
}
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();
}
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.");
}
}
Aggregations