helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject [3/6] [HELIX-395] Remove old Helix alert/stat modules
Date Tue, 20 May 2014 22:49:00 GMT
http://git-wip-us.apache.org/repos/asf/helix/blob/77cc6516/helix-core/src/test/java/org/apache/helix/Mocks.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/Mocks.java b/helix-core/src/test/java/org/apache/helix/Mocks.java
index 9e2452b..e6582e0 100644
--- a/helix-core/src/test/java/org/apache/helix/Mocks.java
+++ b/helix-core/src/test/java/org/apache/helix/Mocks.java
@@ -31,8 +31,6 @@ import org.I0Itec.zkclient.DataUpdater;
 import org.I0Itec.zkclient.IZkChildListener;
 import org.I0Itec.zkclient.IZkDataListener;
 import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.healthcheck.HealthReportProvider;
-import org.apache.helix.healthcheck.ParticipantHealthReportCollector;
 import org.apache.helix.messaging.AsyncCallback;
 import org.apache.helix.messaging.handling.HelixTaskExecutor;
 import org.apache.helix.messaging.handling.HelixTaskResult;
@@ -46,7 +44,6 @@ import org.apache.helix.participant.statemachine.StateModelInfo;
 import org.apache.helix.participant.statemachine.Transition;
 import org.apache.helix.store.zk.ZkHelixPropertyStore;
 import org.apache.zookeeper.data.Stat;
