helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject [2/7] [HELIX-395] Remove old Helix alert/stat modules
Date Tue, 04 Mar 2014 19:04:49 GMT
http://git-wip-us.apache.org/repos/asf/helix/blob/db4c10a2/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java b/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java
deleted file mode 100644
index 8618b1c..0000000
--- a/helix-core/src/test/java/org/apache/helix/healthcheck/TestAlertFireHistory.java
+++ /dev/null
@@ -1,423 +0,0 @@
-package org.apache.helix.healthcheck;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixManager;
-import org.apache.helix.HelixProperty;
-import org.apache.helix.HelixTimerTask;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.integration.ZkStandAloneCMTestBaseWithPropertyServerCheck;
-import org.apache.helix.model.AlertHistory;
-import org.apache.helix.model.HealthStat;
-import org.apache.helix.model.HelixConfigScope;
-import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
-import org.apache.helix.model.builder.HelixConfigScopeBuilder;
-import org.apache.log4j.Logger;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/**
- * setup a storage cluster and start a zk-based cluster controller in stand-alone mode
- * start 5 dummy participants verify the current states at end
- */
-
-public class TestAlertFireHistory extends ZkStandAloneCMTestBaseWithPropertyServerCheck {
-  private final static Logger LOG = Logger.getLogger(TestAlertFireHistory.class);
-
-  String _statName = "TestStat@DB=db1";
-  String _stat = "TestStat";
-  String metricName1 = "TestMetric1";
-  String metricName2 = "TestMetric2";
-
-  String _alertStr1 = "EXP(decay(1.0)(localhost_*.TestStat@DB=db1.TestMetric1))CMP(GREATER)CON(20)";
-  String _alertStr2 =
-      "EXP(decay(1.0)(localhost_*.TestStat@DB=db1.TestMetric2))CMP(GREATER)CON(100)";
-
-  void setHealthData(int[] val1, int[] val2) {
-    for (int i = 0; i < NODE_NR; i++) {
-      HelixManager manager = _participants[i];
-      ZNRecord record = new ZNRecord(_stat);
-      Map<String, String> valMap = new HashMap<String, String>();
-      valMap.put(metricName1, val1[i] + "");
-      valMap.put(metricName2, val2[i] + "");
-      record.setSimpleField("TimeStamp", new Date().getTime() + "");
-      record.setMapField(_statName, valMap);
-      HelixDataAccessor helixDataAccessor = manager.getHelixDataAccessor();
-      Builder keyBuilder = helixDataAccessor.keyBuilder();
-      helixDataAccessor.setProperty(
-          keyBuilder.healthReport(manager.getInstanceName(), record.getId()),
-          new HealthStat(record));
-    }
-    try {
-      Thread.sleep(1000);
-    } catch (InterruptedException e) {
-      LOG.error("Interrupted sleep", e);
-    }
-  }
-
-  @Test
-  public void testAlertDisable() throws InterruptedException {
-
-    int[] metrics1 = {
-        10, 15, 22, 24, 16
-    };
-    int[] metrics2 = {
-        22, 115, 22, 141, 16
-    };
-    setHealthData(metrics1, metrics2);
-
-    HelixManager manager = _controller;
-    manager.startTimerTasks();
-
-    _setupTool.getClusterManagementTool().addAlert(CLUSTER_NAME, _alertStr1);
-    _setupTool.getClusterManagementTool().addAlert(CLUSTER_NAME, _alertStr2);
-
-    HelixConfigScope scope =
-        new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(CLUSTER_NAME).build();
-    Map<String, String> properties = new HashMap<String, String>();
-    properties.put("healthChange.enabled", "false");
-    _setupTool.getClusterManagementTool().setConfig(scope, properties);
-
-    HealthStatsAggregator task = new HealthStatsAggregator(_controller);
-
-    task.aggregate();
-    Thread.sleep(100);
-    HelixDataAccessor helixDataAccessor = manager.getHelixDataAccessor();
-    Builder keyBuilder = helixDataAccessor.keyBuilder();
-
-    AlertHistory history = manager.getHelixDataAccessor().getProperty(keyBuilder.alertHistory());
-
-    Assert.assertEquals(history, null);
-
-    properties.put("healthChange.enabled", "true");
-    _setupTool.getClusterManagementTool().setConfig(scope, properties);
-
-    task.aggregate();
-    Thread.sleep(100);
-
-    history = manager.getHelixDataAccessor().getProperty(keyBuilder.alertHistory());
-    //
-    Assert.assertNotNull(history);
-    Assert.assertEquals(history.getRecord().getMapFields().size(), 1);
-  }
-
-  @Test
-  public void testAlertHistory() throws InterruptedException {
-    int[] metrics1 = {
-        10, 15, 22, 24, 16
-    };
-    int[] metrics2 = {
-        22, 115, 22, 141, 16
-    };
-    setHealthData(metrics1, metrics2);
-
-    HelixManager manager = _controller;
-    for (HelixTimerTask task : _controller.getControllerTimerTasks()) {
-      task.stop();
-    }
-
-    _setupTool.getClusterManagementTool().addAlert(CLUSTER_NAME, _alertStr1);
-    _setupTool.getClusterManagementTool().addAlert(CLUSTER_NAME, _alertStr2);
-
-    int historySize = 0;
-    HelixDataAccessor helixDataAccessor = manager.getHelixDataAccessor();
-    Builder keyBuilder = helixDataAccessor.keyBuilder();
-    HelixProperty property = helixDataAccessor.getProperty(keyBuilder.alertHistory());
-    ZNRecord history = null;
-    if (property != null) {
-      history = property.getRecord();
-      historySize = property.getRecord().getMapFields().size();
-    }
-
-    HealthStatsAggregator task = new HealthStatsAggregator(_controller);
-
-    task.aggregate();
-    Thread.sleep(100);
-
-    history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
-    //
-    Assert.assertEquals(history.getMapFields().size(), 1 + historySize);
-    TreeMap<String, Map<String, String>> recordMap = new TreeMap<String, Map<String, String>>();
-    recordMap.putAll(history.getMapFields());
-    Map<String, String> lastRecord = recordMap.firstEntry().getValue();
-    Assert.assertTrue(lastRecord.size() == 4);
-    Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric1)GREATER(20)")
-        .equals("ON"));
-    Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)")
-        .equals("ON"));
-    Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)")
-        .equals("ON"));
-    Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)")
-        .equals("ON"));
-
-    setHealthData(metrics1, metrics2);
-    task.aggregate();
-    Thread.sleep(100);
-    history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
-    // no change
-    Assert.assertEquals(history.getMapFields().size(), 1 + historySize);
-    recordMap = new TreeMap<String, Map<String, String>>();
-    recordMap.putAll(history.getMapFields());
-    lastRecord = recordMap.firstEntry().getValue();
-    Assert.assertTrue(lastRecord.size() == 4);
-    Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric1)GREATER(20)")
-        .equals("ON"));
-    Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)")
-        .equals("ON"));
-    Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)")
-        .equals("ON"));
-    Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)")
-        .equals("ON"));
-
-    int[] metrics3 = {
-        21, 44, 22, 14, 16
-    };
-    int[] metrics4 = {
-        122, 115, 222, 41, 16
-    };
-    setHealthData(metrics3, metrics4);
-    task.aggregate();
-    Thread.sleep(100);
-    history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
-    // new delta should be recorded
-    Assert.assertEquals(history.getMapFields().size(), 2 + historySize);
-    recordMap = new TreeMap<String, Map<String, String>>();
-    recordMap.putAll(history.getMapFields());
-    lastRecord = recordMap.lastEntry().getValue();
-    Assert.assertEquals(lastRecord.size(), 6);
-    Assert.assertTrue(lastRecord.get("(localhost_12918.TestStat@DB#db1.TestMetric1)GREATER(20)")
-        .equals("ON"));
-    Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)")
-        .equals("OFF"));
-    Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric2)GREATER(100)")
-        .equals("ON"));
-    Assert.assertTrue(lastRecord.get("(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)")
-        .equals("OFF"));
-    Assert.assertTrue(lastRecord.get("(localhost_12918.TestStat@DB#db1.TestMetric2)GREATER(100)")
-        .equals("ON"));
-    Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric1)GREATER(20)")
-        .equals("ON"));
-
-    int[] metrics5 = {
-        0, 0, 0, 0, 0
-    };
-    int[] metrics6 = {
-        0, 0, 0, 0, 0
-    };
-    setHealthData(metrics5, metrics6);
-    task.aggregate();
-
-    for (int i = 0; i < 10; i++) {
-      Thread.sleep(500);
-      history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
-      recordMap = new TreeMap<String, Map<String, String>>();
-      recordMap.putAll(history.getMapFields());
-      lastRecord = recordMap.lastEntry().getValue();
-
-      if (history.getMapFields().size() == 3 + historySize && lastRecord.size() == 6) {
-        break;
-      }
-    }
-
-    // reset everything
-    Assert.assertEquals(history.getMapFields().size(), 3 + historySize,
-        "expect history-map-field size is " + (3 + historySize) + ", but was " + history);
-    Assert
-        .assertTrue(lastRecord.size() == 6, "expect last-record size is 6, but was " + lastRecord);
-
-    Assert.assertTrue(lastRecord.get("(localhost_12918.TestStat@DB#db1.TestMetric1)GREATER(20)")
-        .equals("OFF"));
-    Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric1)GREATER(20)")
-        .equals("OFF"));
-    Assert.assertTrue(lastRecord.get("(localhost_12920.TestStat@DB#db1.TestMetric2)GREATER(100)")
-        .equals("OFF"));
-    Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)")
-        .equals("OFF"));
-    Assert.assertTrue(lastRecord.get("(localhost_12918.TestStat@DB#db1.TestMetric2)GREATER(100)")
-        .equals("OFF"));
-    Assert.assertTrue(lastRecord.get("(localhost_12919.TestStat@DB#db1.TestMetric1)GREATER(20)")
-        .equals("OFF"));
-
-    // Size of the history should be 30
-    for (int i = 0; i < 27; i++) {
-      int x = i % 2;
-      int y = (i + 1) % 2;
-      int[] metricsx = {
-          19 + 3 * x, 19 + 3 * y, 19 + 4 * x, 18 + 4 * y, 17 + 5 * y
-      };
-      int[] metricsy = {
-          99 + 3 * x, 99 + 3 * y, 98 + 4 * x, 98 + 4 * y, 97 + 5 * y
-      };
-
-      setHealthData(metricsx, metricsy);
-      task.aggregate();
-      Thread.sleep(100);
-      history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
-
-      Assert.assertEquals(history.getMapFields().size(), Math.min(3 + i + 1 + historySize, 30));
-      recordMap = new TreeMap<String, Map<String, String>>();
-      recordMap.putAll(history.getMapFields());
-      lastRecord = recordMap.lastEntry().getValue();
-      if (i == 0) {
-        Assert.assertTrue(lastRecord.size() == 6);
-        Assert.assertTrue(lastRecord
-            .get("(localhost_12922.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
-        Assert.assertTrue(lastRecord.get(
-            "(localhost_12922.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
-        Assert.assertTrue(lastRecord.get(
-            "(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
-        Assert.assertTrue(lastRecord
-            .get("(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
-        Assert.assertTrue(lastRecord.get(
-            "(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
-        Assert.assertTrue(lastRecord
-            .get("(localhost_12919.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
-      } else {
-        System.out.println(lastRecord.size());
-        Assert.assertEquals(lastRecord.size(), 10);
-        if (x == 0) {
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12922.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12922.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12920.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12918.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12920.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12918.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12919.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
-        } else {
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12922.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12922.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12920.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12918.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12920.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12918.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
-          Assert.assertTrue(lastRecord.get(
-              "(localhost_12919.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
-        }
-      }
-    }
-    // size limit is 30
-    for (int i = 0; i < 10; i++) {
-      int x = i % 2;
-      int y = (i + 1) % 2;
-      int[] metricsx = {
-          19 + 3 * x, 19 + 3 * y, 19 + 4 * x, 18 + 4 * y, 17 + 5 * y
-      };
-      int[] metricsy = {
-          99 + 3 * x, 99 + 3 * y, 98 + 4 * x, 98 + 4 * y, 97 + 5 * y
-      };
-
-      setHealthData(metricsx, metricsy);
-      task.aggregate();
-      for (int j = 0; j < 10; j++) {
-        Thread.sleep(100);
-        history = helixDataAccessor.getProperty(keyBuilder.alertHistory()).getRecord();
-        recordMap = new TreeMap<String, Map<String, String>>();
-        recordMap.putAll(history.getMapFields());
-        lastRecord = recordMap.lastEntry().getValue();
-
-        if (history.getMapFields().size() == 30 && lastRecord.size() == 10)
-          break;
-      }
-      Assert.assertEquals(history.getMapFields().size(), 30,
-          "expect history.map-field size is 30, but was " + history);
-      Assert.assertEquals(lastRecord.size(), 10, "expect last-record size is 10, but was "
-          + lastRecord);
-
-      if (x == 0) {
-        Assert.assertTrue(lastRecord.get(
-            "(localhost_12922.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
-        Assert.assertTrue(lastRecord
-            .get("(localhost_12922.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
-        Assert.assertTrue(lastRecord
-            .get("(localhost_12920.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
-        Assert.assertTrue(lastRecord
-            .get("(localhost_12918.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
-        Assert.assertTrue(lastRecord.get(
-            "(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
-        Assert.assertTrue(lastRecord
-            .get("(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
-        Assert.assertTrue(lastRecord.get(
-            "(localhost_12920.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
-        Assert.assertTrue(lastRecord.get(
-            "(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
-        Assert.assertTrue(lastRecord.get(
-            "(localhost_12918.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
-        Assert.assertTrue(lastRecord
-            .get("(localhost_12919.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
-      } else {
-        Assert.assertTrue(lastRecord.get(
-            "(localhost_12922.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
-        Assert.assertTrue(lastRecord
-            .get("(localhost_12922.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
-        Assert.assertTrue(lastRecord
-            .get("(localhost_12920.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
-        Assert.assertTrue(lastRecord
-            .get("(localhost_12918.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("ON"));
-        Assert.assertTrue(lastRecord.get(
-            "(localhost_12919.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
-        Assert.assertTrue(lastRecord
-            .get("(localhost_12921.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
-        Assert.assertTrue(lastRecord.get(
-            "(localhost_12920.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
-        Assert.assertTrue(lastRecord.get(
-            "(localhost_12921.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("OFF"));
-        Assert.assertTrue(lastRecord.get(
-            "(localhost_12918.TestStat@DB#db1.TestMetric2)GREATER(100)").equals("ON"));
-        Assert.assertTrue(lastRecord
-            .get("(localhost_12919.TestStat@DB#db1.TestMetric1)GREATER(20)").equals("OFF"));
-      }
-    }
-
-  }
-
-}
-

http://git-wip-us.apache.org/repos/asf/helix/blob/db4c10a2/helix-core/src/test/java/org/apache/helix/healthcheck/TestDummyAlerts.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/healthcheck/TestDummyAlerts.java b/helix-core/src/test/java/org/apache/helix/healthcheck/TestDummyAlerts.java
deleted file mode 100644
index 29f4893..0000000
--- a/helix-core/src/test/java/org/apache/helix/healthcheck/TestDummyAlerts.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package org.apache.helix.healthcheck;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Date;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixManager;
-import org.apache.helix.NotificationContext;
-import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.integration.ZkIntegrationTestBase;
-import org.apache.helix.integration.manager.ClusterControllerManager;
-import org.apache.helix.integration.manager.MockParticipantManager;
-import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.mock.participant.MockTransition;
-import org.apache.helix.model.HealthStat;
-import org.apache.helix.model.Message;
-import org.apache.helix.tools.ClusterSetup;
-import org.apache.helix.tools.ClusterStateVerifier;
-import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
-import org.apache.helix.tools.ClusterStateVerifier.MasterNbInExtViewVerifier;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-public class TestDummyAlerts extends ZkIntegrationTestBase {
-  public class DummyAlertsTransition extends MockTransition {
-    private final AtomicBoolean _done = new AtomicBoolean(false);
-
-    @Override
-    public void doTransition(Message message, NotificationContext context) {
-      HelixManager manager = context.getManager();
-      HelixDataAccessor accessor = manager.getHelixDataAccessor();
-      Builder keyBuilder = accessor.keyBuilder();
-
-      String instance = message.getTgtName();
-      if (_done.getAndSet(true) == false) {
-        for (int i = 0; i < 5; i++) {
-          // System.out.println(instance + " sets healthReport: " + "mockAlerts" + i);
-          accessor.setProperty(keyBuilder.healthReport(instance, "mockAlerts"), new HealthStat(
-              new ZNRecord("mockAlerts" + i)));
-        }
-      }
-    }
-
-  }
-
-  @Test()
-  public void testDummyAlerts() throws Exception {
-    // Logger.getRootLogger().setLevel(Level.INFO);
-    String className = TestHelper.getTestClassName();
-    String methodName = TestHelper.getTestMethodName();
-    String clusterName = className + "_" + methodName;
-    final int n = 5;
-
-    MockParticipantManager[] participants = new MockParticipantManager[n];
-
-    System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
-
-    TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant start
-                                                         // port
-        "localhost", // participant name prefix
-        "TestDB", // resource name prefix
-        1, // resources
-        10, // partitions per resource
-        n, // number of nodes
-        3, // replicas
-        "MasterSlave", true); // do rebalance
-
-    ClusterSetup setupTool = new ClusterSetup(ZK_ADDR);
-    enableHealthCheck(clusterName);
-    setupTool
-        .getClusterManagementTool()
-        .addAlert(clusterName,
-            "EXP(decay(1.0)(*.defaultPerfCounters@defaultPerfCounters.availableCPUs))CMP(GREATER)CON(2)");
-
-    // start controller
-    ClusterControllerManager controller =
-        new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
-    controller.syncStart();
-
-    // start participants
-    for (int i = 0; i < n; i++) {
-      String instanceName = "localhost_" + (12918 + i);
-
-      participants[i] = new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
-      participants[i].setTransition(new DummyAlertsTransition());
-      participants[i].syncStart();
-    }
-
-    boolean result =
-        ClusterStateVerifier
-            .verifyByZkCallback(new MasterNbInExtViewVerifier(ZK_ADDR, clusterName));
-    Assert.assertTrue(result);
-
-    result =
-        ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
-            clusterName));
-    Assert.assertTrue(result);
-
-    // other verifications go here
-    ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
-    Builder keyBuilder = accessor.keyBuilder();
-
-    for (int i = 0; i < n; i++) {
-      String instance = "localhost_" + (12918 + i);
-      ZNRecord record = null;
-      for (int j = 0; j < 10; j++) {
-        record = accessor.getProperty(keyBuilder.healthReport(instance, "mockAlerts")).getRecord();
-        if (record.getId().equals("mockAlerts4")) {
-          break;
-        } else {
-          Thread.sleep(500);
-        }
-      }
-      Assert.assertEquals(record.getId(), "mockAlerts4");
-    }
-
-    // clean up
-    controller.syncStop();
-    for (int i = 0; i < 5; i++) {
-      participants[i].syncStop();
-    }
-
-    System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/db4c10a2/helix-core/src/test/java/org/apache/helix/healthcheck/TestExpandAlert.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/healthcheck/TestExpandAlert.java b/helix-core/src/test/java/org/apache/helix/healthcheck/TestExpandAlert.java
deleted file mode 100644
index 23741c3..0000000
--- a/helix-core/src/test/java/org/apache/helix/healthcheck/TestExpandAlert.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package org.apache.helix.healthcheck;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Date;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixManager;
-import org.apache.helix.NotificationContext;
-import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.alerts.AlertValueAndStatus;
-import org.apache.helix.api.State;
-import org.apache.helix.healthcheck.ParticipantHealthReportCollectorImpl;
-import org.apache.helix.integration.ZkIntegrationTestBase;
-import org.apache.helix.integration.manager.ClusterControllerManager;
-import org.apache.helix.integration.manager.MockParticipantManager;
-import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.mock.participant.MockEspressoHealthReportProvider;
-import org.apache.helix.mock.participant.MockTransition;
-import org.apache.helix.model.Message;
-import org.apache.helix.tools.ClusterSetup;
-import org.apache.helix.tools.ClusterStateVerifier;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-public class TestExpandAlert extends ZkIntegrationTestBase {
-  protected ClusterSetup _setupTool = null;
-  protected final String _alertStr =
-      "EXP(decay(1.0)(localhost_*.RestQueryStats@DBName=TestDB0.latency))CMP(GREATER)CON(16)";
-  protected final String _alertStatusStr = _alertStr
-      + " : (localhost_12918.RestQueryStats@DBName=TestDB0.latency)";
-  protected final String _dbName = "TestDB0";
-
-  @BeforeClass()
-  public void beforeClass() throws Exception {
-
-    _setupTool = new ClusterSetup(_gZkClient);
-  }
-
-  @AfterClass
-  public void afterClass() {
-  }
-
-  public class ExpandAlertTransition extends MockTransition {
-    @Override
-    public void doTransition(Message message, NotificationContext context) {
-      HelixManager manager = context.getManager();
-      HelixDataAccessor accessor = manager.getHelixDataAccessor();
-      State fromState = message.getTypedFromState();
-      State toState = message.getTypedToState();
-      String instance = message.getTgtName();
-
-      if (fromState.toString().equalsIgnoreCase("SLAVE")
-          && toState.toString().equalsIgnoreCase("MASTER")) {
-
-        // add a stat and report to ZK
-        // perhaps should keep reporter per instance...
-        ParticipantHealthReportCollectorImpl reporter =
-            new ParticipantHealthReportCollectorImpl(manager, instance);
-        MockEspressoHealthReportProvider provider = new MockEspressoHealthReportProvider();
-        reporter.addHealthReportProvider(provider);
-        String statName = "latency";
-        provider.setStat(_dbName, statName, "15");
-        reporter.transmitHealthReports();
-
-        /*
-         * for (int i = 0; i < 5; i++)
-         * {
-         * accessor.setProperty(PropertyType.HEALTHREPORT,
-         * new ZNRecord("mockAlerts" + i),
-         * instance,
-         * "mockAlerts");
-         * try
-         * {
-         * Thread.sleep(1000);
-         * }
-         * catch (InterruptedException e)
-         * {
-         * // TODO Auto-generated catch block
-         * e.printStackTrace();
-         * }
-         * }
-         */
-      }
-    }
-
-  }
-
-  @Test()
-  public void testExpandAlert() throws Exception {
-    String clusterName = getShortClassName();
-    MockParticipantManager[] participants = new MockParticipantManager[5];
-
-    System.out.println("START TestExpandAlert at " + new Date(System.currentTimeMillis()));
-
-    TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant start port
-        "localhost", // participant name prefix
-        "TestDB", // resource name prefix
-        1, // resources
-        10, // partitions per resource
-        5, // number of nodes //change back to 5!!!
-        3, // replicas //change back to 3!!!
-        "MasterSlave", true); // do rebalance
-    // enableHealthCheck(clusterName);
-
-    _setupTool.getClusterManagementTool().addAlert(clusterName, _alertStr);
-
-    ClusterControllerManager controller =
-        new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
-    controller.syncStart();
-
-    // start participants
-    for (int i = 0; i < 5; i++) // !!!change back to 5
-    {
-      String instanceName = "localhost_" + (12918 + i);
-
-      participants[i] =
-          new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
-      participants[i].setTransition(new ExpandAlertTransition());
-      participants[i].syncStart();
-    }
-
-    boolean result =
-        ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
-            ZK_ADDR, clusterName));
-    Assert.assertTrue(result);
-
-    Thread.sleep(1000);
-    // HealthAggregationTask is supposed to run by a timer every 30s
-    // To make sure HealthAggregationTask is run, we invoke it explicitly for this test
-    // new HealthStatsAggregator(cmResult._manager).aggregate();
-    new HealthStatsAggregator(controller).aggregate();
-    // sleep for a few seconds to give stats stage time to trigger
-    Thread.sleep(3000);
-
-    // other verifications go here
-    ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
-    Builder keyBuilder = accessor.keyBuilder();
-
-    // for (int i = 0; i < 1; i++) //change 1 back to 5
-    // {
-    // String instance = "localhost_" + (12918 + i);
-    // String instance = "localhost_12918";
-    ZNRecord record = accessor.getProperty(keyBuilder.alertStatus()).getRecord();
-    Map<String, Map<String, String>> recMap = record.getMapFields();
-    Set<String> keySet = recMap.keySet();
-    Map<String, String> alertStatusMap = recMap.get(_alertStatusStr);
-    String val = alertStatusMap.get(AlertValueAndStatus.VALUE_NAME);
-    boolean fired = Boolean.parseBoolean(alertStatusMap.get(AlertValueAndStatus.FIRED_NAME));
-    Assert.assertEquals(Double.parseDouble(val), Double.parseDouble("15.0"));
-    Assert.assertFalse(fired);
-    // }
-
-    // clean up
-    controller.syncStop();
-    for (int i = 0; i < 5; i++) {
-      participants[i].syncStop();
-
-    }
-    System.out.println("END TestExpandAlert at " + new Date(System.currentTimeMillis()));
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/db4c10a2/helix-core/src/test/java/org/apache/helix/healthcheck/TestSimpleAlert.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/healthcheck/TestSimpleAlert.java b/helix-core/src/test/java/org/apache/helix/healthcheck/TestSimpleAlert.java
deleted file mode 100644
index dbbd7aa..0000000
--- a/helix-core/src/test/java/org/apache/helix/healthcheck/TestSimpleAlert.java
+++ /dev/null
@@ -1,201 +0,0 @@
-package org.apache.helix.healthcheck;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Date;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixManager;
-import org.apache.helix.NotificationContext;
-import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.alerts.AlertValueAndStatus;
-import org.apache.helix.api.State;
-import org.apache.helix.healthcheck.ParticipantHealthReportCollectorImpl;
-import org.apache.helix.integration.ZkIntegrationTestBase;
-import org.apache.helix.integration.manager.ClusterControllerManager;
-import org.apache.helix.integration.manager.MockParticipantManager;
-import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.mock.participant.MockEspressoHealthReportProvider;
-import org.apache.helix.mock.participant.MockTransition;
-import org.apache.helix.model.Message;
-import org.apache.helix.tools.ClusterSetup;
-import org.apache.helix.tools.ClusterStateVerifier;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-public class TestSimpleAlert extends ZkIntegrationTestBase {
-  protected ClusterSetup _setupTool = null;
-  protected final String _alertStr =
-      "EXP(decay(1.0)(localhost_12918.RestQueryStats@DBName=TestDB0.latency))CMP(GREATER)CON(10)";
-  protected final String _alertStatusStr = _alertStr; // +" : (*)";
-  protected final String _dbName = "TestDB0";
-
-  @BeforeClass()
-  public void beforeClass() throws Exception {
-    _setupTool = new ClusterSetup(_gZkClient);
-  }
-
-  @AfterClass
-  public void afterClass() {
-  }
-
-  public class SimpleAlertTransition extends MockTransition {
-    int _alertValue;
-
-    public SimpleAlertTransition(int value) {
-      _alertValue = value;
-    }
-
-    @Override
-    public void doTransition(Message message, NotificationContext context) {
-      HelixManager manager = context.getManager();
-      HelixDataAccessor accessor = manager.getHelixDataAccessor();
-      State fromState = message.getTypedFromState();
-      State toState = message.getTypedToState();
-      String instance = message.getTgtName();
-
-      if (fromState.toString().equalsIgnoreCase("SLAVE")
-          && toState.toString().equalsIgnoreCase("MASTER")) {
-
-        // add a stat and report to ZK
-        // perhaps should keep reporter per instance...
-        ParticipantHealthReportCollectorImpl reporter =
-            new ParticipantHealthReportCollectorImpl(manager, instance);
-        MockEspressoHealthReportProvider provider = new MockEspressoHealthReportProvider();
-        reporter.addHealthReportProvider(provider);
-        String statName = "latency";
-        provider.setStat(_dbName, statName, "" + (0.1 + _alertValue));
-        reporter.transmitHealthReports();
-
-        /*
-         * for (int i = 0; i < 5; i++)
-         * {
-         * accessor.setProperty(PropertyType.HEALTHREPORT,
-         * new ZNRecord("mockAlerts" + i),
-         * instance,
-         * "mockAlerts");
-         * try
-         * {
-         * Thread.sleep(1000);
-         * }
-         * catch (InterruptedException e)
-         * {
-         * // TODO Auto-generated catch block
-         * e.printStackTrace();
-         * }
-         * }
-         */
-      }
-    }
-
-  }
-
-  @Test()
-  public void testSimpleAlert() throws Exception {
-    String clusterName = getShortClassName();
-    MockParticipantManager[] participants = new MockParticipantManager[5];
-
-    System.out.println("START TestSimpleAlert at " + new Date(System.currentTimeMillis()));
-
-    TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant start port
-        "localhost", // participant name prefix
-        "TestDB", // resource name prefix
-        1, // resources
-        10, // partitions per resource
-        5, // number of nodes //change back to 5!!!
-        3, // replicas //change back to 3!!!
-        "MasterSlave", true); // do rebalance
-
-    // enableHealthCheck(clusterName);
-
-    ClusterControllerManager controller =
-        new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
-    controller.syncStart();
-    controller.startTimerTasks();
-
-    _setupTool.getClusterManagementTool().addAlert(clusterName, _alertStr);
-    // start participants
-    for (int i = 0; i < 5; i++) // !!!change back to 5
-    {
-      String instanceName = "localhost_" + (12918 + i);
-
-      participants[i] =
-          new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
-      participants[i].setTransition(new SimpleAlertTransition(15));
-      participants[i].syncStart();
-    }
-
-    boolean result =
-        ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
-            ZK_ADDR, clusterName));
-    Assert.assertTrue(result);
-
-    // HealthAggregationTask is supposed to run by a timer every 30s
-    // To make sure HealthAggregationTask is run, we invoke it explicitly for this test
-    // new HealthStatsAggregator(cmResult._manager).aggregate();
-    new HealthStatsAggregator(controller).aggregate();
-    // sleep for a few seconds to give stats stage time to trigger
-    Thread.sleep(3000);
-
-    // other verifications go here
-    ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
-    Builder keyBuilder = accessor.keyBuilder();
-    // for (int i = 0; i < 1; i++) //change 1 back to 5
-    // {
-    // String instance = "localhost_" + (12918 + i);
-    String instance = "localhost_12918";
-    ZNRecord record = accessor.getProperty(keyBuilder.alertStatus()).getRecord();
-    Map<String, Map<String, String>> recMap = record.getMapFields();
-    Set<String> keySet = recMap.keySet();
-    Map<String, String> alertStatusMap = recMap.get(_alertStatusStr);
-    String val = alertStatusMap.get(AlertValueAndStatus.VALUE_NAME);
-    boolean fired = Boolean.parseBoolean(alertStatusMap.get(AlertValueAndStatus.FIRED_NAME));
-    Assert.assertEquals(Double.parseDouble(val), Double.parseDouble("15.1"));
-    Assert.assertTrue(fired);
-
-    // Verify Alert history from ZK
-    ZNRecord alertHistory = accessor.getProperty(keyBuilder.alertHistory()).getRecord();
-
-    String deltakey = (String) (alertHistory.getMapFields().keySet().toArray()[0]);
-    Map<String, String> delta = alertHistory.getMapField(deltakey);
-    Assert.assertTrue(delta.size() == 1);
-    Assert
-        .assertTrue(delta
-            .get(
-                "EXP(decay(1.0)(localhost_12918.RestQueryStats@DBName#TestDB0.latency))CMP(GREATER)CON(10)--(%)")
-            .equals("ON"));
-    // }
-
-    // clean up
-    controller.syncStop();
-    for (int i = 0; i < 5; i++) {
-      participants[i].syncStop();
-    }
-    System.out.println("END TestSimpleAlert at " + new Date(System.currentTimeMillis()));
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/db4c10a2/helix-core/src/test/java/org/apache/helix/healthcheck/TestSimpleWildcardAlert.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/healthcheck/TestSimpleWildcardAlert.java b/helix-core/src/test/java/org/apache/helix/healthcheck/TestSimpleWildcardAlert.java
deleted file mode 100644
index 90223ad..0000000
--- a/helix-core/src/test/java/org/apache/helix/healthcheck/TestSimpleWildcardAlert.java
+++ /dev/null
@@ -1,247 +0,0 @@
-package org.apache.helix.healthcheck;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Date;
-import java.util.Map;
-
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixManager;
-import org.apache.helix.NotificationContext;
-import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.alerts.AlertValueAndStatus;
-import org.apache.helix.api.State;
-import org.apache.helix.healthcheck.ParticipantHealthReportCollectorImpl;
-import org.apache.helix.integration.ZkIntegrationTestBase;
-import org.apache.helix.integration.manager.ClusterControllerManager;
-import org.apache.helix.integration.manager.MockParticipantManager;
-import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.mock.participant.MockEspressoHealthReportProvider;
-import org.apache.helix.mock.participant.MockTransition;
-import org.apache.helix.model.Message;
-import org.apache.helix.tools.ClusterSetup;
-import org.apache.helix.tools.ClusterStateVerifier;
-import org.apache.log4j.Logger;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-public class TestSimpleWildcardAlert extends ZkIntegrationTestBase {
-  private static Logger LOG = Logger.getLogger(TestSimpleWildcardAlert.class);
-
-  protected ClusterSetup _setupTool = null;
-  protected final String _alertStr =
-      "EXP(decay(1.0)(localhost_12918.RestQueryStats@DBName=TestDB0.latency))CMP(GREATER)CON(10)";
-  protected final String _alertStatusStr = _alertStr; // +" : (*)";
-  protected final String _dbName = "TestDB0";
-
-  @BeforeClass()
-  public void beforeClass() throws Exception {
-
-    _setupTool = new ClusterSetup(_gZkClient);
-  }
-
-  @AfterClass
-  public void afterClass() {
-  }
-
-  public class SimpleAlertTransition extends MockTransition {
-    int _alertValue;
-
-    public SimpleAlertTransition(int value) {
-      _alertValue = value;
-    }
-
-    @Override
-    public void doTransition(Message message, NotificationContext context) {
-      HelixManager manager = context.getManager();
-      HelixDataAccessor accessor = manager.getHelixDataAccessor();
-      State fromState = message.getTypedFromState();
-      State toState = message.getTypedToState();
-      String instance = message.getTgtName();
-
-      if (fromState.toString().equalsIgnoreCase("SLAVE")
-          && toState.toString().equalsIgnoreCase("MASTER")) {
-
-        // add a stat and report to ZK
-        // perhaps should keep reporter per instance...
-        ParticipantHealthReportCollectorImpl reporter =
-            new ParticipantHealthReportCollectorImpl(manager, instance);
-        MockEspressoHealthReportProvider provider = new MockEspressoHealthReportProvider();
-        reporter.addHealthReportProvider(provider);
-        String statName = "latency";
-        provider.setStat(_dbName, statName, "" + (0.1 + _alertValue));
-        reporter.transmitHealthReports();
-
-        /*
-         * for (int i = 0; i < 5; i++)
-         * {
-         * accessor.setProperty(PropertyType.HEALTHREPORT,
-         * new ZNRecord("mockAlerts" + i),
-         * instance,
-         * "mockAlerts");
-         * try
-         * {
-         * Thread.sleep(1000);
-         * }
-         * catch (InterruptedException e)
-         * {
-         * // TODO Auto-generated catch block
-         * e.printStackTrace();
-         * }
-         * }
-         */
-      }
-    }
-
-  }
-
-  @Test()
-  public void testSimpleWildcardAlert() throws Exception {
-    String clusterName = getShortClassName();
-    MockParticipantManager[] participants = new MockParticipantManager[5];
-
-    System.out.println("START testSimpleWildcardAlert at " + new Date(System.currentTimeMillis()));
-
-    TestHelper.setupCluster(clusterName, ZK_ADDR, 12944, // participant start port
-        "localhost", // participant name prefix
-        "TestDB", // resource name prefix
-        1, // resources
-        10, // partitions per resource
-        5, // number of nodes //change back to 5!!!
-        3, // replicas //change back to 3!!!
-        "MasterSlave", true); // do rebalance
-
-    // enableHealthCheck(clusterName);
-
-    ClusterControllerManager controller =
-        new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
-    controller.syncStart();
-    controller.stopTimerTasks();
-
-    String alertwildcard =
-        "EXP(decay(1.0)(localhost*.RestQueryStats@DBName=TestDB0.latency))CMP(GREATER)CON(10)";
-
-    _setupTool.getClusterManagementTool().addAlert(clusterName, alertwildcard);
-    // start participants
-    for (int i = 0; i < 5; i++) // !!!change back to 5
-    {
-      String instanceName = "localhost_" + (12944 + i);
-
-      participants[i] =
-          new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
-      participants[i].setTransition(new SimpleAlertTransition(i * 5));
-      participants[i].syncStart();
-    }
-
-    boolean result =
-        ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
-            ZK_ADDR, clusterName));
-    Assert.assertTrue(result);
-
-    Thread.sleep(1000);
-    // HealthAggregationTask is supposed to run by a timer every 30s
-    // To make sure HealthAggregationTask is run, we invoke it explicitly for this test
-    new HealthStatsAggregator(controller).aggregate();
-    // sleep for a few seconds to give stats stage time to trigger
-    Thread.sleep(1000);
-
-    // other verifications go here
-    ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
-    Builder keyBuilder = accessor.keyBuilder();
-    ZNRecord record = accessor.getProperty(keyBuilder.alertStatus()).getRecord();
-    Map<String, Map<String, String>> recMap = record.getMapFields();
-    for (int i = 0; i < 2; i++) {
-      String alertString = "(localhost_" + (12944 + i) + ".RestQueryStats@DBName=TestDB0.latency)";
-      Map<String, String> alertStatusMap = recMap.get(alertwildcard + " : " + alertString);
-      String val = alertStatusMap.get(AlertValueAndStatus.VALUE_NAME);
-      boolean fired = Boolean.parseBoolean(alertStatusMap.get(AlertValueAndStatus.FIRED_NAME));
-      Assert.assertEquals(Double.parseDouble(val), (double) i * 5 + 0.1);
-      Assert.assertFalse(fired);
-    }
-    for (int i = 2; i < 5; i++) {
-      String alertString = "(localhost_" + (12944 + i) + ".RestQueryStats@DBName=TestDB0.latency)";
-      Map<String, String> alertStatusMap = recMap.get(alertwildcard + " : " + alertString);
-      String val = alertStatusMap.get(AlertValueAndStatus.VALUE_NAME);
-      boolean fired = Boolean.parseBoolean(alertStatusMap.get(AlertValueAndStatus.FIRED_NAME));
-      Assert.assertEquals(Double.parseDouble(val), (double) i * 5 + 0.1);
-      Assert.assertTrue(fired);
-    }
-    ZNRecord alertHistory = accessor.getProperty(keyBuilder.alertHistory()).getRecord();
-
-    String deltakey = (String) (alertHistory.getMapFields().keySet().toArray()[0]);
-    Map<String, String> delta = alertHistory.getMapField(deltakey);
-    Assert.assertEquals(delta.size(), 3);
-    for (int i = 2; i < 5; i++) {
-      String alertString =
-          "(localhost_" + (12944 + i) + ".RestQueryStats@DBName#TestDB0.latency)GREATER(10)";
-      Assert.assertTrue(delta.get(alertString).equals("ON"));
-    }
-
-    // Drop and add another alert
-    _setupTool.getClusterManagementTool().dropAlert(clusterName, alertwildcard);
-    alertwildcard =
-        "EXP(decay(1.0)(localhost*.RestQueryStats@DBName=TestDB0.latency))CMP(GREATER)CON(15)";
-    _setupTool.getClusterManagementTool().addAlert(clusterName, alertwildcard);
-    new HealthStatsAggregator(controller).aggregate();
-    Thread.sleep(1000);
-
-    record = accessor.getProperty(keyBuilder.alertStatus()).getRecord();
-    recMap = record.getMapFields();
-    for (int i = 0; i < 3; i++) {
-      String alertString = "(localhost_" + (12944 + i) + ".RestQueryStats@DBName=TestDB0.latency)";
-      Map<String, String> alertStatusMap = recMap.get(alertwildcard + " : " + alertString);
-      String val = alertStatusMap.get(AlertValueAndStatus.VALUE_NAME);
-      boolean fired = Boolean.parseBoolean(alertStatusMap.get(AlertValueAndStatus.FIRED_NAME));
-      Assert.assertEquals(Double.parseDouble(val), (double) i * 5 + 0.1);
-      Assert.assertFalse(fired);
-    }
-    for (int i = 3; i < 5; i++) {
-      String alertString = "(localhost_" + (12944 + i) + ".RestQueryStats@DBName=TestDB0.latency)";
-      Map<String, String> alertStatusMap = recMap.get(alertwildcard + " : " + alertString);
-      String val = alertStatusMap.get(AlertValueAndStatus.VALUE_NAME);
-      boolean fired = Boolean.parseBoolean(alertStatusMap.get(AlertValueAndStatus.FIRED_NAME));
-      Assert.assertEquals(Double.parseDouble(val), (double) i * 5 + 0.1);
-      Assert.assertTrue(fired);
-    }
-    alertHistory = accessor.getProperty(keyBuilder.alertHistory()).getRecord();
-
-    deltakey = (String) (alertHistory.getMapFields().keySet().toArray()[1]);
-    delta = alertHistory.getMapField(deltakey);
-    Assert.assertTrue(delta.size() == 2);
-    for (int i = 3; i < 5; i++) {
-      String alertString =
-          "(localhost_" + (12944 + i) + ".RestQueryStats@DBName#TestDB0.latency)GREATER(15)";
-      Assert.assertTrue(delta.get(alertString).equals("ON"));
-    }
-
-    // clean up
-    controller.syncStop();
-    for (int i = 0; i < 5; i++) {
-      participants[i].syncStop();
-    }
-    System.out.println("END testSimpleWildcardAlert at " + new Date(System.currentTimeMillis()));
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/db4c10a2/helix-core/src/test/java/org/apache/helix/healthcheck/TestStalenessAlert.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/healthcheck/TestStalenessAlert.java b/helix-core/src/test/java/org/apache/helix/healthcheck/TestStalenessAlert.java
deleted file mode 100644
index 76784d3..0000000
--- a/helix-core/src/test/java/org/apache/helix/healthcheck/TestStalenessAlert.java
+++ /dev/null
@@ -1,181 +0,0 @@
-package org.apache.helix.healthcheck;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Date;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixManager;
-import org.apache.helix.NotificationContext;
-import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.alerts.AlertValueAndStatus;
-import org.apache.helix.api.State;
-import org.apache.helix.healthcheck.ParticipantHealthReportCollectorImpl;
-import org.apache.helix.integration.ZkIntegrationTestBase;
-import org.apache.helix.integration.manager.ClusterControllerManager;
-import org.apache.helix.integration.manager.MockParticipantManager;
-import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.mock.participant.MockEspressoHealthReportProvider;
-import org.apache.helix.mock.participant.MockTransition;
-import org.apache.helix.model.Message;
-import org.apache.helix.tools.ClusterSetup;
-import org.apache.helix.tools.ClusterStateVerifier;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-public class TestStalenessAlert extends ZkIntegrationTestBase {
-  protected ClusterSetup _setupTool = null;
-  protected final String _alertStr = "EXP(decay(1)(localhost_*.reportingage))CMP(GREATER)CON(600)";
-  protected final String _alertStatusStr = _alertStr + " : (localhost_12918.reportingage)";
-  protected final String _dbName = "TestDB0";
-
-  @BeforeClass()
-  public void beforeClass() throws Exception {
-
-    _setupTool = new ClusterSetup(_gZkClient);
-  }
-
-  @AfterClass
-  public void afterClass() {
-  }
-
-  public class StalenessAlertTransition extends MockTransition {
-    @Override
-    public void doTransition(Message message, NotificationContext context) {
-      HelixManager manager = context.getManager();
-      HelixDataAccessor accessor = manager.getHelixDataAccessor();
-      State fromState = message.getTypedFromState();
-      State toState = message.getTypedToState();
-      String instance = message.getTgtName();
-
-      if (fromState.toString().equalsIgnoreCase("SLAVE")
-          && toState.toString().equalsIgnoreCase("MASTER")) {
-
-        // add a stat and report to ZK
-        // perhaps should keep reporter per instance...
-        ParticipantHealthReportCollectorImpl reporter =
-            new ParticipantHealthReportCollectorImpl(manager, instance);
-        MockEspressoHealthReportProvider provider = new MockEspressoHealthReportProvider();
-        reporter.addHealthReportProvider(provider);
-        String statName = "latency";
-        provider.setStat(_dbName, statName, "15");
-        reporter.transmitHealthReports();
-
-        /*
-         * for (int i = 0; i < 5; i++)
-         * {
-         * accessor.setProperty(PropertyType.HEALTHREPORT,
-         * new ZNRecord("mockAlerts" + i),
-         * instance,
-         * "mockAlerts");
-         * try
-         * {
-         * Thread.sleep(1000);
-         * }
-         * catch (InterruptedException e)
-         * {
-         * // TODO Auto-generated catch block
-         * e.printStackTrace();
-         * }
-         * }
-         */
-      }
-    }
-
-  }
-
-  @Test()
-  public void testStalenessAlert() throws Exception {
-    String clusterName = getShortClassName();
-    MockParticipantManager[] participants = new MockParticipantManager[5];
-
-    System.out.println("START TestStalenessAlert at " + new Date(System.currentTimeMillis()));
-
-    TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant start port
-        "localhost", // participant name prefix
-        "TestDB", // resource name prefix
-        1, // resources
-        10, // partitions per resource
-        5, // number of nodes //change back to 5!!!
-        3, // replicas //change back to 3!!!
-        "MasterSlave", true); // do rebalance
-    // enableHealthCheck(clusterName);
-
-    _setupTool.getClusterManagementTool().addAlert(clusterName, _alertStr);
-
-    ClusterControllerManager controller =
-        new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
-    controller.syncStart();
-
-    // start participants
-    for (int i = 0; i < 5; i++) // !!!change back to 5
-    {
-      String instanceName = "localhost_" + (12918 + i);
-
-      participants[i] =
-          new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
-      participants[i].setTransition(new StalenessAlertTransition());
-      participants[i].syncStart();
-    }
-
-    boolean result =
-        ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
-            ZK_ADDR, clusterName));
-    Assert.assertTrue(result);
-
-    // HealthAggregationTask is supposed to run by a timer every 30s
-    // To make sure HealthAggregationTask is run, we invoke it explicitly for this test
-    new HealthStatsAggregator(controller).aggregate();
-    // sleep for a few seconds to give stats stage time to trigger
-    Thread.sleep(3000);
-
-    // other verifications go here
-    ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
-    Builder keyBuilder = accessor.keyBuilder();
-    // for (int i = 0; i < 1; i++) //change 1 back to 5
-    // {
-    // String instance = "localhost_" + (12918 + i);
-    // String instance = "localhost_12918";
-    ZNRecord record = accessor.getProperty(keyBuilder.alertStatus()).getRecord();
-    Map<String, Map<String, String>> recMap = record.getMapFields();
-    Set<String> keySet = recMap.keySet();
-    Map<String, String> alertStatusMap = recMap.get(_alertStatusStr);
-    String val = alertStatusMap.get(AlertValueAndStatus.VALUE_NAME);
-    boolean fired = Boolean.parseBoolean(alertStatusMap.get(AlertValueAndStatus.FIRED_NAME));
-    // Assert.assertEquals(Double.parseDouble(val), Double.parseDouble("75.0"));
-    // Assert.assertFalse(fired);
-    // }
-
-    // clean up
-    controller.syncStop();
-    for (int i = 0; i < 5; i++) {
-      participants[i].syncStop();
-    }
-    System.out.println("END TestStalenessAlert at " + new Date(System.currentTimeMillis()));
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/db4c10a2/helix-core/src/test/java/org/apache/helix/healthcheck/TestWildcardAlert.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/healthcheck/TestWildcardAlert.java b/helix-core/src/test/java/org/apache/helix/healthcheck/TestWildcardAlert.java
deleted file mode 100644
index 79c85ca..0000000
--- a/helix-core/src/test/java/org/apache/helix/healthcheck/TestWildcardAlert.java
+++ /dev/null
@@ -1,297 +0,0 @@
-package org.apache.helix.healthcheck;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerNotification;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixManager;
-import org.apache.helix.NotificationContext;
-import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.alerts.AlertValueAndStatus;
-import org.apache.helix.api.State;
-import org.apache.helix.healthcheck.ParticipantHealthReportCollectorImpl;
-import org.apache.helix.integration.ZkIntegrationTestBase;
-import org.apache.helix.integration.manager.ClusterControllerManager;
-import org.apache.helix.integration.manager.MockParticipantManager;
-import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
-import org.apache.helix.mock.participant.MockEspressoHealthReportProvider;
-import org.apache.helix.mock.participant.MockTransition;
-import org.apache.helix.model.Message;
-import org.apache.helix.monitoring.mbeans.ClusterAlertMBeanCollection;
-import org.apache.helix.monitoring.mbeans.ClusterMBeanObserver;
-import org.apache.helix.tools.ClusterSetup;
-import org.apache.helix.tools.ClusterStateVerifier;
-import org.apache.log4j.Logger;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-public class TestWildcardAlert extends ZkIntegrationTestBase {
-  public static class TestClusterMBeanObserver extends ClusterMBeanObserver {
-    public Map<String, Map<String, Object>> _beanValueMap =
-        new ConcurrentHashMap<String, Map<String, Object>>();
-
-    public TestClusterMBeanObserver(String domain) throws InstanceNotFoundException, IOException,
-        MalformedObjectNameException, NullPointerException {
-      super(domain);
-    }
-
-    @Override
-    public void onMBeanRegistered(MBeanServerConnection server,
-        MBeanServerNotification mbsNotification) {
-      try {
-        MBeanInfo info = _server.getMBeanInfo(mbsNotification.getMBeanName());
-        MBeanAttributeInfo[] infos = info.getAttributes();
-        _beanValueMap.put(mbsNotification.getMBeanName().toString(),
-            new ConcurrentHashMap<String, Object>());
-        for (MBeanAttributeInfo infoItem : infos) {
-          Object val = _server.getAttribute(mbsNotification.getMBeanName(), infoItem.getName());
-          System.out.println("         " + infoItem.getName() + " : "
-              + _server.getAttribute(mbsNotification.getMBeanName(), infoItem.getName())
-              + " type : " + infoItem.getType());
-          _beanValueMap.get(mbsNotification.getMBeanName().toString()).put(infoItem.getName(), val);
-        }
-      } catch (Exception e) {
-        _logger.error("Error getting bean info, domain=" + _domain, e);
-      }
-    }
-
-    @Override
-    public void onMBeanUnRegistered(MBeanServerConnection server,
-        MBeanServerNotification mbsNotification) {
-      _beanValueMap.remove(mbsNotification.getMBeanName().toString());
-    }
-
-    public void refresh() throws MalformedObjectNameException, NullPointerException,
-        InstanceNotFoundException, IntrospectionException, ReflectionException, IOException,
-        AttributeNotFoundException, MBeanException {
-      for (String beanName : _beanValueMap.keySet()) {
-        ObjectName objName = new ObjectName(beanName);
-        MBeanInfo info = _server.getMBeanInfo(objName);
-        MBeanAttributeInfo[] infos = info.getAttributes();
-        _beanValueMap.put(objName.toString(), new HashMap<String, Object>());
-        for (MBeanAttributeInfo infoItem : infos) {
-          Object val = _server.getAttribute(objName, infoItem.getName());
-          System.out
-              .println("         " + infoItem.getName() + " : "
-                  + _server.getAttribute(objName, infoItem.getName()) + " type : "
-                  + infoItem.getType());
-          _beanValueMap.get(objName.toString()).put(infoItem.getName(), val);
-        }
-      }
-    }
-
-  }
-
-  private static final Logger _logger = Logger.getLogger(TestWildcardAlert.class);
-  protected ClusterSetup _setupTool = null;
-  protected final String _alertStr =
-      "EXP(decay(1)(localhost_*.RestQueryStats@DBName=TestDB0.latency)|EXPAND|SUMEACH)CMP(GREATER)CON(10)";
-  protected final String _alertStatusStr = _alertStr; // +" : (*)";
-  protected final String _dbName = "TestDB0";
-
-  @BeforeClass()
-  public void beforeClass() throws Exception {
-
-    _setupTool = new ClusterSetup(_gZkClient);
-  }
-
-  @AfterClass
-  public void afterClass() {
-  }
-
-  public class WildcardAlertTransition extends MockTransition {
-    @Override
-    public void doTransition(Message message, NotificationContext context) {
-      HelixManager manager = context.getManager();
-      HelixDataAccessor accessor = manager.getHelixDataAccessor();
-      State fromState = message.getTypedFromState();
-      State toState = message.getTypedToState();
-      String instance = message.getTgtName();
-
-      if (fromState.toString().equalsIgnoreCase("SLAVE")
-          && toState.toString().equalsIgnoreCase("MASTER")) {
-        // add a stat and report to ZK
-        // perhaps should keep reporter per instance...
-        ParticipantHealthReportCollectorImpl reporter =
-            new ParticipantHealthReportCollectorImpl(manager, instance);
-        MockEspressoHealthReportProvider provider = new MockEspressoHealthReportProvider();
-        reporter.addHealthReportProvider(provider);
-        String statName = "latency";
-        // using constant as timestamp so that when each partition does this transition,
-        // they do not advance timestamp, and no stats double-counted
-        String timestamp = "12345";
-        provider.setStat(_dbName, statName, "15", timestamp);
-
-        // sleep for random time and see about errors.
-        /*
-         * Random r = new Random();
-         * int x = r.nextInt(30000);
-         * try {
-         * Thread.sleep(x);
-         * } catch (InterruptedException e) {
-         * // TODO Auto-generated catch block
-         * e.printStackTrace();
-         * }
-         */
-
-        reporter.transmitHealthReports();
-
-        /*
-         * for (int i = 0; i < 5; i++)
-         * {
-         * accessor.setProperty(PropertyType.HEALTHREPORT,
-         * new ZNRecord("mockAlerts" + i),
-         * instance,
-         * "mockAlerts");
-         * try
-         * {
-         * Thread.sleep(1000);
-         * }
-         * catch (InterruptedException e)
-         * {
-         * // TODO Auto-generated catch block
-         * e.printStackTrace();
-         * }
-         * }
-         */
-      }
-    }
-
-  }
-
-  @Test()
-  public void testWildcardAlert() throws Exception {
-    String clusterName = getShortClassName();
-    MockParticipantManager[] participants = new MockParticipantManager[5];
-
-    System.out.println("START TestWildcardAlert at " + new Date(System.currentTimeMillis()));
-
-    TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant start
-                                                         // port
-        "localhost", // participant name prefix
-        "TestDB", // resource name prefix
-        1, // resources
-        10, // partitions per resource
-        5, // number of nodes //change back to 5!!!
-        3, // replicas //change back to 3!!!
-        "MasterSlave", true); // do rebalance
-
-    // enableHealthCheck(clusterName);
-
-    _setupTool.getClusterManagementTool().addAlert(clusterName, _alertStr);
-    // _setupTool.getClusterManagementTool().addAlert(clusterName, _alertStr2);
-
-    ClusterControllerManager controller =
-        new ClusterControllerManager(ZK_ADDR, clusterName, "controller_0");
-    controller.syncStart();
-    // start participants
-    for (int i = 0; i < 5; i++) // !!!change back to 5
-    {
-      String instanceName = "localhost_" + (12918 + i);
-
-      participants[i] =
-          new MockParticipantManager(ZK_ADDR, clusterName, instanceName);
-      participants[i].setTransition(new WildcardAlertTransition());
-      participants[i].syncStart();
-    }
-
-    TestClusterMBeanObserver jmxMBeanObserver =
-        new TestClusterMBeanObserver(ClusterAlertMBeanCollection.DOMAIN_ALERT);
-
-    boolean result =
-        ClusterStateVerifier.verifyByPolling(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(
-            ZK_ADDR, clusterName));
-    Assert.assertTrue(result);
-    Thread.sleep(3000);
-    // HealthAggregationTask is supposed to run by a timer every 30s
-    // To make sure HealthAggregationTask is run, we invoke it explicitly for this test
-    new HealthStatsAggregator(controller).aggregate();
-
-    // sleep for a few seconds to give stats stage time to trigger and for bean to trigger
-    Thread.sleep(3000);
-
-    ZKHelixDataAccessor accessor =
-        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
-    Builder keyBuilder = accessor.keyBuilder();
-
-    // for (int i = 0; i < 1; i++) //change 1 back to 5
-    // {
-    // String instance = "localhost_" + (12918 + i);
-    // String instance = "localhost_12918";
-    ZNRecord record = accessor.getProperty(keyBuilder.alertStatus()).getRecord();
-    Map<String, Map<String, String>> recMap = record.getMapFields();
-    Set<String> keySet = recMap.keySet();
-    Map<String, String> alertStatusMap = recMap.get(_alertStatusStr);
-    String val = alertStatusMap.get(AlertValueAndStatus.VALUE_NAME);
-    boolean fired = Boolean.parseBoolean(alertStatusMap.get(AlertValueAndStatus.FIRED_NAME));
-    Assert.assertEquals(Double.parseDouble(val), Double.parseDouble("75.0"));
-    Assert.assertTrue(fired);
-
-    // Make sure that the jmxObserver has received all the jmx bean value that is corresponding
-    // to the alerts.
-    jmxMBeanObserver.refresh();
-    Assert.assertTrue(jmxMBeanObserver._beanValueMap.size() >= 1);
-
-    String beanName =
-        "HelixAlerts:alert=EXP(decay(1)(localhost_%.RestQueryStats@DBName#TestDB0.latency)|EXPAND|SUMEACH)CMP(GREATER)CON(10)--(%)";
-    Assert.assertTrue(jmxMBeanObserver._beanValueMap.containsKey(beanName));
-
-    Map<String, Object> beanValueMap = jmxMBeanObserver._beanValueMap.get(beanName);
-    Assert.assertEquals(beanValueMap.size(), 4);
-    Assert.assertEquals((beanValueMap.get("AlertFired")), new Integer(1));
-    Assert.assertEquals((beanValueMap.get("AlertValue")), new Double(75.0));
-    Assert
-        .assertEquals(
-            (String) (beanValueMap.get("SensorName")),
-            "EXP(decay(1)(localhost_%.RestQueryStats@DBName#TestDB0.latency)|EXPAND|SUMEACH)CMP(GREATER)CON(10)--(%)");
-    // }
-
-    // clean up
-    controller.syncStop();
-    for (int i = 0; i < 5; i++) {
-      participants[i].syncStop();
-    }
-
-    System.out.println("END TestWildcardAlert at " + new Date(System.currentTimeMillis()));
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/db4c10a2/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkClusterManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkClusterManager.java b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkClusterManager.java
index 83dc986..b3f87ad 100644
--- a/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkClusterManager.java
+++ b/helix-core/src/test/java/org/apache/helix/manager/zk/TestZkClusterManager.java
@@ -106,7 +106,6 @@ public class TestZkClusterManager extends ZkUnitTestBase {
     AssertJUnit.assertEquals("node_1", record.getId());
 
     controller.getMessagingService();
-    controller.getHealthReportCollector();
     controller.getClusterManagmentTool();
 
     controller.handleNewSession();

http://git-wip-us.apache.org/repos/asf/helix/blob/db4c10a2/helix-core/src/test/java/org/apache/helix/mock/participant/MockEspressoHealthReportProvider.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/MockEspressoHealthReportProvider.java b/helix-core/src/test/java/org/apache/helix/mock/participant/MockEspressoHealthReportProvider.java
deleted file mode 100644
index 84ba081..0000000
--- a/helix-core/src/test/java/org/apache/helix/mock/participant/MockEspressoHealthReportProvider.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.apache.helix.mock.participant;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.helix.alerts.StatsHolder;
-import org.apache.helix.healthcheck.HealthReportProvider;
-
-public class MockEspressoHealthReportProvider extends HealthReportProvider {
-
-  private final String _reportName = "RestQueryStats";
-  private HashMap<String, Map<String, String>> _statMap;
-  private final String DB_NAME = "DBName";
-
-  public MockEspressoHealthReportProvider() {
-    super();
-    _statMap = new HashMap<String, Map<String, String>>();
-  }
-
-  public String buildMapKey(String dbName) {
-    return _reportName + "@" + DB_NAME + "=" + dbName;
-  }
-
-  public void setStat(String dbName, String statName, String statVal) {
-    String currTime = String.valueOf(System.currentTimeMillis());
-    setStat(dbName, statName, statVal, currTime);
-  }
-
-  /*
-   * This version takes a fixed timestamp to ease with testing
-   */
-  public void setStat(String dbName, String statName, String statVal, String timestamp) {
-    String key = buildMapKey(dbName);
-    Map<String, String> dbStatMap = _statMap.get(key);
-    if (dbStatMap == null) {
-      dbStatMap = new HashMap<String, String>();
-      _statMap.put(key, dbStatMap);
-    }
-    dbStatMap.put(statName, statVal);
-    dbStatMap.put(StatsHolder.TIMESTAMP_NAME, timestamp);
-  }
-
-  @Override
-  public Map<String, String> getRecentHealthReport() {
-    return null;
-  }
-
-  @Override
-  public Map<String, Map<String, String>> getRecentPartitionHealthReport() {
-    return _statMap;
-  }
-
-  @Override
-  public void resetStats() {
-    _statMap.clear();
-  }
-
-  public String getReportName() {
-    return _reportName;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/db4c10a2/helix-core/src/test/java/org/apache/helix/mock/participant/MockHealthReportParticipant.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/MockHealthReportParticipant.java b/helix-core/src/test/java/org/apache/helix/mock/participant/MockHealthReportParticipant.java
deleted file mode 100644
index 31811bb..0000000
--- a/helix-core/src/test/java/org/apache/helix/mock/participant/MockHealthReportParticipant.java
+++ /dev/null
@@ -1,248 +0,0 @@
-package org.apache.helix.mock.participant;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.ParseException;
-import org.apache.helix.HelixManager;
-import org.apache.helix.healthcheck.HealthReportProvider;
-import org.apache.helix.integration.manager.MockParticipantManager;
-import org.apache.log4j.Logger;
-
-public class MockHealthReportParticipant {
-  private static final Logger LOG = Logger.getLogger(MockHealthReportParticipant.class);
-  public static final String zkServer = "zkSvr";
-  public static final String cluster = "cluster";
-  public static final String host = "host";
-  public static final String port = "port";
-  public static final String help = "help";
-
-  static class MockHealthReportProvider extends HealthReportProvider {
-    private final String _reportName = "MockRestQueryStats";
-    private final Map<String, Map<String, String>> _mockHealthReport;
-
-    public MockHealthReportProvider() {
-      _mockHealthReport = new HashMap<String, Map<String, String>>();
-
-      Map<String, String> reportMap = new HashMap<String, String>();
-      _mockHealthReport.put("MockRestQueryStats@DBName=BizProfile", reportMap);
-
-      reportMap.put("MeanMysqlLatency", "2.132700625");
-      reportMap.put("95PercentileLatencyLucene", "108.40825525");
-      reportMap.put("99PercentileLatencyMysql", "9.369827");
-      reportMap.put("99PercentileLatencyServer", "167.714208");
-      reportMap.put("95PercentileLatencyMysqlPool", "8.03621375");
-      reportMap.put("95PercentileLatencyServer", "164.68374265");
-      reportMap.put("MinLuceneLatency", "1.765908");
-      reportMap.put("MaxServerLatency", "167.714208");
-      reportMap.put("MeanLuceneLatency", "16.107599458333336");
-      reportMap.put("CollectorName", "RestQueryStats");
-      reportMap.put("MeanLucenePoolLatency", "8.120545333333332");
-      reportMap.put("99PercentileLatencyLucenePool", "65.930564");
-      reportMap.put("MinServerLatency", "0.425272");
-      reportMap.put("IndexStoreMismatchCount", "0");
-      reportMap.put("ErrorCount", "0");
-      reportMap.put("MeanMysqlPoolLatency", "1.0704102916666667");
-      reportMap.put("MinLucenePoolLatency", "0.008189");
-      reportMap.put("MinMysqlLatency", "0.709691");
-      reportMap.put("MaxMysqlPoolLatency", "8.606973");
-      reportMap.put("99PercentileLatencyMysqlPool", "8.606973");
-      reportMap.put("MinMysqlPoolLatency", "0.091883");
-      reportMap.put("MaxLucenePoolLatency", "65.930564");
-      reportMap.put("99PercentileLatencyLucene", "111.78799");
-      reportMap.put("MaxMysqlLatency", "9.369827");
-      reportMap.put("TimeStamp", "1332895048143");
-      reportMap.put("MeanConcurrencyLevel", "1.9");
-      reportMap.put("95PercentileLatencyMysql", "8.96594875");
-      reportMap.put("QueryStartCount", "0");
-      reportMap.put("95PercentileLatencyLucenePool", "63.518656500000006");
-      reportMap.put("MeanServerLatency", "39.5451532");
-      reportMap.put("MaxLuceneLatency", "111.78799");
-      reportMap.put("QuerySuccessCount", "0");
-    }
-
-    @Override
-    public Map<String, String> getRecentHealthReport() {
-      // TODO Auto-generated method stub
-      return null;
-    }
-
-    @Override
-    public void resetStats() {
-      // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public Map<String, Map<String, String>> getRecentPartitionHealthReport() {
-      // tweak: randomly change the last digit
-      for (String key1 : _mockHealthReport.keySet()) {
-        Map<String, String> reportMap = _mockHealthReport.get(key1);
-        for (String key2 : reportMap.keySet()) {
-          String value = reportMap.get(key2);
-          String lastDigit = "" + new Random().nextInt(10);
-          value = value.substring(0, value.length() - 1) + lastDigit;
-          reportMap.put(key2, value);
-        }
-      }
-
-      return _mockHealthReport;
-    }
-
-    @Override
-    public String getReportName() {
-      return _reportName;
-    }
-  }
-
-  static class MockHealthReportJob implements MockJobIntf {
-
-    @Override
-    public void doPreConnectJob(HelixManager manager) {
-      // TODO Auto-generated method stub
-
-    }
-
-    @Override
-    public void doPostConnectJob(HelixManager manager) {
-      // TODO Auto-generated method stub
-      manager.getHealthReportCollector().addHealthReportProvider(new MockHealthReportProvider());
-
-      // // set property store path for perf test
-      // final String setPath = "/TEST_PERF/set";
-      // final String updatePath = "/TEST_PERF/update";
-      // manager.getHelixPropertyStore().create(setPath, new ZNRecord(setPath),
-      // BaseDataAccessor.Option.PERSISTENT);
-      // manager.getHelixPropertyStore().set(updatePath, new ZNRecord(updatePath),
-      // BaseDataAccessor.Option.PERSISTENT);
-    }
-
-  }
-
-  // hack OptionBuilder is not thread safe
-  @SuppressWarnings("static-access")
-  synchronized private static Options constructCommandLineOptions() {
-    Option helpOption =
-        OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info")
-            .create();
-
-    Option clusterOption =
-        OptionBuilder.withLongOpt(cluster).withDescription("Provide cluster name").create();
-    clusterOption.setArgs(1);
-    clusterOption.setRequired(true);
-    clusterOption.setArgName("Cluster name (Required)");
-
-    Option hostOption =
-        OptionBuilder.withLongOpt(host).withDescription("Provide host name").create();
-    hostOption.setArgs(1);
-    hostOption.setRequired(true);
-    hostOption.setArgName("Host name (Required)");
-
-    Option portOption =
-        OptionBuilder.withLongOpt(port).withDescription("Provide host port").create();
-    portOption.setArgs(1);
-    portOption.setRequired(true);
-    portOption.setArgName("Host port (Required)");
-
-    Option zkServerOption =
-        OptionBuilder.withLongOpt(zkServer).withDescription("Provide zookeeper address").create();
-    zkServerOption.setArgs(1);
-    zkServerOption.setRequired(true);
-    zkServerOption.setArgName("Zookeeper server address(Required)");
-
-    Options options = new Options();
-    options.addOption(helpOption);
-    options.addOption(clusterOption);
-    options.addOption(hostOption);
-    options.addOption(portOption);
-    options.addOption(zkServerOption);
-
-    return options;
-  }
-
-  public static void printUsage(Options cliOptions) {
-    HelpFormatter helpFormatter = new HelpFormatter();
-    helpFormatter.printHelp("java " + MockHealthReportParticipant.class.getName(), cliOptions);
-  }
-
-  public static CommandLine processCommandLineArgs(String[] cliArgs) throws Exception {
-    CommandLineParser cliParser = new GnuParser();
-    Options cliOptions = constructCommandLineOptions();
-
-    try {
-
-      return cliParser.parse(cliOptions, cliArgs);
-    } catch (ParseException pe) {
-      System.err.println("CommandLineClient: failed to parse command-line options: "
-          + pe.toString());
-      printUsage(cliOptions);
-      System.exit(1);
-    }
-    return null;
-  }
-
-  // NOT working for kill -9, working for kill -2/-15
-  static class MockHealthReportParticipantShutdownHook extends Thread {
-    final MockParticipantManager _participant;
-
-    MockHealthReportParticipantShutdownHook(MockParticipantManager participant) {
-      _participant = participant;
-    }
-
-    @Override
-    public void run() {
-      LOG.info("MockHealthReportParticipantShutdownHook invoked");
-      _participant.syncStop();
-    }
-  }
-
-  public static void main(String[] args) throws Exception {
-    CommandLine cmd = processCommandLineArgs(args);
-    String zkConnectStr = cmd.getOptionValue(zkServer);
-    String clusterName = cmd.getOptionValue(cluster);
-    String hostStr = cmd.getOptionValue(host);
-    String portStr = cmd.getOptionValue(port);
-
-    String instanceName = hostStr + "_" + portStr;
-
-    MockParticipantManager participant =
-        new MockParticipantManager(zkConnectStr, clusterName, instanceName);
-    // participant.setTransition(new StoreAccessDiffNodeTransition());
-    // participant.setTransition(new StoreAccessOneNodeTransition()));
-    // new MockHealthReportJob());
-    Runtime.getRuntime().addShutdownHook(new MockHealthReportParticipantShutdownHook(participant));
-
-    // Espresso_driver.py will consume this
-    System.out
-        .println("MockHealthReportParticipant process started, instanceName: " + instanceName);
-
-    participant.run();
-  }
-}


Mime
View raw message