Source:
private InstanceStatus updateStatuses(CloudVmInstanceStatus vmInstanceStatus, InstanceMetaData instanceMetaData, Map<InstanceMetaData, DetailedStackStatus> instanceHealthStatusMap) { LOGGER.info(":::Auto sync::: instance metadata status update in progress, new status: {}", instanceMetaData.getShortHostname(), vmInstanceStatus); InstanceStatus status = null; if (DetailedStackStatus.UNREACHABLE == instanceHealthStatusMap.get(instanceMetaData)) { setStatusIfNotTheSame(instanceMetaData, InstanceStatus.UNREACHABLE); status = InstanceStatus.UNREACHABLE; } else { switch (vmInstanceStatus.getStatus()) { case STARTED: setStatusIfNotTheSame(instanceMetaData, InstanceStatus.CREATED); status = InstanceStatus.CREATED; break; case STOPPED: setStatusIfNotTheSame(instanceMetaData, InstanceStatus.STOPPED); status = InstanceStatus.STOPPED; break; case FAILED: setStatusIfNotTheSame(instanceMetaData, InstanceStatus.FAILED); status = InstanceStatus.FAILED; break; case TERMINATED: setStatusIfNotTheSame(instanceMetaData, InstanceStatus.DELETED_ON_PROVIDER_SIDE); status = InstanceStatus.DELETED_ON_PROVIDER_SIDE; break; case TERMINATED_BY_PROVIDER: setStatusIfNotTheSame(instanceMetaData, InstanceStatus.DELETED_BY_PROVIDER); status = InstanceStatus.DELETED_BY_PROVIDER; break; default: LOGGER.info(":::Auto sync::: the '{}' status is not converted", vmInstanceStatus.getStatus()); } } if (updateStatus) { instanceMetaDataService.save(instanceMetaData); } else { LOGGER.debug("updateStatus flag is false, don't update status"); } return status; }

Target:
private InstanceStatus updateStatuses(CloudVmInstanceStatus vmInstanceStatus, InstanceMetaData instanceMetaData, Map<InstanceMetaData, DetailedStackStatus> instanceHealthStatusMap) { LOGGER.info(":::Auto sync::: instance metadata status update in progress, new status: {}", instanceMetaData.getShortHostname(), vmInstanceStatus); InstanceStatus status = null; switch (vmInstanceStatus.getStatus()) { case STARTED: if (DetailedStackStatus.UNREACHABLE == instanceHealthStatusMap.get(instanceMetaData)) { setStatusIfNotTheSame(instanceMetaData, InstanceStatus.UNREACHABLE); status = InstanceStatus.UNREACHABLE; } else if (DetailedStackStatus.UNHEALTHY == instanceHealthStatusMap.get(instanceMetaData)) { setStatusIfNotTheSame(instanceMetaData, InstanceStatus.UNHEALTHY); status = InstanceStatus.UNHEALTHY; } else { setStatusIfNotTheSame(instanceMetaData, InstanceStatus.CREATED); status = InstanceStatus.CREATED; } break; case STOPPED: setStatusIfNotTheSame(instanceMetaData, InstanceStatus.STOPPED); status = InstanceStatus.STOPPED; break; case FAILED: setStatusIfNotTheSame(instanceMetaData, InstanceStatus.FAILED); status = InstanceStatus.FAILED; break; case TERMINATED: setStatusIfNotTheSame(instanceMetaData, InstanceStatus.DELETED_ON_PROVIDER_SIDE); status = InstanceStatus.DELETED_ON_PROVIDER_SIDE; break; case TERMINATED_BY_PROVIDER: setStatusIfNotTheSame(instanceMetaData, InstanceStatus.DELETED_BY_PROVIDER); status = InstanceStatus.DELETED_BY_PROVIDER; break; default: LOGGER.info(":::Auto sync::: the '{}' status is not converted", vmInstanceStatus.getStatus()); } if (updateStatus) { instanceMetaDataService.save(instanceMetaData); } else { LOGGER.debug("updateStatus flag is false, don't update status"); } return status; }