Search in sources :

Example 1 with MasterStatus

use of com.netflix.titus.api.supervisor.model.MasterStatus in project titus-control-plane by Netflix.

the class DefaultLocalMasterInstanceResolver method refresh.

private Optional<MasterInstance> refresh(@Nullable MasterInstance previousMasterInstance, ReadinessStatus currentReadinessStatus) {
    MasterState newState;
    switch(currentReadinessStatus.getState()) {
        case NotReady:
            newState = MasterState.Starting;
            break;
        case Disabled:
            newState = MasterState.Inactive;
            break;
        case Enabled:
            newState = MasterState.NonLeader;
            break;
        default:
            logger.warn("Unrecognized master readiness state; assuming inactive: {}", currentReadinessStatus.getState());
            newState = MasterState.Inactive;
    }
    MasterStatus newStatus = MasterStatus.newBuilder().withState(newState).withMessage(currentReadinessStatus.getMessage()).withTimestamp(currentReadinessStatus.getTimestamp()).build();
    if (areDifferent(previousMasterInstance.getStatus(), newStatus)) {
        MasterInstance newMasterInstance = MasterInstanceFunctions.moveTo(previousMasterInstance, newStatus);
        logger.info("MasterInstance status change: {}", newMasterInstance);
        return Optional.of(newMasterInstance);
    }
    logger.debug("Refreshed master instance status not changed: status={}", newStatus);
    return Optional.empty();
}
Also used : MasterStatus(com.netflix.titus.api.supervisor.model.MasterStatus) MasterState(com.netflix.titus.api.supervisor.model.MasterState) MasterInstance(com.netflix.titus.api.supervisor.model.MasterInstance)

Example 2 with MasterStatus

use of com.netflix.titus.api.supervisor.model.MasterStatus in project titus-control-plane by Netflix.

the class MasterInstanceGenerator method masterInstances.

public static DataGenerator<MasterInstance> masterInstances(MasterState initialState, String... ids) {
    MasterStatus masterStatus = MasterStatus.newBuilder().withState(initialState).withMessage("Initial value").build();
    List<MasterInstance> values = new ArrayList<>();
    for (int i = 0; i < ids.length; i++) {
        values.add(MasterInstance.newBuilder().withInstanceId(ids[i]).withInstanceGroupId("testInstanceGroup").withIpAddress("1.0.0." + i).withStatus(masterStatus).withStatusHistory(Collections.emptyList()).build());
    }
    return DataGenerator.items(values);
}
Also used : MasterStatus(com.netflix.titus.api.supervisor.model.MasterStatus) ArrayList(java.util.ArrayList) MasterInstance(com.netflix.titus.api.supervisor.model.MasterInstance)

Aggregations

MasterInstance (com.netflix.titus.api.supervisor.model.MasterInstance)2 MasterStatus (com.netflix.titus.api.supervisor.model.MasterStatus)2 MasterState (com.netflix.titus.api.supervisor.model.MasterState)1 ArrayList (java.util.ArrayList)1