Search in sources :

Example 26 with ClusterState

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

the class RPCCommunicator method setSystemState.

@Override
public void setSystemState(ClusterStateBundle stateBundle, NodeInfo node, Waiter<SetClusterStateRequest> externalWaiter) {
    final RPCSetClusterStateWaiter waiter = new RPCSetClusterStateWaiter(externalWaiter, timer);
    final ClusterState baselineState = stateBundle.getBaselineClusterState();
    Target connection = getConnection(node);
    if (!connection.isValid()) {
        log.log(LogLevel.DEBUG, "Connection to " + node.getRpcAddress() + " could not be created.");
        return;
    }
    final int nodeVersion = node.getVersion();
    // TODO remove this deprecated legacy stuff
    if (nodeVersion == 0 && node.getConnectionVersion() > 0) {
        doVersion0HandShake(connection, node);
        clearOldStoredNodeState(connection, node);
    }
    Request req;
    if (nodeVersion == 0) {
        req = new Request("setsystemstate");
        req.parameters().add(new StringValue(baselineState.toString(true)));
    } else if (nodeVersion <= 2) {
        req = new Request(LEGACY_SET_SYSTEM_STATE2_RPC_METHOD_NAME);
        req.parameters().add(new StringValue(baselineState.toString(false)));
    } else {
        req = new Request(SET_DISTRIBUTION_STATES_RPC_METHOD_NAME);
        SlimeClusterStateBundleCodec codec = new SlimeClusterStateBundleCodec();
        EncodedClusterStateBundle encodedBundle = codec.encode(stateBundle);
        Values v = req.parameters();
        v.add(new Int8Value(encodedBundle.getCompression().type().getCode()));
        v.add(new Int32Value(encodedBundle.getCompression().uncompressedSize()));
        v.add(new DataValue(encodedBundle.getCompression().data()));
    }
    log.log(LogLevel.DEBUG, () -> String.format("Sending '%s' RPC to %s for state version %d", req.methodName(), node.getRpcAddress(), stateBundle.getVersion()));
    RPCSetClusterStateRequest stateRequest = new RPCSetClusterStateRequest(node, req, baselineState.getVersion());
    waiter.setRequest(stateRequest);
    connection.invokeAsync(req, 60, waiter);
    node.setSystemStateVersionSent(baselineState);
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState)

Example 27 with ClusterState

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

the class FleetController method handleNewSystemState.

@Override
public void handleNewSystemState(ClusterStateBundle stateBundle) {
    verifyInControllerThread();
    ClusterState baselineState = stateBundle.getBaselineClusterState();
    newStates.add(stateBundle);
    metricUpdater.updateClusterStateMetrics(cluster, baselineState);
    systemStateBroadcaster.handleNewClusterStates(stateBundle);
    // ZK store will not risk reusing the same version number.
    if (masterElectionHandler.isMaster()) {
        storeClusterStateVersionToZooKeeper(baselineState);
    }
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState)

Example 28 with ClusterState

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

the class FleetController method handleAllDistributorsInSync.

/**
 * Called when all distributors have acked newest cluster state version.
 */
public void handleAllDistributorsInSync(DatabaseHandler database, DatabaseHandler.Context context) throws InterruptedException {
    Set<ConfiguredNode> nodes = new HashSet<>(cluster.clusterInfo().getConfiguredNodes().values());
    ClusterState currentState = stateVersionTracker.getVersionedClusterState();
    log.fine(() -> String.format("All distributors have ACKed cluster state version %d", currentState.getVersion()));
    stateChangeHandler.handleAllDistributorsInSync(currentState, nodes, database, context);
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode)

Example 29 with ClusterState

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

the class NodeStateChangeChecker method contentNodesWithAvailableNodeState.