-import org.omg.CORBA._PolicyStub;
 
 public class Mocks {
   public static class MockBaseDataAccessor implements BaseDataAccessor<ZNRecord> {
@@ -190,18 +187,6 @@ public class Mocks {
       return false;
     }
 
-    // @Override
-    // public boolean subscribe(String path, IZkListener listener) {
-    // // TODO Auto-generated method stub
-    // return false;
-    // }
-    //
-    // @Override
-    // public boolean unsubscribe(String path, IZkListener listener) {
-    // // TODO Auto-generated method stub
-    // return false;
-    // }
-
   }
 
   public static class MockStateModel extends StateModel {
@@ -372,12 +357,6 @@ public class Mocks {
     }
 
     @Override
-    public ParticipantHealthReportCollector getHealthReportCollector() {
-      // TODO Auto-generated method stub
-      return null;
-    }
-
-    @Override
     public InstanceType getInstanceType() {
       return InstanceType.PARTICIPANT;
     }
@@ -394,13 +373,6 @@ public class Mocks {
     }
 
     @Override
-    public void addHealthStateChangeListener(HealthStateChangeListener listener, String instanceName)
-        throws Exception {
-      // TODO Auto-generated method stub
-
-    }
-
-    @Override
     public StateMachineEngine getStateMachineEngine() {
       // TODO Auto-generated method stub
       return null;
@@ -427,7 +399,6 @@ public class Mocks {
     @Override
     public void stopTimerTasks() {
       // TODO Auto-generated method stub
-
     }
 
     @Override
@@ -438,7 +409,6 @@ public class Mocks {
     @Override
     public void addPreConnectCallback(PreConnectCallback callback) {
       // TODO Auto-generated method stub
-
     }
 
     @Override
@@ -451,20 +421,17 @@ public class Mocks {
     public void addInstanceConfigChangeListener(InstanceConfigChangeListener listener)
         throws Exception {
       // TODO Auto-generated method stub
-
     }
 
     @Override
     public void addConfigChangeListener(ScopedConfigChangeListener listener,
         ConfigScopeProperty scope) throws Exception {
       // TODO Auto-generated method stub
-
     }
 
     @Override
     public void setLiveInstanceInfoProvider(LiveInstanceInfoProvider liveInstanceInfoProvider) {
       // TODO Auto-generated method stub
-
     }
 
     @Override
@@ -476,13 +443,11 @@ public class Mocks {
     @Override
     public void addControllerMessageListener(MessageListener listener) {
       // TODO Auto-generated method stub
-
     }
 
   }
 
-  public static class MockAccessor implements HelixDataAccessor // DataAccessor
-  {
+  public static class MockAccessor implements HelixDataAccessor {
     private final String _clusterName;
     Map<String, ZNRecord> data = new HashMap<String, ZNRecord>();
     private final Builder _propertyKeyBuilder;
@@ -499,35 +464,14 @@ public class Mocks {
     Map<String, ZNRecord> map = new HashMap<String, ZNRecord>();
 
     @Override
-    // public boolean setProperty(PropertyType type, HelixProperty value,
-    // String... keys)
     public boolean setProperty(PropertyKey key, HelixProperty value) {
-      // return setProperty(type, value.getRecord(), keys);
       String path = key.getPath();
       data.put(path, value.getRecord());
       return true;
     }
 
-    // @Override
-    // public boolean setProperty(PropertyType type, ZNRecord value,
-    // String... keys)
-    // {
-    // String path = PropertyPathConfig.getPath(type, _clusterName, keys);
-    // data.put(path, value);
-    // return true;
-    // }
-
-    // @Override
-    // public boolean updateProperty(PropertyType type, HelixProperty value,
-    // String... keys)
-    // {
-    // return updateProperty(type, value.getRecord(), keys);
-    // }
-
     @Override
     public <T extends HelixProperty> boolean updateProperty(PropertyKey key, T value) {
-      // String path = PropertyPathConfig.getPath(type, _clusterName,
-      // keys);
       String path = key.getPath();
       PropertyType type = key.getType();
       if (type.updateOnlyOnExists) {
@@ -557,34 +501,15 @@ public class Mocks {
       return true;
     }
 
-    // @Override
-    // public <T extends HelixProperty> T getProperty(Class<T> clazz,
-    // PropertyType type,
-    // String... keys)
-    // {
-    // ZNRecord record = getProperty(type, keys);
-    // if (record == null)
-    // {
-    // return null;
-    // }
-    // return HelixProperty.convertToTypedInstance(clazz, record);
-    // }
-
     @SuppressWarnings("unchecked")
     @Override
-    public <T extends HelixProperty> T getProperty(PropertyKey key)
-    // public ZNRecord getProperty(PropertyType type, String... keys)
-    {
-      // String path = PropertyPathConfig.getPath(type, _clusterName,
-      // keys);
+    public <T extends HelixProperty> T getProperty(PropertyKey key) {
       String path = key.getPath();
       return (T) HelixProperty.convertToTypedInstance(key.getTypeClass(), data.get(path));
     }
 
     @Override
-    public boolean removeProperty(PropertyKey key)
-    // public boolean removeProperty(PropertyType type, String... keys)
-    {
+    public boolean removeProperty(PropertyKey key) {
       String path = key.getPath(); // PropertyPathConfig.getPath(type,
       // _clusterName, keys);
       data.remove(path);
@@ -592,12 +517,9 @@ public class Mocks {
     }
 
     @Override
-    public List<String> getChildNames(PropertyKey propertyKey)
-    // public List<String> getChildNames(PropertyType type, String... keys)
-    {
+    public List<String> getChildNames(PropertyKey propertyKey) {
       List<String> child = new ArrayList<String>();
-      String path = propertyKey.getPath(); // PropertyPathConfig.getPath(type,
-      // _clusterName, keys);
+      String path = propertyKey.getPath();
       for (String key : data.keySet()) {
         if (key.startsWith(path)) {
           String[] keySplit = key.split("\\/");
@@ -610,21 +532,9 @@ public class Mocks {
       return child;
     }
 
-    // @Override
-    // public <T extends HelixProperty> List<T> getChildValues(Class<T>
-    // clazz, PropertyType type,
-    // String... keys)
-    // {
-    // List<ZNRecord> list = getChildValues(type, keys);
-    // return HelixProperty.convertToTypedList(clazz, list);
-    // }
-
     @SuppressWarnings("unchecked")
     @Override
-    public <T extends HelixProperty> List<T> getChildValues(PropertyKey propertyKey)
-    // public List<ZNRecord> getChildValues(PropertyType type, String...
-    // keys)
-    {
+    public <T extends HelixProperty> List<T> getChildValues(PropertyKey propertyKey) {
       List<ZNRecord> childs = new ArrayList<ZNRecord>();
       String path = propertyKey.getPath(); // PropertyPathConfig.getPath(type,
       // _clusterName, keys);
@@ -647,11 +557,7 @@ public class Mocks {
     }
 
     @Override
-    public <T extends HelixProperty> Map<String, T> getChildValuesMap(PropertyKey key)
-    // public <T extends HelixProperty> Map<String, T>
-    // getChildValuesMap(Class<T> clazz,
-    // PropertyType type, String... keys)
-    {
+    public <T extends HelixProperty> Map<String, T> getChildValuesMap(PropertyKey key) {
       List<T> list = getChildValues(key);
       return HelixProperty.convertListToMap(list);
     }
@@ -705,22 +611,6 @@ public class Mocks {
     }
   }
 
-  public static class MockHealthReportProvider extends HealthReportProvider {
-
-    @Override
-    public Map<String, String> getRecentHealthReport() {
-      // TODO Auto-generated method stub
-      return null;
-    }
-
-    @Override
-    public void resetStats() {
-      // TODO Auto-generated method stub
-
-    }
-
-  }
-
   public static class MockClusterMessagingService implements ClusterMessagingService {
 
     @Override

http://git-wip-us.apache.org/repos/asf/helix/blob/77cc6516/helix-core/src/test/java/org/apache/helix/TestParticipantHealthReportCollectorImpl.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/TestParticipantHealthReportCollectorImpl.java b/helix-core/src/test/java/org/apache/helix/TestParticipantHealthReportCollectorImpl.java
deleted file mode 100644
index fe4c688..0000000
--- a/helix-core/src/test/java/org/apache/helix/TestParticipantHealthReportCollectorImpl.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.apache.helix;
-
-/*
- * 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 org.apache.helix.Mocks.MockHealthReportProvider;
-import org.apache.helix.Mocks.MockManager;
-import org.apache.helix.healthcheck.ParticipantHealthReportCollectorImpl;
-import org.apache.helix.healthcheck.ParticipantHealthReportTask;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-public class TestParticipantHealthReportCollectorImpl {
-
-  protected ParticipantHealthReportCollectorImpl _providerImpl;
-  protected ParticipantHealthReportTask _providerTask;
-  protected HelixManager _manager;
-  protected MockHealthReportProvider _mockProvider;
-
-  @BeforeMethod(groups = {
-    "unitTest"
-  })
-  public void setup() {
-    _providerImpl = new ParticipantHealthReportCollectorImpl(new MockManager(), "instance_123");
-    _providerTask = new ParticipantHealthReportTask(_providerImpl);
-    _mockProvider = new MockHealthReportProvider();
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testStart() throws Exception {
-    _providerTask.start();
-    _providerTask.start();
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testStop() throws Exception {
-    _providerTask.stop();
-    _providerTask.stop();
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddProvider() throws Exception {
-    _providerImpl.removeHealthReportProvider(_mockProvider);
-    _providerImpl.addHealthReportProvider(_mockProvider);
-    _providerImpl.addHealthReportProvider(_mockProvider);
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testRemoveProvider() throws Exception {
-    _providerImpl.addHealthReportProvider(_mockProvider);
-    _providerImpl.removeHealthReportProvider(_mockProvider);
-    _providerImpl.removeHealthReportProvider(_mockProvider);
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/77cc6516/helix-core/src/test/java/org/apache/helix/TestPerfCounters.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/TestPerfCounters.java b/helix-core/src/test/java/org/apache/helix/TestPerfCounters.java
deleted file mode 100644
index d95bff8..0000000
--- a/helix-core/src/test/java/org/apache/helix/TestPerfCounters.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.apache.helix;
-
-/*
- * 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 org.apache.helix.healthcheck.DefaultPerfCounters;
-import org.testng.AssertJUnit;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-public class TestPerfCounters {
-
-  final String INSTANCE_NAME = "instance_123";
-  final long AVAILABLE_CPUS = 1;
-  final long FREE_PHYSICAL_MEMORY = 2;
-  final long FREE_JVM_MEMORY = 3;
-  final long TOTAL_JVM_MEMORY = 4;
-  final double AVERAGE_SYSTEM_LOAD = 5;
-
-  DefaultPerfCounters _perfCounters;
-
-  @BeforeTest()
-  public void setup() {
-    _perfCounters =
-        new DefaultPerfCounters(INSTANCE_NAME, AVAILABLE_CPUS, FREE_PHYSICAL_MEMORY,
-            FREE_JVM_MEMORY, TOTAL_JVM_MEMORY, AVERAGE_SYSTEM_LOAD);
-  }
-
-  @Test()
-  public void testGetAvailableCpus() {
-    AssertJUnit.assertEquals(AVAILABLE_CPUS, _perfCounters.getAvailableCpus());
-  }
-
-  @Test()
-  public void testGetAverageSystemLoad() {
-    AssertJUnit.assertEquals(AVERAGE_SYSTEM_LOAD, _perfCounters.getAverageSystemLoad());
-  }
-
-  @Test()
-  public void testGetTotalJvmMemory() {
-    AssertJUnit.assertEquals(TOTAL_JVM_MEMORY, _perfCounters.getTotalJvmMemory());
-  }
-
-  @Test()
-  public void testGetFreeJvmMemory() {
-    AssertJUnit.assertEquals(FREE_JVM_MEMORY, _perfCounters.getFreeJvmMemory());
-  }
-
-  @Test()
-  public void testGetFreePhysicalMemory() {
-    AssertJUnit.assertEquals(FREE_PHYSICAL_MEMORY, _perfCounters.getFreePhysicalMemory());
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/77cc6516/helix-core/src/test/java/org/apache/helix/TestPerformanceHealthReportProvider.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/TestPerformanceHealthReportProvider.java b/helix-core/src/test/java/org/apache/helix/TestPerformanceHealthReportProvider.java
deleted file mode 100644
index 60e1bcb..0000000
--- a/helix-core/src/test/java/org/apache/helix/TestPerformanceHealthReportProvider.java
+++ /dev/null
@@ -1,160 +0,0 @@
-package org.apache.helix;
-
-/*
- * 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.Map;
-
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.Mocks.MockManager;
-import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.healthcheck.PerformanceHealthReportProvider;
-import org.apache.helix.model.HealthStat;
-import org.testng.AssertJUnit;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-public class TestPerformanceHealthReportProvider {
-
-  protected static final String CLUSTER_NAME = "TestCluster";
-  protected final String STAT_NAME = "Stat_123";
-  protected final String PARTITION_NAME = "Partition_456";
-  protected final String FAKE_STAT_NAME = "Stat_ABC";
-  protected final String FAKE_PARTITION_NAME = "Partition_DEF";
-  protected final String STORED_STAT = "789";
-  protected final String INSTANCE_NAME = "instance:1";
-
-  PerformanceHealthReportProvider _healthProvider;
-  MockManager _helixManager;
-
-  public void incrementPartitionStat() throws Exception {
-    _helixManager = new MockManager(CLUSTER_NAME);
-    _healthProvider.incrementPartitionStat(STAT_NAME, PARTITION_NAME);
-  }
-
-  public void transmitReport() throws Exception {
-    _helixManager = new MockManager(CLUSTER_NAME);
-    Map<String, Map<String, String>> partitionReport =
-        _healthProvider.getRecentPartitionHealthReport();
-    ZNRecord record = new ZNRecord(_healthProvider.getReportName());
-    if (partitionReport != null) {
-      record.setMapFields(partitionReport);
-    }
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-
-    Builder keyBuilder = accessor.keyBuilder();
-    accessor.setProperty(keyBuilder.healthReport(INSTANCE_NAME, record.getId()), new HealthStat(
-        record));
-  }
-
-  @BeforeMethod()
-  public void setup() {
-    _healthProvider = new PerformanceHealthReportProvider();
-  }
-
-  @Test()
-  public void testGetRecentHealthReports() throws Exception {
-    _healthProvider.getRecentHealthReport();
-    _healthProvider.getRecentPartitionHealthReport();
-  }
-
-  @Test()
-  public void testIncrementPartitionStat() throws Exception {
-    // stat does not exist yet
-    _healthProvider.incrementPartitionStat(STAT_NAME, PARTITION_NAME);
-    transmitReport();
-    // stat does exist
-    _healthProvider.incrementPartitionStat(STAT_NAME, PARTITION_NAME);
-    transmitReport();
-    String retrievedStat = _healthProvider.getPartitionStat(STAT_NAME, PARTITION_NAME);
-    AssertJUnit.assertEquals(2.0, Double.parseDouble(retrievedStat));
-
-    // set to some other value
-    _healthProvider.submitPartitionStat(STAT_NAME, PARTITION_NAME, STORED_STAT);
-    transmitReport();
-    _healthProvider.incrementPartitionStat(STAT_NAME, PARTITION_NAME);
-    transmitReport();
-    retrievedStat = _healthProvider.getPartitionStat(STAT_NAME, PARTITION_NAME);
-    AssertJUnit
-        .assertEquals(Double.parseDouble(retrievedStat), Double.parseDouble(STORED_STAT) + 1);
-  }
-
-  @Test()
-  public void testSetGetPartitionStat() throws Exception {
-    _healthProvider.submitPartitionStat(STAT_NAME, PARTITION_NAME, STORED_STAT);
-    transmitReport();
-    String retrievedStat = _healthProvider.getPartitionStat(STAT_NAME, PARTITION_NAME);
-    // check on correct retrieval for real stat, real partition
-    AssertJUnit.assertEquals(STORED_STAT, retrievedStat);
-
-    // real stat, fake partition
-    retrievedStat = _healthProvider.getPartitionStat(STAT_NAME, FAKE_PARTITION_NAME);
-    AssertJUnit.assertNull(retrievedStat);
-
-    // fake stat, real partition
-    retrievedStat = _healthProvider.getPartitionStat(FAKE_STAT_NAME, PARTITION_NAME);
-    AssertJUnit.assertNull(retrievedStat);
-
-    // fake stat, fake partition
-    retrievedStat = _healthProvider.getPartitionStat(FAKE_STAT_NAME, FAKE_PARTITION_NAME);
-    AssertJUnit.assertNull(retrievedStat);
-  }
-
-  @Test()
-  public void testGetPartitionHealthReport() throws Exception {
-    // test empty map case
-    Map<String, Map<String, String>> resultMap = _healthProvider.getRecentPartitionHealthReport();
-    AssertJUnit.assertEquals(resultMap.size(), 0);
-
-    // test non-empty case
-    testSetGetPartitionStat();
-    resultMap = _healthProvider.getRecentPartitionHealthReport();
-    // check contains 1 stat
-    AssertJUnit.assertEquals(1, resultMap.size());
-    // check contains STAT_NAME STAT
-    AssertJUnit.assertTrue(resultMap.keySet().contains(STAT_NAME));
-    Map<String, String> statMap = resultMap.get(STAT_NAME);
-    // check statMap has size 1
-    AssertJUnit.assertEquals(1, statMap.size());
-    // check contains PARTITION_NAME
-    AssertJUnit.assertTrue(statMap.keySet().contains(PARTITION_NAME));
-    // check stored val
-    String statVal = statMap.get(PARTITION_NAME);
-    AssertJUnit.assertEquals(statVal, STORED_STAT);
-  }
-
-  @Test()
-  public void testPartitionStatReset() throws Exception {
-    incrementPartitionStat();
-    // ensure stat appears
-    String retrievedStat = _healthProvider.getPartitionStat(STAT_NAME, PARTITION_NAME);
-    AssertJUnit.assertEquals(1.0, Double.parseDouble(retrievedStat));
-    // reset partition stats
-    _healthProvider.resetStats();
-    transmitReport();
-    retrievedStat = _healthProvider.getPartitionStat(STAT_NAME, PARTITION_NAME);
-    AssertJUnit.assertEquals(null, retrievedStat);
-  }
-
-  @Test()
-  public void testGetReportName() throws Exception {
-    _healthProvider.getReportName();
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/77cc6516/helix-core/src/test/java/org/apache/helix/alerts/TestAddAlerts.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/alerts/TestAddAlerts.java b/helix-core/src/test/java/org/apache/helix/alerts/TestAddAlerts.java
deleted file mode 100644
index 4263ddc..0000000
--- a/helix-core/src/test/java/org/apache/helix/alerts/TestAddAlerts.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package org.apache.helix.alerts;
-
-/*
- * 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.Map;
-
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.Mocks.MockManager;
-import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.alerts.AlertParser;
-import org.apache.helix.alerts.AlertsHolder;
-import org.apache.helix.controller.stages.HealthDataCache;
-import org.testng.AssertJUnit;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-public class TestAddAlerts {
-
-  protected static final String CLUSTER_NAME = "TestCluster";
-
-  MockManager _helixManager;
-  AlertsHolder _alertsHolder;
-
-  public final String EXP = AlertParser.EXPRESSION_NAME;
-  public final String CMP = AlertParser.COMPARATOR_NAME;
-  public final String CON = AlertParser.CONSTANT_NAME;
-
-  @BeforeMethod()
-  public void setup() {
-    _helixManager = new MockManager(CLUSTER_NAME);
-    _alertsHolder = new AlertsHolder(_helixManager, new HealthDataCache());
-  }
-
-  public boolean alertRecordContains(ZNRecord rec, String alertName) {
-    Map<String, Map<String, String>> alerts = rec.getMapFields();
-    return alerts.containsKey(alertName);
-  }
-
-  public int alertsSize(ZNRecord rec) {
-    Map<String, Map<String, String>> alerts = rec.getMapFields();
-    return alerts.size();
-  }
-
-  @Test()
-  public void testAddAlert() throws Exception {
-    String alert =
-        EXP + "(accumulate()(dbFoo.partition10.latency))" + CMP + "(GREATER)" + CON + "(10)";
-    _alertsHolder.addAlert(alert);
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.alerts()).getRecord();
-    System.out.println("alert: " + alert);
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(alertRecordContains(rec, alert));
-    AssertJUnit.assertEquals(1, alertsSize(rec));
-  }
-
-  @Test()
-  public void testAddTwoAlerts() throws Exception {
-    String alert1 =
-        EXP + "(accumulate()(dbFoo.partition10.latency))" + CMP + "(GREATER)" + CON + "(10)";
-    String alert2 =
-        EXP + "(accumulate()(dbFoo.partition10.latency))" + CMP + "(GREATER)" + CON + "(100)";
-    _alertsHolder.addAlert(alert1);
-    _alertsHolder.addAlert(alert2);
-
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.alerts()).getRecord();
-    // System.out.println("alert: "+alert1);
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(alertRecordContains(rec, alert1));
-    AssertJUnit.assertTrue(alertRecordContains(rec, alert2));
-    AssertJUnit.assertEquals(2, alertsSize(rec));
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddTwoWildcardAlert() throws Exception {
-    String alert1 =
-        EXP + "(accumulate()(dbFoo.partition*.put*))" + CMP + "(GREATER)" + CON + "(10)";
-    _alertsHolder.addAlert(alert1);
-
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.alerts()).getRecord();
-    // System.out.println("alert: "+alert1);
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(alertRecordContains(rec, alert1));
-    AssertJUnit.assertEquals(1, alertsSize(rec));
-  }
-
-  // add 2 wildcard alert here
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/77cc6516/helix-core/src/test/java/org/apache/helix/alerts/TestAddPersistentStats.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/alerts/TestAddPersistentStats.java b/helix-core/src/test/java/org/apache/helix/alerts/TestAddPersistentStats.java
deleted file mode 100644
index e9e5e32..0000000
--- a/helix-core/src/test/java/org/apache/helix/alerts/TestAddPersistentStats.java
+++ /dev/null
@@ -1,211 +0,0 @@
-package org.apache.helix.alerts;
-
-/*
- * 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.Map;
-
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixException;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.Mocks.MockManager;
-import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.alerts.StatsHolder;
-import org.apache.helix.controller.stages.HealthDataCache;
-import org.testng.AssertJUnit;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-public class TestAddPersistentStats {
-
-  protected static final String CLUSTER_NAME = "TestCluster";
-
-  MockManager _helixManager;
-  StatsHolder _statsHolder;
-
-  @BeforeMethod(groups = {
-    "unitTest"
-  })
-  public void setup() {
-    _helixManager = new MockManager(CLUSTER_NAME);
-    _statsHolder = new StatsHolder(_helixManager, new HealthDataCache());
-  }
-
-  public boolean statRecordContains(ZNRecord rec, String statName) {
-    Map<String, Map<String, String>> stats = rec.getMapFields();
-    return stats.containsKey(statName);
-  }
-
-  public int statsSize(ZNRecord rec) {
-    Map<String, Map<String, String>> stats = rec.getMapFields();
-    return stats.size();
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddStat() throws Exception {
-    String stat = "window(5)(dbFoo.partition10.latency)";
-    _statsHolder.addStat(stat);
-    _statsHolder.persistStats();
-
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordContains(rec, stat));
-    AssertJUnit.assertEquals(1, statsSize(rec));
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddTwoStats() throws Exception {
-    String stat1 = "window(5)(dbFoo.partition10.latency)";
-    _statsHolder.addStat(stat1);
-    _statsHolder.persistStats();
-    String stat2 = "window(5)(dbFoo.partition11.latency)";
-    _statsHolder.addStat(stat2);
-    _statsHolder.persistStats();
-
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordContains(rec, stat1));
-    AssertJUnit.assertTrue(statRecordContains(rec, stat2));
-    AssertJUnit.assertEquals(2, statsSize(rec));
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddDuplicateStat() throws Exception {
-    String stat = "window(5)(dbFoo.partition10.latency)";
-    _statsHolder.addStat(stat);
-    _statsHolder.addStat(stat);
-    _statsHolder.persistStats();
-
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordContains(rec, stat));
-    AssertJUnit.assertEquals(1, statsSize(rec));
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddPairOfStats() throws Exception {
-    String exp = "accumulate()(dbFoo.partition10.latency, dbFoo.partition10.count)";
-    _statsHolder.addStat(exp);
-    _statsHolder.persistStats();
-
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordContains(rec, "accumulate()(dbFoo.partition10.latency)"));
-    AssertJUnit.assertTrue(statRecordContains(rec, "accumulate()(dbFoo.partition10.count)"));
-    AssertJUnit.assertEquals(2, statsSize(rec));
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddStatsWithOperators() throws Exception {
-    String exp =
-        "accumulate()(dbFoo.partition10.latency, dbFoo.partition10.count)|EACH|ACCUMULATE|DIVIDE";
-    _statsHolder.addStat(exp);
-    _statsHolder.persistStats();
-
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordContains(rec, "accumulate()(dbFoo.partition10.latency)"));
-    AssertJUnit.assertTrue(statRecordContains(rec, "accumulate()(dbFoo.partition10.count)"));
-    AssertJUnit.assertEquals(2, statsSize(rec));
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddNonExistentAggregator() throws Exception {
-    String exp = "fakeagg()(dbFoo.partition10.latency)";
-    boolean caughtException = false;
-    try {
-      _statsHolder.addStat(exp);
-    } catch (HelixException e) {
-      caughtException = true;
-    }
-    AssertJUnit.assertTrue(caughtException);
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testGoodAggregatorBadArgs() throws Exception {
-    String exp = "accumulate(10)(dbFoo.partition10.latency)";
-    boolean caughtException = false;
-    try {
-      _statsHolder.addStat(exp);
-    } catch (HelixException e) {
-      caughtException = true;
-    }
-    AssertJUnit.assertTrue(caughtException);
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddBadNestingStat1() throws Exception {
-    String exp = "window((5)(dbFoo.partition10.latency)";
-    boolean caughtException = false;
-    try {
-      _statsHolder.addStat(exp);
-    } catch (HelixException e) {
-      caughtException = true;
-    }
-    AssertJUnit.assertTrue(caughtException);
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddBadNestingStat2() throws Exception {
-    String exp = "window(5)(dbFoo.partition10.latency))";
-    boolean caughtException = false;
-    try {
-      _statsHolder.addStat(exp);
-    } catch (HelixException e) {
-      caughtException = true;
-    }
-    AssertJUnit.assertTrue(caughtException);
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/77cc6516/helix-core/src/test/java/org/apache/helix/alerts/TestAlertValidation.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/alerts/TestAlertValidation.java b/helix-core/src/test/java/org/apache/helix/alerts/TestAlertValidation.java
deleted file mode 100644
index 09a9d93..0000000
--- a/helix-core/src/test/java/org/apache/helix/alerts/TestAlertValidation.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package org.apache.helix.alerts;
-
-/*
- * 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 org.apache.helix.HelixException;
-import org.apache.helix.alerts.AlertParser;
-import org.testng.annotations.Test;
-import org.testng.AssertJUnit;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-@Test
-public class TestAlertValidation {
-
-  public final String EXP = AlertParser.EXPRESSION_NAME;
-  public final String CMP = AlertParser.COMPARATOR_NAME;
-  public final String CON = AlertParser.CONSTANT_NAME;
-
-  @Test
-  public void testSimple() {
-    String alertName =
-        EXP + "(accumulate()(dbFoo.partition10.latency)) " + CMP + "(GREATER) " + CON + "(10)";
-    boolean caughtException = false;
-    try {
-      AlertParser.validateAlert(alertName);
-    } catch (HelixException e) {
-      caughtException = true;
-      e.printStackTrace();
-    }
-    AssertJUnit.assertFalse(caughtException);
-  }
-
-  @Test
-  public void testSingleInSingleOut() {
-    String alertName =
-        EXP + "(accumulate()(dbFoo.partition10.latency)|EXPAND) " + CMP + "(GREATER) " + CON
-            + "(10)";
-    boolean caughtException = false;
-    try {
-      AlertParser.validateAlert(alertName);
-    } catch (HelixException e) {
-      caughtException = true;
-      e.printStackTrace();
-    }
-    AssertJUnit.assertFalse(caughtException);
-  }
-
-  @Test
-  public void testDoubleInDoubleOut() {
-    String alertName =
-        EXP + "(accumulate()(dbFoo.partition10.latency, dbFoo.partition11.latency)|EXPAND) " + CMP
-            + "(GREATER) " + CON + "(10)";
-    boolean caughtException = false;
-    try {
-      AlertParser.validateAlert(alertName);
-    } catch (HelixException e) {
-      caughtException = true;
-      e.printStackTrace();
-    }
-    AssertJUnit.assertTrue(caughtException);
-  }
-
-  @Test
-  public void testTwoStageOps() {
-    String alertName =
-        EXP + "(accumulate()(dbFoo.partition*.latency, dbFoo.partition*.count)|EXPAND|DIVIDE) "
-            + CMP + "(GREATER) " + CON + "(10)";
-    boolean caughtException = false;
-    try {
-      AlertParser.validateAlert(alertName);
-    } catch (HelixException e) {
-      caughtException = true;
-      e.printStackTrace();
-    }
-    AssertJUnit.assertFalse(caughtException);
-  }
-
-  @Test
-  public void testTwoListsIntoOne() {
-    String alertName =
-        EXP + "(accumulate()(dbFoo.partition10.latency, dbFoo.partition11.count)|SUM) " + CMP
-            + "(GREATER) " + CON + "(10)";
-    boolean caughtException = false;
-    try {
-      AlertParser.validateAlert(alertName);
-    } catch (HelixException e) {
-      caughtException = true;
-      e.printStackTrace();
-    }
-    AssertJUnit.assertFalse(caughtException);
-  }
-
-  @Test
-  public void testSumEach() {
-    String alertName =
-        EXP
-            + "(accumulate()(dbFoo.partition*.latency, dbFoo.partition*.count)|EXPAND|SUMEACH|DIVIDE) "
-            + CMP + "(GREATER) " + CON + "(10)";
-    boolean caughtException = false;
-    try {
-      AlertParser.validateAlert(alertName);
-    } catch (HelixException e) {
-      caughtException = true;
-      e.printStackTrace();
-    }
-    AssertJUnit.assertFalse(caughtException);
-  }
-
-  @Test
-  public void testNeedTwoTuplesGetOne() {
-    String alertName =
-        EXP + "(accumulate()(dbFoo.partition*.latency)|EXPAND|DIVIDE) " + CMP + "(GREATER) " + CON
-            + "(10)";
-    boolean caughtException = false;
-    try {
-      AlertParser.validateAlert(alertName);
-    } catch (HelixException e) {
-      caughtException = true;
-      e.printStackTrace();
-    }
-    AssertJUnit.assertTrue(caughtException);
-  }
-
-  @Test
-  public void testExtraPipe() {
-    String alertName =
-        EXP + "(accumulate()(dbFoo.partition10.latency)|) " + CMP + "(GREATER) " + CON + "(10)";
-    boolean caughtException = false;
-    try {
-      AlertParser.validateAlert(alertName);
-    } catch (HelixException e) {
-      caughtException = true;
-      e.printStackTrace();
-    }
-    AssertJUnit.assertTrue(caughtException);
-  }
-
-  @Test
-  public void testAlertUnknownOp() {
-    String alertName =
-        EXP + "(accumulate()(dbFoo.partition10.latency)|BADOP) " + CMP + "(GREATER) " + CON
-            + "(10)";
-    boolean caughtException = false;
-    try {
-      AlertParser.validateAlert(alertName);
-    } catch (HelixException e) {
-      caughtException = true;
-      e.printStackTrace();
-    }
-    AssertJUnit.assertTrue(caughtException);
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/77cc6516/helix-core/src/test/java/org/apache/helix/alerts/TestArrivingParticipantStats.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/alerts/TestArrivingParticipantStats.java b/helix-core/src/test/java/org/apache/helix/alerts/TestArrivingParticipantStats.java
deleted file mode 100644
index 848ef5a..0000000
--- a/helix-core/src/test/java/org/apache/helix/alerts/TestArrivingParticipantStats.java
+++ /dev/null
@@ -1,498 +0,0 @@
-package org.apache.helix.alerts;
-
-/*
- * 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.HelixDataAccessor;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.Mocks.MockManager;
-import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.alerts.StatsHolder;
-import org.apache.helix.alerts.Tuple;
-import org.apache.helix.controller.stages.HealthDataCache;
-import org.testng.AssertJUnit;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-public class TestArrivingParticipantStats {
-  protected static final String CLUSTER_NAME = "TestCluster";
-
-  MockManager _helixManager;
-  StatsHolder _statsHolder;
-
-  @BeforeMethod(groups = {
-    "unitTest"
-  })
-  public void setup() {
-    _helixManager = new MockManager(CLUSTER_NAME);
-    _statsHolder = new StatsHolder(_helixManager, new HealthDataCache());
-  }
-
-  public Map<String, String> getStatFields(String value, String timestamp) {
-    Map<String, String> statMap = new HashMap<String, String>();
-    statMap.put(StatsHolder.VALUE_NAME, value);
-    statMap.put(StatsHolder.TIMESTAMP_NAME, timestamp);
-    return statMap;
-  }
-
-  public boolean statRecordContains(ZNRecord rec, String statName) {
-    Map<String, Map<String, String>> stats = rec.getMapFields();
-    return stats.containsKey(statName);
-  }
-
-  public boolean statRecordHasValue(ZNRecord rec, String statName, String value) {
-    Map<String, Map<String, String>> stats = rec.getMapFields();
-    Map<String, String> statFields = stats.get(statName);
-    return (statFields.get(StatsHolder.VALUE_NAME).equals(value));
-  }
-
-  public boolean statRecordHasTimestamp(ZNRecord rec, String statName, String timestamp) {
-    Map<String, Map<String, String>> stats = rec.getMapFields();
-    Map<String, String> statFields = stats.get(statName);
-    return (statFields.get(StatsHolder.TIMESTAMP_NAME).equals(timestamp));
-  }
-
-  // Exact matching persistent stat, but has no values yet
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddFirstParticipantStat() throws Exception {
-    // add a persistent stat
-    String persistentStat = "accumulate()(dbFoo.partition10.latency)";
-    _statsHolder.addStat(persistentStat);
-
-    // generate incoming stat
-    String incomingStatName = "dbFoo.partition10.latency";
-    Map<String, String> statFields = getStatFields("0", "0");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    // check persistent stats
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "0.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "0.0"));
-  }
-
-  // Exact matching persistent stat, but has no values yet
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddRepeatParticipantStat() throws Exception {
-    // add a persistent stat
-    String persistentStat = "accumulate()(dbFoo.partition10.latency)";
-    _statsHolder.addStat(persistentStat);
-
-    // generate incoming stat
-    String incomingStatName = "dbFoo.partition10.latency";
-    // apply stat once and then again
-    Map<String, String> statFields = getStatFields("0", "0");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    statFields = getStatFields("1", "10");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    // check persistent stats
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "1.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "10.0"));
-  }
-
-  // test to ensure backdated stats not applied
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testBackdatedParticipantStat() throws Exception {
-    // add a persistent stat
-    String persistentStat = "accumulate()(dbFoo.partition10.latency)";
-    _statsHolder.addStat(persistentStat);
-
-    // generate incoming stat
-    String incomingStatName = "dbFoo.partition10.latency";
-    // apply stat once and then again
-    Map<String, String> statFields = getStatFields("0", "0");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    statFields = getStatFields("1", "10");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    statFields = getStatFields("5", "15");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    statFields = getStatFields("1", "10");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    // check persistent stats
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "6.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "15.0"));
-  }
-
-  // Exact matching persistent stat, but has no values yet
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddFirstParticipantStatToWildCard() throws Exception {
-    // add a persistent stat
-    String persistentWildcardStat = "accumulate()(dbFoo.partition*.latency)";
-    _statsHolder.addStat(persistentWildcardStat);
-
-    // generate incoming stat
-    String incomingStatName = "dbFoo.partition10.latency";
-    Map<String, String> statFields = getStatFields("0", "0");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    // check persistent stats
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    String persistentStat = "accumulate()(dbFoo.partition10.latency)";
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "0.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "0.0"));
-  }
-
-  // test to add 2nd report to same stat
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddSecondParticipantStatToWildCard() throws Exception {
-    // add a persistent stat
-    String persistentWildcardStat = "accumulate()(dbFoo.partition*.latency)";
-    _statsHolder.addStat(persistentWildcardStat);
-
-    // generate incoming stat
-    String incomingStatName = "dbFoo.partition10.latency";
-    Map<String, String> statFields = getStatFields("1", "0");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    statFields = getStatFields("1", "10");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    // check persistent stats
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    String persistentStat = "accumulate()(dbFoo.partition10.latency)";
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "2.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "10.0"));
-  }
-
-  // Exact matching persistent stat, but has no values yet
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddParticipantStatToDoubleWildCard() throws Exception {
-    // add a persistent stat
-    String persistentWildcardStat = "accumulate()(db*.partition*.latency)";
-    _statsHolder.addStat(persistentWildcardStat);
-
-    // generate incoming stat
-    String incomingStatName = "dbFoo.partition10.latency";
-    Map<String, String> statFields = getStatFields("0", "0");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    // check persistent stats
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    String persistentStat = "accumulate()(dbFoo.partition10.latency)";
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "0.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "0.0"));
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddWildcardInFirstStatToken() throws Exception {
-    String persistentWildcardStat = "accumulate()(instance*.reportingage)";
-    _statsHolder.addStat(persistentWildcardStat);
-
-    // generate incoming stat
-    String incomingStatName = "instance10.reportingage";
-    Map<String, String> statFields = getStatFields("1", "10");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    // check persistent stats
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    String persistentStat = "accumulate()(instance10.reportingage)";
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "1.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "10.0"));
-
-  }
-
-  // test to add report to same wildcard stat, different actual stat
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddTwoDistinctParticipantStatsToSameWildCard() throws Exception {
-    // add a persistent stat
-    String persistentWildcardStat = "accumulate()(dbFoo.partition*.latency)";
-    _statsHolder.addStat(persistentWildcardStat);
-
-    // generate incoming stat
-    String incomingStatName = "dbFoo.partition10.latency";
-    Map<String, String> statFields = getStatFields("1", "10");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    incomingStatName = "dbFoo.partition11.latency";
-    statFields = getStatFields("5", "10");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    // check persistent stats
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    String persistentStat = "accumulate()(dbFoo.partition10.latency)";
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "1.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "10.0"));
-    persistentStat = "accumulate()(dbFoo.partition11.latency)";
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "5.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "10.0"));
-  }
-
-  // Exact matching persistent stat, but has no values yet
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testWindowStat() throws Exception {
-    // add a persistent stat
-    String persistentWildcardStat = "window(3)(dbFoo.partition*.latency)";
-    _statsHolder.addStat(persistentWildcardStat);
-
-    // generate incoming stat
-    String incomingStatName = "dbFoo.partition10.latency";
-    Map<String, String> statFields = getStatFields("0", "0");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    // check persistent stats
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    String persistentStat = "window(3)(dbFoo.partition10.latency)";
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "0.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "0.0"));
-
-    // add 2nd stat
-    statFields = getStatFields("10", "1");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "0.0,10.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "0.0,1.0"));
-
-    // add 3rd stat
-    statFields = getStatFields("20", "2");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "0.0,10.0,20.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "0.0,1.0,2.0"));
-
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testWindowStatExpiration() throws Exception {
-    String persistentWildcardStat = "window(3)(dbFoo.partition*.latency)";
-    String persistentStat = "window(3)(dbFoo.partition10.latency)";
-    // init with 3 elements
-    testWindowStat();
-
-    String incomingStatName = "dbFoo.partition10.latency";
-    Map<String, String> statFields = getStatFields("30", "3");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "10.0,20.0,30.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "1.0,2.0,3.0"));
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testWindowStatStale() throws Exception {
-    String persistentWildcardStat = "window(3)(dbFoo.partition*.latency)";
-    String persistentStat = "window(3)(dbFoo.partition10.latency)";
-    // init with 3 elements
-    testWindowStat();
-
-    String incomingStatName = "dbFoo.partition10.latency";
-    Map<String, String> statFields = getStatFields("10", "1");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "0.0,10.0,20.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "0.0,1.0,2.0"));
-  }
-
-  // test that has 2 agg stats for same raw stat
-  // Exact matching persistent stat, but has no values yet
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddStatForTwoAggTypes() throws Exception {
-    // add a persistent stat
-    String persistentStatOne = "accumulate()(dbFoo.partition10.latency)";
-    String persistentStatTwo = "window(3)(dbFoo.partition10.latency)";
-    _statsHolder.addStat(persistentStatOne);
-    _statsHolder.persistStats();
-    _statsHolder.addStat(persistentStatTwo);
-    _statsHolder.persistStats();
-
-    // generate incoming stat
-    String incomingStatName = "dbFoo.partition10.latency";
-    Map<String, String> statFields = getStatFields("0", "0");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    // check persistent stats
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStatOne, "0.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStatOne, "0.0"));
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStatTwo, "0.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStatTwo, "0.0"));
-  }
-
-  // test merging 2 window stats, new is applied
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testMergeTwoWindowsYesMerge() throws Exception {
-    String persistentWildcardStat = "window(3)(dbFoo.partition*.latency)";
-    String persistentStat = "window(3)(dbFoo.partition10.latency)";
-    String incomingStatName = "dbFoo.partition10.latency";
-    // init with 3 elements
-    testWindowStat();
-
-    // create a two tuples, value and time
-    Tuple<String> valTuple = new Tuple<String>();
-    Tuple<String> timeTuple = new Tuple<String>();
-    valTuple.add("30.0");
-    valTuple.add("40.0");
-    timeTuple.add("3.0");
-    timeTuple.add("4.0");
-    Map<String, String> statFields = getStatFields(valTuple.toString(), timeTuple.toString());
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    // check persistent stats
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "20.0,30.0,40.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "2.0,3.0,4.0"));
-  }
-
-  // test merging 2 window stats, new is ignored
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testMergeTwoWindowsNoMerge() throws Exception {
-    String persistentWildcardStat = "window(3)(dbFoo.partition*.latency)";
-    String persistentStat = "window(3)(dbFoo.partition10.latency)";
-    String incomingStatName = "dbFoo.partition10.latency";
-    // init with 3 elements
-    testWindowStat();
-
-    // create a two tuples, value and time
-    Tuple<String> valTuple = new Tuple<String>();
-    Tuple<String> timeTuple = new Tuple<String>();
-    valTuple.add("0.0");
-    valTuple.add("40.0");
-    timeTuple.add("0.0");
-    timeTuple.add("4.0");
-    Map<String, String> statFields = getStatFields(valTuple.toString(), timeTuple.toString());
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    // check persistent stats
-    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
-    Builder keyBuilder = accessor.keyBuilder();
-
-    ZNRecord rec = accessor.getProperty(keyBuilder.persistantStat()).getRecord();
-    System.out.println("rec: " + rec.toString());
-    AssertJUnit.assertTrue(statRecordHasValue(rec, persistentStat, "0.0,10.0,20.0"));
-    AssertJUnit.assertTrue(statRecordHasTimestamp(rec, persistentStat, "0.0,1.0,2.0"));
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/77cc6516/helix-core/src/test/java/org/apache/helix/alerts/TestBaseStatsValidation.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/alerts/TestBaseStatsValidation.java b/helix-core/src/test/java/org/apache/helix/alerts/TestBaseStatsValidation.java
deleted file mode 100644
index 5183182..0000000
--- a/helix-core/src/test/java/org/apache/helix/alerts/TestBaseStatsValidation.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package org.apache.helix.alerts;
-
-/*
- * 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 org.apache.helix.HelixException;
-import org.apache.helix.alerts.ExpressionOperatorType;
-import org.apache.helix.alerts.ExpressionParser;
-import org.testng.annotations.Test;
-import org.testng.AssertJUnit;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-@Test
-public class TestBaseStatsValidation {
-
-  @Test
-  public void testParseSingletonExpression() {
-    String[] actual = null;
-
-    String statName = "window(5)(dbFoo.partition10.latency)";
-    try {
-      actual = ExpressionParser.getBaseStats(statName);
-    } catch (HelixException e) {
-      e.printStackTrace();
-    }
-    AssertJUnit.assertEquals(statName, actual[0]);
-  }
-
-  @Test
-  public void testExtraParen() {
-    String[] actual = null;
-
-    String statName = "window(5)(dbFoo.partition10.latency)()";
-    boolean caughtException = false;
-    try {
-      actual = ExpressionParser.getBaseStats(statName);
-    } catch (HelixException e) {
-      caughtException = true;
-      // e.printStackTrace();
-    }
-    AssertJUnit.assertEquals(true, caughtException);
-  }
-
-  @Test
-  public void testParseSingletonWildcardExpression() {
-    String[] actual = null;
-
-    String statName = "accumulate()(dbFoo.partition*.latency)";
-    try {
-      actual = ExpressionParser.getBaseStats(statName);
-    } catch (HelixException e) {
-      e.printStackTrace();
-    }
-    AssertJUnit.assertEquals(statName, actual[0]);
-  }
-
-  @Test
-  public void testParsePairOfExpressions() {
-    String[] actual = null;
-
-    String expression = "accumulate()(dbFoo.partition10.latency, dbFoo.partition10.count)";
-    try {
-      actual = ExpressionParser.getBaseStats(expression);
-    } catch (HelixException e) {
-      e.printStackTrace();
-    }
-    AssertJUnit.assertEquals("accumulate()(dbFoo.partition10.latency)", actual[0]);
-    AssertJUnit.assertEquals("accumulate()(dbFoo.partition10.count)", actual[1]);
-  }
-
-  /*
-   * SUM is not to be persisted, so pull out the pieces
-   */
-  @Test
-  public void testSUMExpression() {
-    String[] actual = null;
-
-    String expression = "accumulate()(dbFoo.partition*.latency)|SUM";
-    try {
-      actual = ExpressionParser.getBaseStats(expression);
-    } catch (HelixException e) {
-      e.printStackTrace();
-    }
-    AssertJUnit.assertEquals("accumulate()(dbFoo.partition*.latency)", actual[0]);
-  }
-
-  @Test
-  public void testSumPairExpression() {
-    String[] actual = null;
-
-    String expression = "window(5)(dbFoo.partition10.latency, dbFoo.partition11.latency)|SUM";
-    try {
-      actual = ExpressionParser.getBaseStats(expression);
-    } catch (HelixException e) {
-      e.printStackTrace();
-    }
-    AssertJUnit.assertEquals("window(5)(dbFoo.partition10.latency)", actual[0]);
-    AssertJUnit.assertEquals("window(5)(dbFoo.partition11.latency)", actual[1]);
-  }
-
-  @Test
-  public void testEachPairExpression() {
-    String[] actual = null;
-
-    String expression = "accumulate()(dbFoo.partition*.latency, dbFoo.partition*.count)|EACH";
-    try {
-      actual = ExpressionParser.getBaseStats(expression);
-    } catch (HelixException e) {
-      e.printStackTrace();
-    }
-    AssertJUnit.assertEquals("accumulate()(dbFoo.partition*.latency)", actual[0]);
-    AssertJUnit.assertEquals("accumulate()(dbFoo.partition*.count)", actual[1]);
-  }
-
-  @Test
-  public void testAccumulateExpression() {
-    String[] actual = null;
-
-    String expression = "accumulate()(dbFoo.partition10.latency)|ACCUMULATE";
-    try {
-      actual = ExpressionParser.getBaseStats(expression);
-    } catch (HelixException e) {
-      e.printStackTrace();
-    }
-    AssertJUnit.assertEquals("accumulate()(dbFoo.partition10.latency)", actual[0]);
-  }
-
-  @Test
-  public void testAccumulateEachExpression() {
-    String[] actual = null;
-
-    String expression = "window(5)(dbFoo.partition*.latency)|EACH|ACCUMULATE";
-    try {
-      actual = ExpressionParser.getBaseStats(expression);
-    } catch (HelixException e) {
-      e.printStackTrace();
-    }
-    AssertJUnit.assertEquals("window(5)(dbFoo.partition*.latency)", actual[0]);
-  }
-
-  @Test
-  public void testAccumulateEachPairExpression() {
-    String[] actual = null;
-
-    String expression =
-        "accumulate()(dbFoo.partition*.latency, dbFoo.partition*.count)|EACH|ACCUMULATE|DIVIDE";
-    try {
-      actual = ExpressionParser.getBaseStats(expression);
-    } catch (HelixException e) {
-      e.printStackTrace();
-    }
-    AssertJUnit.assertEquals("accumulate()(dbFoo.partition*.latency)", actual[0]);
-    AssertJUnit.assertEquals("accumulate()(dbFoo.partition*.count)", actual[1]);
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/77cc6516/helix-core/src/test/java/org/apache/helix/alerts/TestEvaluateAlerts.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/alerts/TestEvaluateAlerts.java b/helix-core/src/test/java/org/apache/helix/alerts/TestEvaluateAlerts.java
deleted file mode 100644
index 403dfdb..0000000
--- a/helix-core/src/test/java/org/apache/helix/alerts/TestEvaluateAlerts.java
+++ /dev/null
@@ -1,393 +0,0 @@
-package org.apache.helix.alerts;
-
-/*
- * 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.HelixException;
-import org.apache.helix.Mocks.MockManager;
-import org.apache.helix.alerts.AlertParser;
-import org.apache.helix.alerts.AlertProcessor;
-import org.apache.helix.alerts.AlertValueAndStatus;
-import org.apache.helix.alerts.AlertsHolder;
-import org.apache.helix.alerts.StatsHolder;
-import org.apache.helix.controller.stages.HealthDataCache;
-import org.testng.AssertJUnit;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-public class TestEvaluateAlerts {
-  protected static final String CLUSTER_NAME = "TestCluster";
-
-  MockManager _helixManager;
-  AlertsHolder _alertsHolder;
-  StatsHolder _statsHolder;
-
-  public final String EXP = AlertParser.EXPRESSION_NAME;
-  public final String CMP = AlertParser.COMPARATOR_NAME;
-  public final String CON = AlertParser.CONSTANT_NAME;
-
-  @BeforeMethod(groups = {
-    "unitTest"
-  })
-  public void setup() {
-    HealthDataCache cache = new HealthDataCache();
-    _helixManager = new MockManager(CLUSTER_NAME);
-    _alertsHolder = new AlertsHolder(_helixManager, cache);
-    _statsHolder = _alertsHolder._statsHolder;
-  }
-
-  public Map<String, String> getStatFields(String value, String timestamp) {
-    Map<String, String> statMap = new HashMap<String, String>();
-    statMap.put(StatsHolder.VALUE_NAME, value);
-    statMap.put(StatsHolder.TIMESTAMP_NAME, timestamp);
-    return statMap;
-  }
-
-  public String getSimpleStat() throws HelixException {
-    String stat = "accumulate()(dbFoo.partition10.latency)";
-    // _statsHolder.addStat(stat);
-    return stat;
-  }
-
-  public String addPairOfStats() throws HelixException {
-    String stat = "accumulate()(dbFoo.partition10.latency, dbFoo.partition11.latency)";
-    _statsHolder.addStat(stat);
-    _statsHolder.persistStats();
-    return stat;
-  }
-
-  public String getWildcardStat() throws HelixException {
-    String stat = "accumulate()(dbFoo.partition*.latency)";
-    // _statsHolder.addStat(stat);
-    return stat;
-  }
-
-  public String addSimpleAlert() throws HelixException {
-    String alert =
-        EXP + "(accumulate()(dbFoo.partition10.latency))" + CMP + "(GREATER)" + CON + "(100)";
-    _alertsHolder.addAlert(alert);
-    return alert;
-  }
-
-  public String addWildcardAlert() throws HelixException {
-    String alert =
-        EXP + "(accumulate()(dbFoo.partition*.latency))" + CMP + "(GREATER)" + CON + "(100)";
-    _alertsHolder.addAlert(alert);
-    return alert;
-  }
-
-  public String addTwoWildcardAlert() throws HelixException {
-    String alert =
-        EXP + "(accumulate()(dbFoo.partition*.put*))" + CMP + "(GREATER)" + CON + "(100)";
-    _alertsHolder.addAlert(alert);
-    return alert;
-  }
-
-  public String addExpandWildcardAlert() throws HelixException {
-    String alert =
-        EXP + "(accumulate()(dbFoo.partition*.latency)|EXPAND)" + CMP + "(GREATER)" + CON + "(100)";
-    _alertsHolder.addAlert(alert);
-    return alert;
-  }
-
-  public String addExpandSumAlert() throws HelixException {
-    String alert =
-        EXP + "(accumulate()(dbFoo.partition10.latency,dbFoo.partition11.latency)|EXPAND|SUM)"
-            + CMP + "(GREATER)" + CON + "(100)";
-    _alertsHolder.addAlert(alert);
-    return alert;
-  }
-
-  public String addExpandSumWildcardAlert() throws HelixException {
-    String alert =
-        EXP + "(accumulate()(dbFoo.partition*.success,dbFoo.partition*.failure)|EXPAND|SUM)" + CMP
-            + "(GREATER)" + CON + "(100)";
-    _alertsHolder.addAlert(alert);
-    return alert;
-  }
-
-  public String addExpandSumEachWildcardAlert() throws HelixException {
-    String alert =
-        EXP + "(accumulate()(dbFoo.partition*.success,dbFoo.partition*.failure)|EXPAND|SUMEACH)"
-            + CMP + "(GREATER)" + CON + "(100)";
-    _alertsHolder.addAlert(alert);
-    return alert;
-  }
-
-  public String addExpandSumEachSumWildcardAlert() throws HelixException {
-    String alert =
-        EXP
-            + "(accumulate()(dbFoo.partition*.success,dbFoo.partition*.failure)|EXPAND|SUMEACH|SUM)"
-            + CMP + "(GREATER)" + CON + "(100)";
-    _alertsHolder.addAlert(alert);
-    return alert;
-  }
-
-  public String addArrivingSimpleStat() throws HelixException {
-    _statsHolder.refreshStats();
-    String incomingStatName = "dbFoo.partition10.latency";
-    Map<String, String> statFields = getStatFields("110", "0");
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-    return incomingStatName;
-  }
-
-  public String addArrivingPairOfStats() throws HelixException {
-    _statsHolder.refreshStats();
-    String incomingStatName1 = "dbFoo.partition10.latency";
-    String incomingStatName2 = "dbFoo.partition11.latency";
-    Map<String, String> statFields = getStatFields("50", "0");
-    _statsHolder.applyStat(incomingStatName1, statFields);
-    statFields = getStatFields("51", "0");
-    _statsHolder.applyStat(incomingStatName2, statFields);
-    _statsHolder.persistStats();
-    return null;
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testSimpleAlertFires() {
-    String alert = addSimpleAlert();
-    String stat = AlertParser.getComponent(AlertParser.EXPRESSION_NAME, alert);
-    _statsHolder.refreshStats(); // need to refresh since not triggered by stats aggregation stage
-    addArrivingSimpleStat();
-    Map<String, Map<String, AlertValueAndStatus>> alertResult =
-        AlertProcessor.executeAllAlerts(_alertsHolder.getAlertList(), _statsHolder.getStatsList());
-    boolean alertFired = alertResult.get(alert).get(AlertProcessor.noWildcardAlertKey).isFired();
-    AssertJUnit.assertTrue(alertFired);
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testSimpleAlertNoStatArrivesFires() {
-    String alert = addSimpleAlert();
-    String stat = AlertParser.getComponent(AlertParser.EXPRESSION_NAME, alert);
-    Map<String, Map<String, AlertValueAndStatus>> alertResult =
-        AlertProcessor.executeAllAlerts(_alertsHolder.getAlertList(), _statsHolder.getStatsList());
-    AssertJUnit.assertEquals(null, alertResult.get(AlertProcessor.noWildcardAlertKey));
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testWildcardAlertFires() {
-    String alert = addWildcardAlert();
-    String stat = AlertParser.getComponent(AlertParser.EXPRESSION_NAME, alert);
-    String incomingStatName = addArrivingSimpleStat();
-
-    Map<String, Map<String, AlertValueAndStatus>> alertResult =
-        AlertProcessor.executeAllAlerts(_alertsHolder.getAlertList(), _statsHolder.getStatsList());
-    String wildcardBinding = incomingStatName;
-    boolean alertFired = alertResult.get(alert).get(wildcardBinding).isFired();
-    AssertJUnit.assertTrue(alertFired);
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testExpandOperatorWildcardAlertFires() {
-    String alert = addExpandWildcardAlert();
-    String stat = AlertParser.getComponent(AlertParser.EXPRESSION_NAME, alert);
-    String incomingStatName = addArrivingSimpleStat();
-    Map<String, Map<String, AlertValueAndStatus>> alertResult =
-        AlertProcessor.executeAllAlerts(_alertsHolder.getAlertList(), _statsHolder.getStatsList());
-    String wildcardBinding = incomingStatName;
-    boolean alertFired = alertResult.get(alert).get(wildcardBinding).isFired();
-    AssertJUnit.assertTrue(alertFired);
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testExpandSumOperatorAlertFires() {
-    String alert = addExpandSumAlert();
-    String stat = AlertParser.getComponent(AlertParser.EXPRESSION_NAME, alert);
-    addArrivingPairOfStats();
-    Map<String, Map<String, AlertValueAndStatus>> alertResult =
-        AlertProcessor.executeAllAlerts(_alertsHolder.getAlertList(), _statsHolder.getStatsList());
-    boolean alertFired = alertResult.get(alert).get(AlertProcessor.noWildcardAlertKey).isFired();
-    AssertJUnit.assertTrue(alertFired);
-  }
-
-  /**
-   * We need to re-decide how to support the feature to specify more than one stats in
-   * an alert.
-   * Probabaly instead of
-   * "(dbFoo.partition*.success,dbFoo.partition*.failure)", use the form
-   * "(dbFoo.partition*.(success, failure))" as it seems that the stat source is always the
-   * same.
-   * 
-   //@Test (groups = {"unitTest"})
-   * public void testExpandSumOperatorWildcardAlert()
-   * {
-   * String alert = addExpandSumWildcardAlert();
-   * String stat = AlertParser.getComponent(AlertParser.EXPRESSION_NAME, alert);
-   * String part10SuccStat = "dbFoo.partition10.success";
-   * String part10FailStat = "dbFoo.partition10.failure";
-   * String part11SuccStat = "dbFoo.partition11.success";
-   * String part11FailStat = "dbFoo.partition11.failure";
-   * Map<String, String> statFields = getStatFields("50","0");
-   * _statsHolder.applyStat(part10SuccStat, statFields);
-   * statFields = getStatFields("51","0");
-   * _statsHolder.applyStat(part10FailStat, statFields);
-   * statFields = getStatFields("50","0");
-   * _statsHolder.applyStat(part11SuccStat, statFields);
-   * statFields = getStatFields("49","0");
-   * _statsHolder.applyStat(part11FailStat, statFields);
-   * Map<String, Map<String, AlertValueAndStatus>> alertResult =
-   * AlertProcessor.executeAllAlerts(_alertsHolder.getAlertList(), _statsHolder.getStatsList());
-   * boolean alertFired = alertResult.get(alert).get("10").isFired(); //10 should fire
-   * AssertJUnit.assertTrue(alertFired);
-   * alertFired = alertResult.get(alert).get("11").isFired(); //11 should not fire
-   * AssertJUnit.assertFalse(alertFired);
-   * }
-   * //@Test (groups = {"unitTest"})
-   * public void testExpandSumEachSumOperatorWildcardAlert()
-   * {
-   * String alert = addExpandSumEachSumWildcardAlert();
-   * String stat = AlertParser.getComponent(AlertParser.EXPRESSION_NAME, alert);
-   * String part10SuccStat = "dbFoo.partition10.success";
-   * String part10FailStat = "dbFoo.partition10.failure";
-   * String part11SuccStat = "dbFoo.partition11.success";
-   * String part11FailStat = "dbFoo.partition11.failure";
-   * Map<String, String> statFields = getStatFields("50","0");
-   * _statsHolder.applyStat(part10SuccStat, statFields);
-   * statFields = getStatFields("51","0");
-   * _statsHolder.applyStat(part10FailStat, statFields);
-   * statFields = getStatFields("50","0");
-   * _statsHolder.applyStat(part11SuccStat, statFields);
-   * statFields = getStatFields("49","0");
-   * _statsHolder.applyStat(part11FailStat, statFields);
-   * Map<String, Map<String, AlertValueAndStatus>> alertResult =
-   * AlertProcessor.executeAllAlerts(_alertsHolder.getAlertList(), _statsHolder.getStatsList());
-   * boolean alertFired = alertResult.get(alert).get(_statsHolder.getStatsList().get(0)).isFired();
-   * //10 should fire
-   * AssertJUnit.assertTrue(alertFired);
-   * }
-   * //@Test (groups = {"unitTest"})
-   * public void testTwoAlerts()
-   * {
-   * //alert 1
-   * String alert1 = addSimpleAlert();
-   * String stat = AlertParser.getComponent(AlertParser.EXPRESSION_NAME, alert1);
-   * addArrivingSimpleStat();
-   * //alert 2
-   * String alert2 = addExpandSumWildcardAlert();
-   * stat = AlertParser.getComponent(AlertParser.EXPRESSION_NAME, alert2);
-   * String part10SuccStat = "dbFoo.partition10.success";
-   * String part10FailStat = "dbFoo.partition10.failure";
-   * String part11SuccStat = "dbFoo.partition11.success";
-   * String part11FailStat = "dbFoo.partition11.failure";
-   * Map<String, String> statFields = getStatFields("50","0");
-   * _statsHolder.applyStat(part10SuccStat, statFields);
-   * statFields = getStatFields("51","0");
-   * _statsHolder.applyStat(part10FailStat, statFields);
-   * statFields = getStatFields("50","0");
-   * _statsHolder.applyStat(part11SuccStat, statFields);
-   * statFields = getStatFields("49","0");
-   * _statsHolder.applyStat(part11FailStat, statFields);
-   * Map<String, Map<String, AlertValueAndStatus>> alertResult =
-   * AlertProcessor.executeAllAlerts(_alertsHolder.getAlertList(), _statsHolder.getStatsList());
-   * //alert 1 check
-   * boolean alertFired = alertResult.get(alert1).get(AlertProcessor.noWildcardAlertKey).isFired();
-   * AssertJUnit.assertTrue(alertFired);
-   * //alert 2 check
-   * alertFired = alertResult.get(alert2).get("10").isFired(); //10 should fire
-   * AssertJUnit.assertTrue(alertFired);
-   * alertFired = alertResult.get(alert2).get("11").isFired(); //11 should not fire
-   * AssertJUnit.assertFalse(alertFired);
-   * }
-   */
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testAddWildcardInFirstStatToken() throws Exception {
-    String alert = "EXP(decay(1)(instance*.reportingage))CMP(GREATER)CON(300)";
-    _alertsHolder.addAlert(alert);
-    _statsHolder.persistStats();
-
-    _statsHolder.refreshStats();
-    // generate incoming stat
-    String incomingStatName = "instance10.reportingage";
-    Map<String, String> statFields = getStatFields("301", "10");
-    _statsHolder.refreshStats();
-
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-
-    Map<String, Map<String, AlertValueAndStatus>> alertResult =
-        AlertProcessor.executeAllAlerts(_alertsHolder.getAlertList(), _statsHolder.getStatsList());
-    String wildcardBinding = incomingStatName;
-    boolean alertFired = alertResult.get(alert).get(wildcardBinding).isFired();
-    AssertJUnit.assertTrue(alertFired);
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void testTwoWildcardAlertFires() {
-    // error is with * and )
-    String alert = addTwoWildcardAlert();
-    String stat = AlertParser.getComponent(AlertParser.EXPRESSION_NAME, alert);
-    String incomingStatName = "dbFoo.partition10.putCount";
-    Map<String, String> statFields = getStatFields("110", "0");
-    _statsHolder.refreshStats();
-    _statsHolder.applyStat(incomingStatName, statFields);
-    _statsHolder.persistStats();
-    Map<String, Map<String, AlertValueAndStatus>> alertResult =
-        AlertProcessor.executeAllAlerts(_alertsHolder.getAlertList(), _statsHolder.getStatsList());
-    String wildcardBinding = incomingStatName; // XXX: this is not going to work...need "Count" in
-                                               // here too.
-    boolean alertFired = alertResult.get(alert).get(wildcardBinding).isFired();
-    AssertJUnit.assertTrue(alertFired);
-  }
-
-  /*
-   * only supporting wildcards at end of components right now
-   * @Test (groups = {"unitTest"})
-   * public void testTwoWildcardsNotAtEndFires()
-   * {
-   * String alert = EXP + "(accumulate()(dbFoo.partition*.*Count))"
-   * + CMP + "(GREATER)" + CON + "(100)";
-   * _alertsHolder.addAlert(alert);
-   * String incomingStatName = "dbFoo.partition10.putCount";
-   * Map<String, String> statFields = getStatFields("110","0");
-   * _statsHolder.applyStat(incomingStatName, statFields);
-   * Map<String, Map<String, AlertValueAndStatus>> alertResult =
-   * AlertProcessor.executeAllAlerts(_alertsHolder.getAlertList(), _statsHolder.getStatsList());
-   * String wildcardBinding = "10,put"; //XXX: this is not going to work...need "Count" in here too.
-   * boolean alertFired = alertResult.get(alert).get(wildcardBinding).isFired();
-   * AssertJUnit.assertTrue(alertFired);
-   * }
-   */
-
-  // test using sumall
-  // test using rows where some tuples are null (no stat sent)
-  // test with window tuples where some windows are different lengths
-  // anything else, look around at the code
-
-  // next: review all older tests
-  // next: actually write the fired alerts to ZK
-
-}


Mime
View raw message