Search in sources :

Example 56 with Node

use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.

the class ClusterStateGeneratorTest method reported_node_down_after_transition_time_has_down_generated_state.

@Test
public void reported_node_down_after_transition_time_has_down_generated_state() {
    final ClusterFixture fixture = ClusterFixture.forFlatCluster(5).bringEntireClusterUp();
    final ClusterStateGenerator.Params params = fixture.generatorParams().currentTimeInMilllis(11_000).transitionTimes(2000);
    fixture.reportStorageNodeState(1, State.DOWN);
    final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 1));
    nodeInfo.setTransitionTime(9000);
    final AnnotatedClusterState state = ClusterStateGenerator.generatedStateFrom(params);
    assertThat(state.toString(), equalTo("distributor:5 storage:5 .1.s:d"));
}
Also used : ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ClusterFixture.storageNode(com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode) Node(com.yahoo.vdslib.state.Node) HasStateReasonForNode.hasStateReasonForNode(com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForNode.hasStateReasonForNode) Test(org.junit.Test)

Example 57 with Node

use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.

the class ClusterStateGeneratorTest method unstable_retired_node_should_be_marked_down.

/**
 * The generated state must be considered over the Reported state when deciding whether
 * to override it with the Wanted state. Otherwise, an unstable retired node could have
 * its generated state be Retired instead of Down. We want it to stay down instead of
 * potentially contributing additional instability to the cluster.
 */
@Test
public void unstable_retired_node_should_be_marked_down() {
    final ClusterFixture fixture = ClusterFixture.forFlatCluster(5).bringEntireClusterUp().proposeStorageNodeWantedState(3, State.RETIRED);
    final ClusterStateGenerator.Params params = fixture.generatorParams().maxPrematureCrashes(10);
    final NodeInfo nodeInfo = fixture.cluster.getNodeInfo(new Node(NodeType.STORAGE, 3));
    nodeInfo.setPrematureCrashCount(11);
    final AnnotatedClusterState state = ClusterStateGenerator.generatedStateFrom(params);
    assertThat(state.toString(), equalTo("distributor:5 storage:5 .3.s:d"));
}
Also used : ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ClusterFixture.storageNode(com.yahoo.vespa.clustercontroller.core.ClusterFixture.storageNode) Node(com.yahoo.vdslib.state.Node) HasStateReasonForNode.hasStateReasonForNode(com.yahoo.vespa.clustercontroller.core.matchers.HasStateReasonForNode.hasStateReasonForNode) Test(org.junit.Test)

Example 58 with Node

use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.

the class ZooKeeperDatabase method storeStartTimestamps.

@Override
public boolean storeStartTimestamps(Map<Node, Long> timestamps) throws InterruptedException {
    if (timestamps == null)
        timestamps = new TreeMap<>();
    StringBuilder sb = new StringBuilder();
    for (Node n : timestamps.keySet()) {
        Long timestamp = timestamps.get(n);
        sb.append(n.toString()).append(':').append(timestamp).append('\n');
    }
    byte[] val = sb.toString().getBytes(utf8);
    try {
        log.log(LogLevel.DEBUG, "Fleetcontroller " + nodeIndex + ": Storing start timestamps at '" + zooKeeperRoot + "starttimestamps");
        session.setData(zooKeeperRoot + "starttimestamps", val, -1);
        return true;
    } catch (InterruptedException e) {
        throw (InterruptedException) new InterruptedException("Interrupted").initCause(e);
    } catch (Exception e) {
        if (sessionOpen && reportErrors) {
            StringWriter sw = new StringWriter();
            e.printStackTrace(new PrintWriter(sw));
            log.log(LogLevel.WARNING, "Fleetcontroller " + nodeIndex + ": Failed to store start timestamps in zookeeper: " + e.getMessage() + "\n" + sw);
        }
        return false;
    }
}
Also used : StringWriter(java.io.StringWriter) Node(com.yahoo.vdslib.state.Node) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 59 with Node

use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.

the class ClusterFixture method reportDistributorNodeState.

public ClusterFixture reportDistributorNodeState(final int index, State state) {
    final Node node = new Node(NodeType.DISTRIBUTOR, index);
    final NodeState nodeState = new NodeState(NodeType.DISTRIBUTOR, state);
    doReportNodeState(node, nodeState);
    return this;
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) Node(com.yahoo.vdslib.state.Node)

Example 60 with Node

use of com.yahoo.vdslib.state.Node in project vespa by vespa-engine.

the class ClusterFixture method proposeStorageNodeWantedState.

public ClusterFixture proposeStorageNodeWantedState(final int index, State state, String description) {
    final Node node = new Node(NodeType.STORAGE, index);
    final NodeState nodeState = new NodeState(NodeType.STORAGE, state);
    doProposeWantedState(node, nodeState, description);
    return this;
}
Also used : NodeState(com.yahoo.vdslib.state.NodeState) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) 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