Search in sources :

Example 1 with InternalFailure

use of com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InternalFailure in project vespa by vespa-engine.

the class Request method doRemoteFleetControllerTask.

@Override
public final void doRemoteFleetControllerTask(Context context) {
    try {
        if (masterState == MasterState.MUST_BE_MASTER && !context.masterInfo.isMaster()) {
            Integer masterIndex = context.masterInfo.getMaster();
            if (masterIndex == null)
                throw new UnknownMasterException();
            throw new OtherMasterIndexException(masterIndex);
        }
        result = calculateResult(context);
        resultSet = true;
    } catch (OtherMasterIndexException | StateRestApiException e) {
        failure = e;
    } catch (Exception e) {
        failure = new InternalFailure("Caught unexpected exception");
        failure.initCause(e);
    }
}
Also used : UnknownMasterException(com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.UnknownMasterException) StateRestApiException(com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.StateRestApiException) InternalFailure(com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InternalFailure) StateRestApiException(com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.StateRestApiException) DeadlineExceededException(com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.DeadlineExceededException) UnknownMasterException(com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.UnknownMasterException)

Example 2 with InternalFailure

use of com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InternalFailure in project vespa by vespa-engine.

the class SetNodeStatesForClusterRequest method calculateResult.

@Override
public SetResponse calculateResult(RemoteClusterControllerTask.Context context) throws StateRestApiException {
    if (condition != SetUnitStateRequest.Condition.FORCE) {
        // go down, etc. This is prohibited in Condition.SAFE.
        throw new InvalidContentException("Setting all nodes in a cluster to a state is only supported with FORCE");
    }
    for (ConfiguredNode configuredNode : context.cluster.getConfiguredNodes().values()) {
        Node node = new Node(NodeType.STORAGE, configuredNode.index());
        SetResponse setResponse = SetNodeStateRequest.setWantedState(context.cluster, condition, newStates, node, context.nodeStateOrHostInfoChangeHandler, context.currentConsolidatedState);
        if (!setResponse.getWasModified()) {
            throw new InternalFailure("We have not yet implemented the meaning of " + "failing to set the wanted state for a subset of nodes: " + "condition = " + condition + ", newStates = " + newStates + ", currentConsolidatedState = " + context.currentConsolidatedState);
        }
    }
    // 'true' here means the current state now equals the request's wanted state.
    return new SetResponse("ok", true);
}
Also used : SetResponse(com.yahoo.vespa.clustercontroller.utils.staterestapi.response.SetResponse) InvalidContentException(com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InvalidContentException) InternalFailure(com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InternalFailure) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode) ConfiguredNode(com.yahoo.vdslib.distribution.ConfiguredNode)

Aggregations

InternalFailure (com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InternalFailure)2 ConfiguredNode (com.yahoo.vdslib.distribution.ConfiguredNode)1 DeadlineExceededException (com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.DeadlineExceededException)1 InvalidContentException (com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.InvalidContentException)1 StateRestApiException (com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.StateRestApiException)1 UnknownMasterException (com.yahoo.vespa.clustercontroller.utils.staterestapi.errors.UnknownMasterException)1 SetResponse (com.yahoo.vespa.clustercontroller.utils.staterestapi.response.SetResponse)1