HealthReport HealthReport::CreateSystemHealthReport()

in src/prod/src/ServiceModel/HealthReport.cpp [123:966]


HealthReport HealthReport::CreateSystemHealthReport(
    SystemHealthReportCode::Enum reportCode,
    EntityHealthInformationSPtr && entityInformation,
    std::wstring const & dynamicProperty,
    std::wstring const & extraDescription,
    FABRIC_SEQUENCE_NUMBER sequenceNumber,
    Common::TimeSpan const timeToLive,
    AttributeList && attributeList)
{
    wstring sourceId;
    wstring property;
    FABRIC_HEALTH_STATE healthState;
    bool removeWhenExpired = false;
    wstring description;
    switch(reportCode)
    {
    case SystemHealthReportCode::CM_ApplicationCreated:
        sourceId = *Constants::HealthReportCMSource;
        property = *Constants::HealthStateProperty;
        description = HMResource::GetResources().ApplicationCreated;
        healthState = FABRIC_HEALTH_STATE_OK;
        break;

    case SystemHealthReportCode::CM_ApplicationUpdated:
        sourceId = *Constants::HealthReportCMSource;
        property = *Constants::HealthStateProperty;
        description = HMResource::GetResources().ApplicationUpdated;
        healthState = FABRIC_HEALTH_STATE_OK;
        break;

    case SystemHealthReportCode::RA_ReconfigurationStuckWarning:
        sourceId = *Constants::HealthReportRASource;
        property = *Constants::ReconfigurationProperty;
        description = HMResource::GetResources().HealthReconfigurationStatusWarning;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        break;

    case SystemHealthReportCode::RA_ReconfigurationHealthy:
        sourceId = *Constants::HealthReportRASource;
        property = *Constants::ReconfigurationProperty;
        description = HMResource::GetResources().HealthReconfigurationStatusHealthy;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::RA_ReplicaCreated:
        sourceId = *Constants::HealthReportRASource;
        property = *Constants::HealthStateProperty;
        description = HMResource::GetResources().HealthReplicaCreated;
        healthState = FABRIC_HEALTH_STATE_OK;
        break;

    case SystemHealthReportCode::RA_ReplicaOpenStatusWarning:
        sourceId = *Constants::HealthReportRASource;
        property = *Constants::HealthReplicaOpenStatusProperty;
        description = HMResource::GetResources().HealthReplicaOpenStatusWarning;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        break;

    case SystemHealthReportCode::RA_ReplicaOpenStatusHealthy:
        sourceId = *Constants::HealthReportRASource;
        property = *Constants::HealthReplicaOpenStatusProperty;
        description = HMResource::GetResources().HealthReplicaOpenStatusHealthy;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::RA_ReplicaCloseStatusWarning:
        sourceId = *Constants::HealthReportRASource;
        property = *Constants::HealthReplicaCloseStatusProperty;
        description = HMResource::GetResources().HealthReplicaCloseStatusWarning;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        break;

    case SystemHealthReportCode::RA_ReplicaCloseStatusHealthy:
        sourceId = *Constants::HealthReportRASource;
        property = *Constants::HealthReplicaCloseStatusProperty;
        description = HMResource::GetResources().HealthReplicaCloseStatusHealthy;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::RA_ReplicaServiceTypeRegistrationStatusWarning:
        sourceId = *Constants::HealthReportRASource;
        property = *Constants::HealthReplicaServiceTypeRegistrationStatusProperty;
        description = HMResource::GetResources().HealthReplicaServiceTypeRegistrationStatusWarning;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        break;

    case SystemHealthReportCode::RA_ReplicaServiceTypeRegistrationStatusHealthy:
        sourceId = *Constants::HealthReportRASource;
        property = *Constants::HealthReplicaServiceTypeRegistrationStatusProperty;
        description = HMResource::GetResources().HealthReplicaServiceTypeRegistrationStatusHealthy;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::RA_StoreProviderHealthy:
        sourceId = *Constants::HealthReportRASource;
        property = *Constants::HealthRAStoreProvider;
        healthState = FABRIC_HEALTH_STATE_OK;
        break;

    case SystemHealthReportCode::RA_StoreProviderUnhealthy:
        sourceId = *Constants::HealthReportRASource;
        property = *Constants::HealthRAStoreProvider;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        break;

    case SystemHealthReportCode::RA_ReplicaChangeRoleStatusError:
        sourceId = *Constants::HealthReportRASource;
        property = *Constants::HealthReplicaChangeRoleStatusProperty;
        description = HMResource::GetResources().HealthReplicaChangeRoleStatusError;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        break;

    case SystemHealthReportCode::RA_ReplicaChangeRoleStatusHealthy:
        sourceId = *Constants::HealthReportRASource;
        property = *Constants::HealthReplicaChangeRoleStatusProperty;
        description = HMResource::GetResources().HealthReplicaChangeStatusHealthy;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::FMM_NodeDeactivateStuck:
        sourceId = *Constants::HealthReportFMMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().NodeDeactivateStuck;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::FMM_PartitionQuorumLoss:
        sourceId = *Constants::HealthReportFMMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().PartitionQuorumLoss;
        break;

    case SystemHealthReportCode::FMM_PartitionBuildStuckBelowMinReplicaCount:
        sourceId = *Constants::HealthReportFMMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().PartitionBuildStuck;
        break;

    case SystemHealthReportCode::FMM_PartitionPlacementStuckBelowMinReplicaCount:
        sourceId = *Constants::HealthReportFMMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().PartitionPlacementStuck;
        break;

    case SystemHealthReportCode::FMM_PartitionReconfigurationStuck:
        sourceId = *Constants::HealthReportFMMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().PartitionReconfigurationStuck;
        break;

    case SystemHealthReportCode::FMM_PartitionBuildStuck:
        sourceId = *Constants::HealthReportFMMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().PartitionBuildStuck;
        break;

    case SystemHealthReportCode::FMM_PartitionRebuildStuck:
        sourceId = *Constants::HealthReportFMMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().PartitionRebuildStuck;
        break;

    case SystemHealthReportCode::FMM_PartitionPlacementStuck:
        sourceId = *Constants::HealthReportFMMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().PartitionPlacementStuck;
        break;

    case SystemHealthReportCode::FMM_PartitionDeletionInProgress:
        sourceId = *Constants::HealthReportFMMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().DeletionInProgress;
        break;

    case SystemHealthReportCode::FMM_PartitionHealthy:
        sourceId = *Constants::HealthReportFMMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().PartitionHealthy;
        break;

    case SystemHealthReportCode::FMM_ServiceCreated:
        sourceId = *Constants::HealthReportFMMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().ServiceCreated;
        break;

    case SystemHealthReportCode::FMM_RebuildStuck:
        sourceId = *Constants::HealthReportFMMSource;
        property = *Constants::RebuildProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().FMMRebuildStuck;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::FMM_RebuildHealthy:
        sourceId = *Constants::HealthReportFMMSource;
        property = *Constants::RebuildProperty;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().FMMRebuildHealthy;
        removeWhenExpired = true;
        break;        

    case SystemHealthReportCode::FM_PartitionQuorumLoss:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().PartitionQuorumLoss;
        break;

    case SystemHealthReportCode::FM_PartitionBuildStuckBelowMinReplicaCount:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().PartitionBuildStuck;
        break;

    case SystemHealthReportCode::FM_PartitionPlacementStuckBelowMinReplicaCount:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().PartitionPlacementStuck;
        break;

    case SystemHealthReportCode::FM_PartitionPlacementStuckAtZeroReplicaCount:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().PartitionPlacementStuck;
        break;

    case SystemHealthReportCode::FM_PartitionReconfigurationStuck:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().PartitionReconfigurationStuck;
        break;

    case SystemHealthReportCode::FM_PartitionBuildStuck:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().PartitionBuildStuck;
        break;

    case SystemHealthReportCode::FM_PartitionRebuildStuck:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().PartitionRebuildStuck;
        break;

    case SystemHealthReportCode::FM_PartitionPlacementStuck:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().PartitionPlacementStuck;
        break;

    case SystemHealthReportCode::FM_ServiceCreated:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().ServiceCreated;
        break;

    case SystemHealthReportCode::FM_NodeDeactivateStuck:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().NodeDeactivateStuck;
        break;

    case SystemHealthReportCode::FM_NodeUp:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().NodeUp;
        break;

    case SystemHealthReportCode::FM_PartitionHealthy:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().PartitionHealthy;
        break;

    case SystemHealthReportCode::FM_PartitionDeletionInProgress:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().DeletionInProgress;
        break;

    case SystemHealthReportCode::FM_NodeDown:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().NodeDown;
        break;

    case SystemHealthReportCode::FM_SeedNodeDown:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().SeedNodeDown;
        break;

    case SystemHealthReportCode::FM_NodeDownDuringUpgrade:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().NodeDownDuringUpgrade;
        break;

    case SystemHealthReportCode::FM_RebuildStuck:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::RebuildProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().FMRebuildStuck;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::FM_RebuildHealthy:
        sourceId = *Constants::HealthReportFMSource;
        property = *Constants::RebuildProperty;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().FMRebuildHealthy;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::RAP_ApiOk:
        sourceId = *Constants::HealthReportRAPSource;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().HealthStartTime;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::RAP_ApiSlow:
        sourceId = *Constants::HealthReportRAPSource;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().HealthStartTime;
        break;

    case SystemHealthReportCode::FabricNode_CertificateOk:
        sourceId = *Constants::HealthReportFabricNodeSource;
        property = *Constants::FabricCertificateProperty;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().CertificateExpiration;
        break;

    case SystemHealthReportCode::FabricNode_CertificateCloseToExpiration:
        sourceId = *Constants::HealthReportFabricNodeSource;
        property = *Constants::FabricCertificateProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().CertificateExpiration;
        break;

    case SystemHealthReportCode::FabricNode_CertificateRevocationListOffline:
        sourceId = *Constants::HealthReportFabricNodeSource;
        property = *Constants::FabricCertificateRevocationListProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().CertificateRevocationList;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::FabricNode_CertificateRevocationListOk:
        sourceId = *Constants::HealthReportFabricNodeSource;
        property = *Constants::FabricCertificateRevocationListProperty;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().CertificateRevocationList;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::FabricNode_SecurityApiSlow:
        sourceId = *Constants::HealthReportFabricNodeSource;
        property = *Constants::SecurityApiProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().SecurityApi;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::Federation_NeighborhoodLost:
        sourceId = *Constants::HealthReportFederationSource;
        property = *Constants::NeighborhoodProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().NeighborHoodLost;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::Federation_NeighborhoodOk:
        sourceId = *Constants::HealthReportFederationSource;
        property = *Constants::NeighborhoodProperty;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().NeighborHoodLost;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::Hosting_DeleteEvent:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        // No description for delete event
        break;

    case SystemHealthReportCode::Hosting_ServiceTypeRegistered:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().ServiceTypeRegistered;
        break;

    case SystemHealthReportCode::Hosting_CodePackageActivated:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().CodePackageActivated;
        break;

    case SystemHealthReportCode::Hosting_ApplicationActivated:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().ApplicationActivated;
        break;

    case SystemHealthReportCode::Hosting_ServicePackageActivated:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_OK;
        description = HMResource::GetResources().ServicePackageActivated;
        break;

    case SystemHealthReportCode::Hosting_ServiceTypeRegistrationTimeout:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().ServiceTypeRegistrationTimeout;
        break;

    case SystemHealthReportCode::Hosting_ServiceTypeDisabled:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().ServiceTypeDisabled;
        break;

    case SystemHealthReportCode::Hosting_ActivationFailed:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().ActivationFailed;
        break;

    case SystemHealthReportCode::Hosting_CodePackageActivationError:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().CodePackageActivationFailed;
        break;

    case SystemHealthReportCode::Hosting_DownloadFailed:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().DownloadFailed;
        break;

    case SystemHealthReportCode::Hosting_ServiceTypeUnregistered:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().ServiceTypeUnregistered;
        break;

    case SystemHealthReportCode::Hosting_CodePackageActivationWarning:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().CodePackageActivationFailed;
        break;

    case SystemHealthReportCode::Hosting_FabricUpgradeValidationFailed:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().FabricUpgradeValidationFailed;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::Hosting_FabricUpgradeFailed:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        description = HMResource::GetResources().FabricUpgradeFailed;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::Hosting_AvailableResourceCapacityMismatch:
        sourceId = *Constants::HealthReportHostingSource;
        property = *Constants::ResourceGovernanceReportProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().AvailableResourceCapacityMismatch;
        break;

    case SystemHealthReportCode::Hosting_AvailableResourceCapacityNotDefined:
        sourceId = *Constants::HealthReportHostingSource;
        property = *Constants::ResourceGovernanceReportProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        description = HMResource::GetResources().AvailableResourceCapacityNotDefined;
        break;

    case SystemHealthReportCode::Hosting_DockerHealthCheckStatusHealthy:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_OK;
        break;

    case SystemHealthReportCode::Hosting_DockerHealthCheckStatusUnhealthy:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        break;

    case SystemHealthReportCode::Hosting_DockerDaemonUnhealthy:
        sourceId = *Constants::HealthReportHostingSource;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::PLB_NodeCapacityViolation:
        sourceId = *Constants::HealthReportPLBSource;
        property = *Constants::HealthCapacityProperty;
        description = HMResource::GetResources().PLBNodeCapacityViolationWarning;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::PLB_NodeCapacityOK:
        sourceId = *Constants::HealthReportPLBSource;
        property = *Constants::HealthCapacityProperty;
        description = HMResource::GetResources().PLBNodeCapacityOK;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::PLB_UnplacedReplicaViolation:
        sourceId = *Constants::HealthReportPLBSource;
        property = *Constants::ServiceReplicaUnplacedHealthProperty;
        description = HMResource::GetResources().PLBUnplacedReplicaViolation;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::PLB_ReplicaConstraintViolation:
        sourceId = *Constants::HealthReportPLBSource;
        property = *Constants::ReplicaConstraintViolationProperty;
        description = HMResource::GetResources().PLBReplicaConstraintViolation;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::PLB_ReplicaSoftConstraintViolation:
        sourceId = *Constants::HealthReportPLBSource;
        property = *Constants::ReplicaConstraintViolationProperty;
        description = HMResource::GetResources().PLBReplicaSoftConstraintViolation;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::PLB_UpgradePrimarySwapViolation:
        sourceId = *Constants::HealthReportPLBSource;
        property = *Constants::UpgradePrimarySwapHealthProperty;
        description = HMResource::GetResources().PLBUpgradePrimarySwapViolation;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::PLB_BalancingUnsuccessful:
        sourceId = *Constants::HealthReportPLBSource;
        property = *Constants::BalancingUnsuccessfulProperty;
        description = HMResource::GetResources().PLBBalancingUnsuccessful;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::PLB_ConstraintFixUnsuccessful:
        sourceId = *Constants::HealthReportPLBSource;
        property = *Constants::ConstraintFixUnsuccessfulProperty;
        description = HMResource::GetResources().PLBConstraintFixUnsuccessful;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::PLB_MovementsDropped:
        sourceId = *Constants::HealthReportPLBSource;
        property = *Constants::MovementEfficacyProperty;
        description = HMResource::GetResources().PLBMovementsDropped;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::PLB_ServiceCorrelationError:
        sourceId = *Constants::HealthReportPLBSource;
        property = *Constants::ServiceDescriptionHealthProperty;
        description = HMResource::GetResources().PLBServiceCorrelationError;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        removeWhenExpired = false;
        break;

    case SystemHealthReportCode::PLB_ServiceDescriptionOK:
        sourceId = *Constants::HealthReportPLBSource;
        property = *Constants::ServiceDescriptionHealthProperty;
        description = HMResource::GetResources().PLBServiceDescriptionOK;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::CRM_NodeCapacityViolation:
        sourceId = *Constants::HealthReportCRMSource;
        property = *Constants::HealthCapacityProperty;
        description = HMResource::GetResources().PLBNodeCapacityViolationWarning;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::CRM_NodeCapacityOK:
        sourceId = *Constants::HealthReportCRMSource;
        property = *Constants::HealthCapacityProperty;
        description = HMResource::GetResources().PLBNodeCapacityOK;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::CRM_UnplacedReplicaViolation:
        sourceId = *Constants::HealthReportCRMSource;
        property = *Constants::ServiceReplicaUnplacedHealthProperty;
        description = HMResource::GetResources().PLBUnplacedReplicaViolation;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::CRM_ReplicaConstraintViolation:
        sourceId = *Constants::HealthReportCRMSource;
        property = *Constants::ReplicaConstraintViolationProperty;
        description = HMResource::GetResources().PLBReplicaConstraintViolation;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::CRM_ReplicaSoftConstraintViolation:
        sourceId = *Constants::HealthReportCRMSource;
        property = *Constants::ReplicaConstraintViolationProperty;
        description = HMResource::GetResources().PLBReplicaSoftConstraintViolation;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::CRM_UpgradePrimarySwapViolation:
        sourceId = *Constants::HealthReportCRMSource;
        property = *Constants::UpgradePrimarySwapHealthProperty;
        description = HMResource::GetResources().PLBUpgradePrimarySwapViolation;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::CRM_BalancingUnsuccessful:
        sourceId = *Constants::HealthReportCRMSource;
        property = *Constants::BalancingUnsuccessfulProperty;
        description = HMResource::GetResources().PLBBalancingUnsuccessful;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::CRM_ConstraintFixUnsuccessful:
        sourceId = *Constants::HealthReportCRMSource;
        property = *Constants::ConstraintFixUnsuccessfulProperty;
        description = HMResource::GetResources().PLBConstraintFixUnsuccessful;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::CRM_MovementsDropped:
        sourceId = *Constants::HealthReportCRMSource;
        property = *Constants::MovementEfficacyProperty;
        description = HMResource::GetResources().PLBMovementsDropped;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::CRM_ServiceCorrelationError:
        sourceId = *Constants::HealthReportCRMSource;
        property = *Constants::ServiceDescriptionHealthProperty;
        description = HMResource::GetResources().PLBServiceCorrelationError;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        removeWhenExpired = false;
        break;

    case SystemHealthReportCode::CRM_ServiceDescriptionOK:
        sourceId = *Constants::HealthReportCRMSource;
        property = *Constants::ServiceDescriptionHealthProperty;
        description = HMResource::GetResources().PLBServiceDescriptionOK;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::RE_QueueFull:
        sourceId = *Constants::HealthReportReplicatorSource;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = false;
        ASSERT_IF(extraDescription.empty(), "Replicator heath report description cannot be empty");
        ASSERT_IF(dynamicProperty.empty(), "Replicator heath report dynamic property cannot be empty");
        break;

    case SystemHealthReportCode::RE_QueueOk:
        sourceId = *Constants::HealthReportReplicatorSource;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        ASSERT_IF(dynamicProperty.empty(), "Replicator heath report dynamic property cannot be empty");
        break;
    
    case SystemHealthReportCode::RE_RemoteReplicatorConnectionStatusOk:
        sourceId = *Constants::HealthReportReplicatorSource;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        ASSERT_IF(dynamicProperty.empty(), "Replicator heath report dynamic property cannot be empty");
        break;
    
    case SystemHealthReportCode::RE_RemoteReplicatorConnectionStatusFailed:
        sourceId = *Constants::HealthReportReplicatorSource;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        ASSERT_IF(dynamicProperty.empty(), "Replicator heath report dynamic property cannot be empty");
        break;

    case SystemHealthReportCode::RE_ApiSlow:
        sourceId = *Constants::HealthReportReplicatorSource;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = false;
        ASSERT_IF(dynamicProperty.empty(), "Replicator heath report dynamic property cannot be empty");
        break;

    case SystemHealthReportCode::RE_ApiOk:
        sourceId = *Constants::HealthReportReplicatorSource;
        healthState = FABRIC_HEALTH_STATE_OK;
        removeWhenExpired = true;
        ASSERT_IF(dynamicProperty.empty(), "Replicator heath report dynamic property cannot be empty");
        break;

    case SystemHealthReportCode::Testability_UnreliableTransportBehaviorTimeOut:
        sourceId = *Constants::HealthReportTestabilitySource;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::REStore_Unexpected:
        sourceId = *Constants::HealthReportReplicatedStoreSource;
        property = *Constants::HealthStateProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::REStore_SlowCommit:
        sourceId = *Constants::HealthReportReplicatedStoreSource;
        property = *Constants::CommitPerformanceHealthProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::REStore_PathTooLong:
        sourceId = *Constants::HealthReportReplicatedStoreSource;
        property = *Constants::HealthReplicaOpenStatusProperty;
        healthState = FABRIC_HEALTH_STATE_ERROR;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::REStore_AutoCompaction:
        sourceId = *Constants::HealthReportReplicatedStoreSource;
        property = *Constants::HealthReplicaOpenStatusProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = (timeToLive != TimeSpan::MaxValue);
        break;

    case SystemHealthReportCode::Naming_OperationSlow:
        sourceId = *Constants::HealthReportNamingServiceSource;
        property = *Constants::DurationHealthProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        ASSERT_IF(extraDescription.empty(), "Naming_OperationSlow extra description cannot be empty");
        ASSERT_IF(dynamicProperty.empty(), "Naming_OperationSlow dynamic property cannot be empty");
        break;

    case SystemHealthReportCode::Naming_OperationSlowCompleted:
        sourceId = *Constants::HealthReportNamingServiceSource;
        property = *Constants::DurationHealthProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        ASSERT_IF(extraDescription.empty(), "Naming_OperationSlowCompleted extra description cannot be empty");
        ASSERT_IF(dynamicProperty.empty(), "Naming_OperationSlowCompleted dynamic property cannot be empty");
        break;

    case SystemHealthReportCode::Federation_LeaseTransportDelay:
        sourceId = *Constants::HealthReportFederationSource;
        property = *Constants::DurationHealthProperty;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        break;

    case SystemHealthReportCode::TR_SlowIO:
        sourceId = *Constants::HealthReportReplicatorSource;
        healthState = FABRIC_HEALTH_STATE_WARNING;
        removeWhenExpired = true;
        ASSERT_IF(dynamicProperty.empty(), "Transactional Replicator heath report dynamic property cannot be empty");
        break;

    default:
        Assert::CodingError("Unsupported reportCode {0}", reportCode);
    }

    if (!extraDescription.empty())
    {
        description += extraDescription;
    }

    if (!dynamicProperty.empty())
    {
        property += dynamicProperty;
    }

    HealthReport report(
        move(entityInformation),
        move(sourceId),
        move(property),
        timeToLive,
        healthState,
        move(description),
        sequenceNumber,
        removeWhenExpired,
        move(attributeList));
    auto error = report.TryAcceptUserOrSystemReport();
    ASSERT_IFNOT(error.IsSuccess(), "CreateSystemHealthReport: error validating the error report: {0} {1}", error, error.Message);

    return report;
}