private AlertFirmness calculateFirmnessForStateChange(Long clusterId, AlertDefinitionEntity definition,
      AlertState state, long occurrences) {
    // OK is always HARD since the alert has fulfilled the conditions
    if (state == AlertState.OK) {
      return AlertFirmness.HARD;
    }

    // aggregate alerts are always HARD since they only react to HARD alerts
    if (definition.getSourceType() == SourceType.AGGREGATE) {
      return AlertFirmness.HARD;
    }

    int tolerance = getRepeatTolerance(definition, clusterId);
    if (tolerance <= 1) {
      return AlertFirmness.HARD;
    }

    if (tolerance <= occurrences) {
      return AlertFirmness.HARD;
    }

    return AlertFirmness.SOFT;
  }
Gets the firmness for an {@link AlertCurrentEntity}. The following rules
apply:
<ul>
<li>If an alert is {@link AlertState#OK}, then the firmness is always
{@link AlertFirmness#HARD}.</li>
<li>If an alert is {@link SourceType#AGGREGATE}, then the firmness is
always {@link AlertFirmness#HARD}.</li>
<li>Otherwise, the firmness will be {@link AlertFirmness#SOFT} unless the
repeat tolerance has been met.</li>
</ul>

@param definition
         the definition to read any repeat tolerance overrides from.
@param state
         the state of the {@link AlertCurrentEntity}.
@param occurrences the
         occurrences of the alert in the current state (used for
         calculation firmness when moving between non-OK states)
@return
ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertReceivedListener.java