Search in sources :

Example 1 with SimulatorHAStateResponse

use of com.cloud.api.response.SimulatorHAStateResponse in project cloudstack by apache.

the class SimulatorHAState method addStateTransition.

public boolean addStateTransition(final HAConfig.HAState newHaState, final HAConfig.HAState oldHaState, final HAConfig.Event event, final HAResourceCounter counter) {
    final SimulatorHAStateResponse stateResponse = new SimulatorHAStateResponse();
    stateResponse.setHaState(newHaState);
    stateResponse.setPreviousHaState(oldHaState);
    stateResponse.setHaEvent(event);
    if (counter != null) {
        stateResponse.setActivityCounter(counter.getActivityCheckCounter());
        stateResponse.setRecoveryCounter(counter.getRecoveryCounter());
    }
    stateResponse.setObjectName("hastatetransition");
    return stateTransitions.add(stateResponse);
}
Also used : SimulatorHAStateResponse(com.cloud.api.response.SimulatorHAStateResponse)

Example 2 with SimulatorHAStateResponse

use of com.cloud.api.response.SimulatorHAStateResponse in project cloudstack by apache.

the class ListSimulatorHAStateTransitions method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
    final Host host = _resourceService.getHost(getHostId());
    if (host == null) {
        throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find host by ID: " + getHostId());
    }
    final SimulatorHAProvider simulatorHAProvider = (SimulatorHAProvider) haManager.getHAProvider(SimulatorHAProvider.class.getSimpleName().toLowerCase());
    List<SimulatorHAStateResponse> recentStates = new ArrayList<>();
    if (simulatorHAProvider != null) {
        recentStates = simulatorHAProvider.listHAStateTransitions(host.getId());
    }
    final ListResponse<SimulatorHAStateResponse> response = new ListResponse<>();
    response.setResponses(recentStates);
    response.setResponseName(getCommandName());
    response.setObjectName("simulatorhastatetransition");
    setResponseObject(response);
}
Also used : SimulatorHAProvider(org.apache.cloudstack.ha.SimulatorHAProvider) ServerApiException(org.apache.cloudstack.api.ServerApiException) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) Host(com.cloud.host.Host) SimulatorHAStateResponse(com.cloud.api.response.SimulatorHAStateResponse)

Aggregations

SimulatorHAStateResponse (com.cloud.api.response.SimulatorHAStateResponse)2 Host (com.cloud.host.Host)1 ArrayList (java.util.ArrayList)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1 SimulatorHAProvider (org.apache.cloudstack.ha.SimulatorHAProvider)1