private int contentNodesWithAvailableNodeState(ClusterState clusterState) {
    final int nodeCount = clusterState.getNodeCount(NodeType.STORAGE);
    int upNodesCount = 0;
    for (int i = 0; i < nodeCount; ++i) {
        final Node node = new Node(NodeType.STORAGE, i);
        final State state = clusterState.getNodeState(node).getState();
        if (state == State.UP || state == State.RETIRED || state == State.INITIALIZING) {
            upNodesCount++;
        }
    }
    return upNodesCount;
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState) State(com.yahoo.vdslib.state.State) StorageNode(com.yahoo.vespa.clustercontroller.core.hostinfo.StorageNode) Node(com.yahoo.vdslib.state.Node)

Example 30 with ClusterState

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

the class NodeStateChangeChecker method canSetStateDownPermanently.

private Result canSetStateDownPermanently(NodeInfo nodeInfo, ClusterState clusterState) {
    State reportedState = nodeInfo.getReportedState().getState();
    if (reportedState != State.UP) {
        return Result.createDisallowed("Reported state (" + reportedState + ") is not UP, so no bucket data is available");
    }
    State currentState = clusterState.getNodeState(nodeInfo.getNode()).getState();
    if (currentState != State.RETIRED) {
        return Result.createDisallowed("Only retired nodes are allowed to be set to DOWN in safe mode - is " + currentState);
    }
    Result thresholdCheckResult = checkUpThresholds(clusterState);
    if (!thresholdCheckResult.settingWantedStateIsAllowed()) {
        return thresholdCheckResult;
    }
    HostInfo hostInfo = nodeInfo.getHostInfo();
    Integer hostInfoNodeVersion = hostInfo.getClusterStateVersionOrNull();
    int clusterControllerVersion = clusterState.getVersion();
    if (hostInfoNodeVersion == null || hostInfoNodeVersion != clusterControllerVersion) {
        return Result.createDisallowed("Cluster controller at version " + clusterControllerVersion + " got info for storage node " + nodeInfo.getNodeIndex() + " at a different version " + hostInfoNodeVersion);
    }
    Optional<Metrics.Value> bucketsMetric = hostInfo.getMetrics().getValue(BUCKETS_METRIC_NAME);
    if (!bucketsMetric.isPresent() || bucketsMetric.get().getLast() == null) {
        return Result.createDisallowed("Missing last value of the " + BUCKETS_METRIC_NAME + " metric for storage node " + nodeInfo.getNodeIndex());
    }
    long lastBuckets = bucketsMetric.get().getLast();
    if (lastBuckets > 0) {
        return Result.createDisallowed("The storage node manages " + lastBuckets + " buckets");
    }
    return Result.allowSettingOfWantedState();
}
Also used : ClusterState(com.yahoo.vdslib.state.ClusterState) NodeState(com.yahoo.vdslib.state.NodeState) State(com.yahoo.vdslib.state.State) HostInfo(com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo)

Aggregations

ClusterState (com.yahoo.vdslib.state.ClusterState)38 Test (org.junit.Test)11 NodeState (com.yahoo.vdslib.state.NodeState)10 Node (com.yahoo.vdslib.state.Node)8 BucketId (com.yahoo.document.BucketId)6 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)6 State (com.yahoo.vdslib.state.State)4 Request (com.yahoo.jrt.Request)2 Spec (com.yahoo.jrt.Spec)2 Supervisor (com.yahoo.jrt.Supervisor)2 Target (com.yahoo.jrt.Target)2 Transport (com.yahoo.jrt.Transport)2 StringWriter (java.io.StringWriter)2 HashMap (java.util.HashMap)2 ParseException (com.yahoo.document.select.parser.ParseException)1 StringValue (com.yahoo.jrt.StringValue)1 Distribution (com.yahoo.vdslib.distribution.Distribution)1 NodeType (com.yahoo.vdslib.state.NodeType)1 AnnotatedClusterState (com.yahoo.vespa.clustercontroller.core.AnnotatedClusterState)1 HostInfo (com.yahoo.vespa.clustercontroller.core.hostinfo.HostInfo)1