package com.linkedin.helix.monitoring.mbeans;


import com.linkedin.helix.alerts.AlertValueAndStatus;

public class ClusterAlertItem implements ClusterAlertItemMBean
{
  String _alertItemName;
  double  _alertValue;
  int _alertFired;
  AlertValueAndStatus _valueAndStatus;
  
  public ClusterAlertItem(String name, AlertValueAndStatus valueAndStatus)
  {
    _valueAndStatus = valueAndStatus;
    _alertItemName = name;
    refreshValues();
  }
  @Override
  public String getSensorName()
  {
    return _alertItemName;
  }

  @Override
  public double getAlertValue()
  {
    return _alertValue;
  }
  
  public void setValueMap(AlertValueAndStatus valueAndStatus)
  {
    _valueAndStatus = valueAndStatus;
    refreshValues();
  }
  
  void refreshValues()
  {
    _alertValue = Double.parseDouble(_valueAndStatus.getValue().getElements().get(0));
    _alertFired = _valueAndStatus.isFired() ?  1 : 0;
  }
  @Override
  public int getAlertFired()
  {
    return _alertFired;
  }
}

@@ -753,24 +753,92 @@
 alues()%0A  %7B%0A
+    if(_valueAndStatus.getValue().getElements().size() %3E 0)%0A    %7B%0A  
     _alertVa
@@ -912,16 +912,66 @@
 et(0));%0A
+    %7D%0A    else%0A    %7B%0A      _alertValue = 0;%0A    %7D%0A
     _ale

Fix a exception in the case that an Alert first get exposed, an exception is thrown due to the size of the Alert value elements is empty.