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();
}
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);
}
Aggregations