You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ka...@apache.org on 2014/07/11 21:58:04 UTC
[09/17] git commit: [HELIX-395] Remove old Helix alert/stat modules
[HELIX-395] Remove old Helix alert/stat modules
Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/38b43965
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/38b43965
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/38b43965
Branch: refs/heads/master
Commit: 38b439651b4f2ce33f1dbdb96b0f626a1ca49514
Parents: 9524e51
Author: zzhang <zz...@apache.org>
Authored: Tue May 20 13:22:02 2014 -0700
Committer: Kanak Biscuitwala <ka...@apache.org>
Committed: Fri Jul 11 12:40:20 2014 -0700
----------------------------------------------------------------------
.../apache/helix/HealthStateChangeListener.java | 39 --
.../main/java/org/apache/helix/HelixAdmin.java | 28 --
.../java/org/apache/helix/HelixConnection.java | 10 -
.../java/org/apache/helix/HelixManager.java | 24 +-
.../main/java/org/apache/helix/PropertyKey.java | 61 ---
.../org/apache/helix/PropertyPathConfig.java | 13 -
.../java/org/apache/helix/PropertyType.java | 4 -
.../helix/alerts/AccumulateAggregator.java | 67 ---
.../org/apache/helix/alerts/Aggregator.java | 40 --
.../java/org/apache/helix/alerts/Alert.java | 52 --
.../apache/helix/alerts/AlertComparator.java | 30 --
.../org/apache/helix/alerts/AlertParser.java | 138 ------
.../org/apache/helix/alerts/AlertProcessor.java | 308 ------------
.../helix/alerts/AlertValueAndStatus.java | 42 --
.../org/apache/helix/alerts/AlertsHolder.java | 261 ----------
.../apache/helix/alerts/DecayAggregator.java | 76 ---
.../org/apache/helix/alerts/DivideOperator.java | 40 --
.../org/apache/helix/alerts/ExpandOperator.java | 39 --
.../helix/alerts/ExpressionOperatorType.java | 44 --
.../apache/helix/alerts/ExpressionParser.java | 494 ------------------
.../helix/alerts/GreaterAlertComparator.java | 45 --
.../apache/helix/alerts/MultiplyOperator.java | 60 ---
.../java/org/apache/helix/alerts/Operator.java | 111 -----
.../main/java/org/apache/helix/alerts/Stat.java | 44 --
.../org/apache/helix/alerts/StatsHolder.java | 306 ------------
.../apache/helix/alerts/SumEachOperator.java | 51 --
.../org/apache/helix/alerts/SumOperator.java | 59 ---
.../java/org/apache/helix/alerts/Tuple.java | 85 ----
.../apache/helix/alerts/WindowAggregator.java | 91 ----
.../org/apache/helix/alerts/package-info.java | 22 -
.../helix/api/accessor/ClusterAccessor.java | 161 ------
.../controller/GenericHelixController.java | 59 +--
.../controller/stages/HealthDataCache.java | 95 ----
.../controller/stages/ReadHealthDataStage.java | 51 --
.../stages/StatsAggregationStage.java | 399 ---------------
.../healthcheck/AccumulateAggregationType.java | 41 --
.../helix/healthcheck/AggregationType.java | 31 --
.../healthcheck/AggregationTypeFactory.java | 69 ---
.../helix/healthcheck/DecayAggregationType.java | 57 ---
.../DefaultHealthReportProvider.java | 86 ----
.../helix/healthcheck/DefaultPerfCounters.java | 95 ----
.../helix/healthcheck/HealthReportProvider.java | 39 --
.../healthcheck/HealthStatsAggregationTask.java | 89 ----
.../healthcheck/HealthStatsAggregator.java | 141 ------
.../ParticipantHealthReportCollector.java | 32 --
.../ParticipantHealthReportCollectorImpl.java | 115 -----
.../ParticipantHealthReportTask.java | 71 ---
.../PerformanceHealthReportProvider.java | 138 ------
.../java/org/apache/helix/healthcheck/Stat.java | 125 -----
.../healthcheck/StatHealthReportProvider.java | 159 ------
.../healthcheck/WindowAggregationType.java | 67 ---
.../apache/helix/healthcheck/package-info.java | 23 -
.../helix/manager/zk/CallbackHandler.java | 11 -
.../manager/zk/HelixConnectionAdaptor.java | 14 -
.../manager/zk/ParticipantManagerHelper.java | 11 -
.../apache/helix/manager/zk/ZKHelixAdmin.java | 141 ------
.../apache/helix/manager/zk/ZKHelixManager.java | 46 +-
.../helix/manager/zk/ZkCallbackHandler.java | 11 -
.../helix/manager/zk/ZkHelixConnection.java | 11 -
.../helix/manager/zk/ZkHelixController.java | 3 -
.../helix/manager/zk/ZkHelixParticipant.java | 19 -
.../java/org/apache/helix/model/HealthStat.java | 147 ------
.../monitoring/mbeans/ClusterAlertItem.java | 88 ----
.../mbeans/ClusterAlertItemMBean.java | 30 --
.../mbeans/ClusterAlertMBeanCollection.java | 275 ----------
.../org/apache/helix/tools/ClusterSetup.java | 52 --
.../org/apache/helix/tools/NewClusterSetup.java | 40 --
.../java/org/apache/helix/util/HelixUtil.java | 16 -
.../src/test/java/org/apache/helix/Mocks.java | 123 +----
...estParticipantHealthReportCollectorImpl.java | 78 ---
.../java/org/apache/helix/TestPerfCounters.java | 70 ---
.../TestPerformanceHealthReportProvider.java | 158 ------
.../org/apache/helix/alerts/TestAddAlerts.java | 114 -----
.../helix/alerts/TestAddPersistentStats.java | 210 --------
.../helix/alerts/TestAlertValidation.java | 166 -------
.../alerts/TestArrivingParticipantStats.java | 496 -------------------
.../helix/alerts/TestBaseStatsValidation.java | 169 -------
.../apache/helix/alerts/TestEvaluateAlerts.java | 388 ---------------
.../org/apache/helix/alerts/TestOperators.java | 325 ------------
.../org/apache/helix/alerts/TestStatsMatch.java | 103 ----
.../controller/stages/DummyClusterManager.java | 15 -
.../stages/TestParseInfoFromAlert.java | 56 ---
.../helix/healthcheck/TestAddDropAlert.java | 172 -------
.../helix/healthcheck/TestDummyAlerts.java | 148 ------
.../helix/healthcheck/TestExpandAlert.java | 186 -------
.../helix/healthcheck/TestSimpleAlert.java | 200 --------
.../healthcheck/TestSimpleWildcardAlert.java | 246 ---------
.../helix/healthcheck/TestStalenessAlert.java | 180 -------
.../helix/healthcheck/TestWildcardAlert.java | 296 -----------
.../helix/manager/zk/TestZkClusterManager.java | 3 -
.../MockEspressoHealthReportProvider.java | 81 ---
.../MockHealthReportParticipant.java | 248 ----------
.../TestClusterAlertItemMBeanCollection.java | 289 -----------
.../helix/participant/MockZKHelixManager.java | 15 -
94 files changed, 38 insertions(+), 10239 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/HealthStateChangeListener.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HealthStateChangeListener.java b/helix-core/src/main/java/org/apache/helix/HealthStateChangeListener.java
deleted file mode 100644
index 9202330..0000000
--- a/helix-core/src/main/java/org/apache/helix/HealthStateChangeListener.java
+++ /dev/null
@@ -1,39 +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.List;
-
-import org.apache.helix.model.HealthStat;
-
-/**
- * Interface to implement to listen for when a health status event is triggered.
- */
-public interface HealthStateChangeListener {
-
- /**
- * Invoked when health stats change
- * @param instanceName the instance where the health status changed
- * @param reports the health statuses
- * @param changeContext event properties and state
- */
- public void onHealthChange(String instanceName, List<HealthStat> reports,
- NotificationContext changeContext);
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixAdmin.java b/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
index dce3893..5337cdd 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
@@ -243,34 +243,6 @@ public interface HelixAdmin {
void dropResource(String clusterName, String resourceName);
/**
- * Add a statistics to a cluster
- * @param clusterName
- * @param statName
- */
- void addStat(String clusterName, String statName);
-
- /**
- * Add an alert to a cluster
- * @param clusterName
- * @param alertName
- */
- void addAlert(String clusterName, String alertName);
-
- /**
- * Drop statistics from a cluster
- * @param clusterName
- * @param statName
- */
- void dropStat(String clusterName, String statName);
-
- /**
- * Drop an alert from a cluster
- * @param clusterName
- * @param alertName
- */
- void dropAlert(String clusterName, String alertName);
-
- /**
* Get a list of state model definitions in a cluster
* @param clusterName
* @return
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/HelixConnection.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixConnection.java b/helix-core/src/main/java/org/apache/helix/HelixConnection.java
index 0e674d2..c56b01a 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixConnection.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixConnection.java
@@ -25,7 +25,6 @@ import org.apache.helix.api.accessor.ResourceAccessor;
import org.apache.helix.api.id.ClusterId;
import org.apache.helix.api.id.ControllerId;
import org.apache.helix.api.id.ParticipantId;
-import org.apache.helix.api.id.ResourceId;
import org.apache.helix.api.id.SessionId;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
import org.apache.helix.store.HelixPropertyStore;
@@ -222,15 +221,6 @@ public interface HelixConnection {
ClusterId clusterId, ParticipantId participantId, SessionId sessionId);
/**
- * add health state change listener
- * @see HealthStateChangeListener#onHealthChange(String, List, NotificationContext)
- * @param listener
- * @param instanceName
- */
- void addHealthStateChangeListener(HelixRole role, HealthStateChangeListener listener,
- ClusterId clusterId, ParticipantId participantId);
-
- /**
* add external view change listener
* @see ExternalViewChangeListener#onExternalViewChange(List, NotificationContext)
* @param listener
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/HelixManager.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixManager.java b/helix-core/src/main/java/org/apache/helix/HelixManager.java
index 7c34b00..6901715 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixManager.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixManager.java
@@ -22,7 +22,6 @@ package org.apache.helix;
import java.util.List;
import org.apache.helix.controller.GenericHelixController;
-import org.apache.helix.healthcheck.ParticipantHealthReportCollector;
import org.apache.helix.manager.zk.ZKHelixManager;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
import org.apache.helix.participant.HelixStateMachineEngine;
@@ -34,7 +33,11 @@ import org.apache.helix.store.zk.ZkHelixPropertyStore;
* Class that represents the Helix Agent.
* First class Object any process will interact with<br/>
* General flow <blockquote>
+<<<<<<< HEAD
*
+=======
+ *
+>>>>>>> 77cc651... [HELIX-395] Remove old Helix alert/stat modules
* <pre>
* manager = HelixManagerFactory.getZKHelixManager(
* clusterName, instanceName, ROLE, zkAddr);
@@ -50,7 +53,11 @@ import org.apache.helix.store.zk.ZkHelixPropertyStore;
* FINALIZE -> will be invoked when listener is removed or session expires
* manager.disconnect()
* </pre>
+<<<<<<< HEAD
*
+=======
+ *
+>>>>>>> 77cc651... [HELIX-395] Remove old Helix alert/stat modules
* </blockquote> Default implementations available
* @see HelixStateMachineEngine HelixStateMachineEngine for participant
* @see RoutingTableProvider RoutingTableProvider for spectator
@@ -137,14 +144,6 @@ public interface HelixManager {
String sessionId) throws Exception;
/**
- * @see HealthStateChangeListener#onHealthChange(String, List, NotificationContext)
- * @param listener
- * @param instanceName
- */
- void addHealthStateChangeListener(HealthStateChangeListener listener, String instanceName)
- throws Exception;
-
- /**
* @see ExternalViewChangeListener#onExternalViewChange(List, NotificationContext)
* @param listener
*/
@@ -237,13 +236,6 @@ public interface HelixManager {
ClusterMessagingService getMessagingService();
/**
- * Participant only component that periodically update participant health
- * report to cluster manager server.
- * @return ParticipantHealthReportCollector
- */
- ParticipantHealthReportCollector getHealthReportCollector();
-
- /**
* Get cluster manager instance type
* @return instance type (e.g. PARTICIPANT, CONTROLLER, SPECTATOR)
*/
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/PropertyKey.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/PropertyKey.java b/helix-core/src/main/java/org/apache/helix/PropertyKey.java
index 2af63a5..fb3e1d1 100644
--- a/helix-core/src/main/java/org/apache/helix/PropertyKey.java
+++ b/helix-core/src/main/java/org/apache/helix/PropertyKey.java
@@ -19,9 +19,6 @@ package org.apache.helix;
* under the License.
*/
-import static org.apache.helix.PropertyType.ALERTS;
-import static org.apache.helix.PropertyType.ALERT_HISTORY;
-import static org.apache.helix.PropertyType.ALERT_STATUS;
import static org.apache.helix.PropertyType.CLUSTER;
import static org.apache.helix.PropertyType.CONFIGS;
import static org.apache.helix.PropertyType.CONTEXT;
@@ -30,7 +27,6 @@ import static org.apache.helix.PropertyType.CURRENTSTATES;
import static org.apache.helix.PropertyType.ERRORS;
import static org.apache.helix.PropertyType.ERRORS_CONTROLLER;
import static org.apache.helix.PropertyType.EXTERNALVIEW;
-import static org.apache.helix.PropertyType.HEALTHREPORT;
import static org.apache.helix.PropertyType.HISTORY;
import static org.apache.helix.PropertyType.IDEALSTATES;
import static org.apache.helix.PropertyType.LEADER;
@@ -38,7 +34,6 @@ import static org.apache.helix.PropertyType.LIVEINSTANCES;
import static org.apache.helix.PropertyType.MESSAGES;
import static org.apache.helix.PropertyType.MESSAGES_CONTROLLER;
import static org.apache.helix.PropertyType.PAUSE;
-import static org.apache.helix.PropertyType.PERSISTENTSTATS;
import static org.apache.helix.PropertyType.PROPERTYSTORE;
import static org.apache.helix.PropertyType.RESOURCEASSIGNMENTS;
import static org.apache.helix.PropertyType.STATEMODELDEFS;
@@ -48,15 +43,11 @@ import static org.apache.helix.PropertyType.STATUSUPDATES_CONTROLLER;
import java.util.Arrays;
import org.apache.helix.controller.context.ControllerContextHolder;
-import org.apache.helix.model.AlertHistory;
-import org.apache.helix.model.AlertStatus;
-import org.apache.helix.model.Alerts;
import org.apache.helix.model.ClusterConfiguration;
import org.apache.helix.model.ClusterConstraints;
import org.apache.helix.model.CurrentState;
import org.apache.helix.model.Error;
import org.apache.helix.model.ExternalView;
-import org.apache.helix.model.HealthStat;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
import org.apache.helix.model.IdealState;
import org.apache.helix.model.InstanceConfig;
@@ -65,7 +56,6 @@ import org.apache.helix.model.LiveInstance;
import org.apache.helix.model.Message;
import org.apache.helix.model.PartitionConfiguration;
import org.apache.helix.model.PauseSignal;
-import org.apache.helix.model.PersistentStats;
import org.apache.helix.model.ResourceAssignment;
import org.apache.helix.model.ResourceConfiguration;
import org.apache.helix.model.StateModelDefinition;
@@ -666,57 +656,6 @@ public class PropertyKey {
}
/**
- * Get a property key associated with {@link PersistentStats}
- * @return {@link PropertyKey}
- */
- public PropertyKey persistantStat() {
- return new PropertyKey(PERSISTENTSTATS, PersistentStats.class, _clusterName);
- }
-
- /**
- * Get a property key associated with {@link Alerts}
- * @return {@link PropertyKey}
- */
- public PropertyKey alerts() {
- return new PropertyKey(ALERTS, Alerts.class, _clusterName);
- }
-
- /**
- * Get a property key associated with {@link AlertStatus}
- * @return {@link PropertyKey}
- */
- public PropertyKey alertStatus() {
- return new PropertyKey(ALERT_STATUS, AlertStatus.class, _clusterName);
- }
-
- /**
- * Get a property key associated with {@link AlertHistory}
- * @return {@link PropertyKey}
- */
- public PropertyKey alertHistory() {
- return new PropertyKey(ALERT_HISTORY, AlertHistory.class, _clusterName);
- }
-
- /**
- * Get a property key associated with a {@link HealthStat} for an instance
- * @param instanceName
- * @param id identifies the statistics
- * @return {@link PropertyKey}
- */
- public PropertyKey healthReport(String instanceName, String id) {
- return new PropertyKey(HEALTHREPORT, HealthStat.class, _clusterName, instanceName, id);
- }
-
- /**
- * Get a property key associated with {@link HealthStat}s for an instance
- * @param instanceName
- * @return {@link PropertyKey}
- */
- public PropertyKey healthReports(String instanceName) {
- return new PropertyKey(HEALTHREPORT, HealthStat.class, _clusterName, instanceName);
- }
-
- /**
* Get a propertykey associated with the root of the Helix property store
* @return {@link PropertyStore}
*/
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java b/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java
index d66e7d9..b56a23a 100644
--- a/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java
+++ b/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java
@@ -19,13 +19,10 @@ package org.apache.helix;
* under the License.
*/
-import static org.apache.helix.PropertyType.ALERTS;
-import static org.apache.helix.PropertyType.ALERT_STATUS;
import static org.apache.helix.PropertyType.CONFIGS;
import static org.apache.helix.PropertyType.CONTEXT;
import static org.apache.helix.PropertyType.CURRENTSTATES;
import static org.apache.helix.PropertyType.EXTERNALVIEW;
-import static org.apache.helix.PropertyType.HEALTHREPORT;
import static org.apache.helix.PropertyType.HISTORY;
import static org.apache.helix.PropertyType.IDEALSTATES;
import static org.apache.helix.PropertyType.LIVEINSTANCES;
@@ -42,11 +39,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.helix.controller.context.ControllerContextHolder;
-import org.apache.helix.model.AlertStatus;
-import org.apache.helix.model.Alerts;
import org.apache.helix.model.CurrentState;
import org.apache.helix.model.ExternalView;
-import org.apache.helix.model.HealthStat;
import org.apache.helix.model.IdealState;
import org.apache.helix.model.InstanceConfig;
import org.apache.helix.model.LeaderHistory;
@@ -78,9 +72,6 @@ public class PropertyPathConfig {
typeToClassMapping.put(CURRENTSTATES, CurrentState.class);
typeToClassMapping.put(STATUSUPDATES, StatusUpdate.class);
typeToClassMapping.put(HISTORY, LeaderHistory.class);
- typeToClassMapping.put(HEALTHREPORT, HealthStat.class);
- typeToClassMapping.put(ALERTS, Alerts.class);
- typeToClassMapping.put(ALERT_STATUS, AlertStatus.class);
typeToClassMapping.put(PAUSE, PauseSignal.class);
typeToClassMapping.put(RESOURCEASSIGNMENTS, ResourceAssignment.class);
typeToClassMapping.put(CONTEXT, ControllerContextHolder.class);
@@ -147,10 +138,6 @@ public class PropertyPathConfig {
addEntry(PropertyType.LEADER, 1, "/{clusterName}/CONTROLLER/LEADER");
addEntry(PropertyType.HISTORY, 1, "/{clusterName}/CONTROLLER/HISTORY");
addEntry(PropertyType.PAUSE, 1, "/{clusterName}/CONTROLLER/PAUSE");
- addEntry(PropertyType.PERSISTENTSTATS, 1, "/{clusterName}/CONTROLLER/PERSISTENTSTATS");
- addEntry(PropertyType.ALERTS, 1, "/{clusterName}/CONTROLLER/ALERTS");
- addEntry(PropertyType.ALERT_STATUS, 1, "/{clusterName}/CONTROLLER/ALERT_STATUS");
- addEntry(PropertyType.ALERT_HISTORY, 1, "/{clusterName}/CONTROLLER/ALERT_HISTORY");
addEntry(PropertyType.CONTEXT, 1, "/{clusterName}/CONTROLLER/CONTEXT");
addEntry(PropertyType.CONTEXT, 2, "/{clusterName}/CONTROLLER/CONTEXT/{contextId}");
// @formatter:on
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/PropertyType.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/PropertyType.java b/helix-core/src/main/java/org/apache/helix/PropertyType.java
index 579f454..fd3c5ef 100644
--- a/helix-core/src/main/java/org/apache/helix/PropertyType.java
+++ b/helix-core/src/main/java/org/apache/helix/PropertyType.java
@@ -61,10 +61,6 @@ public enum PropertyType {
MESSAGES_CONTROLLER(Type.CONTROLLER, true, false, true),
STATUSUPDATES_CONTROLLER(Type.CONTROLLER, true, true, true),
ERRORS_CONTROLLER(Type.CONTROLLER, true, true, true),
- PERSISTENTSTATS(Type.CONTROLLER, true, false, false, false),
- ALERTS(Type.CONTROLLER, true, false, false, false),
- ALERT_STATUS(Type.CONTROLLER, true, false, false, false),
- ALERT_HISTORY(Type.CONTROLLER, true, false, false, false),
CONTEXT(Type.CONTROLLER, true, false);
// @formatter:on
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/alerts/AccumulateAggregator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/AccumulateAggregator.java b/helix-core/src/main/java/org/apache/helix/alerts/AccumulateAggregator.java
deleted file mode 100644
index 2967f05..0000000
--- a/helix-core/src/main/java/org/apache/helix/alerts/AccumulateAggregator.java
+++ /dev/null
@@ -1,67 +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;
-
-public class AccumulateAggregator extends Aggregator {
-
- public AccumulateAggregator() {
- _numArgs = 0;
- }
-
- @Override
- public void merge(Tuple<String> currValTup, Tuple<String> newValTup, Tuple<String> currTimeTup,
- Tuple<String> newTimeTup, String... args) {
-
- double currVal = 0;
- double currTime = -1;
- double newVal;
- double newTime;
- double mergedVal;
- double mergedTime;
-
- if (currValTup == null || newValTup == null || currTimeTup == null || newTimeTup == null) {
- throw new HelixException("Tuples cannot be null");
- }
-
- // old tuples may be empty, indicating no value/time exist
- if (currValTup.size() > 0 && currTimeTup.size() > 0) {
- currVal = Double.parseDouble(currValTup.iterator().next());
- currTime = Double.parseDouble(currTimeTup.iterator().next());
- }
- newVal = Double.parseDouble(newValTup.iterator().next());
- newTime = Double.parseDouble(newTimeTup.iterator().next());
-
- if (newTime > currTime) { // if old doesn't exist, we end up here
- mergedVal = currVal + newVal; // if old doesn't exist, it has value "0"
- mergedTime = newTime;
- } else {
- mergedVal = currVal;
- mergedTime = currTime;
- }
-
- currValTup.clear();
- currValTup.add(Double.toString(mergedVal));
- currTimeTup.clear();
- currTimeTup.add(Double.toString(mergedTime));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/alerts/Aggregator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/Aggregator.java b/helix-core/src/main/java/org/apache/helix/alerts/Aggregator.java
deleted file mode 100644
index 65a4285..0000000
--- a/helix-core/src/main/java/org/apache/helix/alerts/Aggregator.java
+++ /dev/null
@@ -1,40 +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.
- */
-
-public abstract class Aggregator {
-
- int _numArgs;
-
- public Aggregator() {
-
- }
-
- /*
- * Take curr and new values. Update curr.
- */
- public abstract void merge(Tuple<String> currVal, Tuple<String> newVal, Tuple<String> currTime,
- Tuple<String> newTime, String... args);
-
- public int getRequiredNumArgs() {
- return _numArgs;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/alerts/Alert.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/Alert.java b/helix-core/src/main/java/org/apache/helix/alerts/Alert.java
deleted file mode 100644
index 17af060..0000000
--- a/helix-core/src/main/java/org/apache/helix/alerts/Alert.java
+++ /dev/null
@@ -1,52 +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.
- */
-
-public class Alert {
-
- String _name;
-
- String _expression;
- String _comparator;
- Tuple<String> _constant;
-
- public Alert(String name, String expression, String comparator, Tuple<String> constant) {
- _name = name;
- _expression = expression;
- _comparator = comparator;
- _constant = constant;
- }
-
- public String getName() {
- return _name;
- }
-
- public String getExpression() {
- return _expression;
- }
-
- public String getComparator() {
- return _comparator;
- }
-
- public Tuple<String> getConstant() {
- return _constant;
- }
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/alerts/AlertComparator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/AlertComparator.java b/helix-core/src/main/java/org/apache/helix/alerts/AlertComparator.java
deleted file mode 100644
index c0330c5..0000000
--- a/helix-core/src/main/java/org/apache/helix/alerts/AlertComparator.java
+++ /dev/null
@@ -1,30 +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.
- */
-
-public abstract class AlertComparator {
-
- public AlertComparator() {
-
- }
-
- public abstract boolean evaluate(Tuple<String> leftTup, Tuple<String> rightTup);
-
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/alerts/AlertParser.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/AlertParser.java b/helix-core/src/main/java/org/apache/helix/alerts/AlertParser.java
deleted file mode 100644
index ceb4d2e..0000000
--- a/helix-core/src/main/java/org/apache/helix/alerts/AlertParser.java
+++ /dev/null
@@ -1,138 +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.manager.zk.DefaultParticipantErrorMessageHandlerFactory.ActionOnError;
-import org.apache.log4j.Logger;
-
-public class AlertParser {
- private static Logger logger = Logger.getLogger(AlertParser.class);
-
- public static final String EXPRESSION_NAME = "EXP";
- public static final String COMPARATOR_NAME = "CMP";
- public static final String CONSTANT_NAME = "CON";
- public static final String ACTION_NAME = "ACTION";
-
- static Map<String, AlertComparator> comparatorMap = new HashMap<String, AlertComparator>();
-
- static {
-
- addComparatorEntry("GREATER", new GreaterAlertComparator());
- }
-
- private static void addComparatorEntry(String label, AlertComparator comp) {
- if (!comparatorMap.containsKey(label)) {
- comparatorMap.put(label, comp);
- }
- logger.info("Adding comparator: " + comp);
- }
-
- public static AlertComparator getComparator(String compName) {
- compName = compName.replaceAll("\\s+", ""); // remove white space
- if (!comparatorMap.containsKey(compName)) {
- throw new HelixException("Comparator type <" + compName + "> unknown");
- }
- return comparatorMap.get(compName);
- }
-
- public static String getComponent(String component, String alert) throws HelixException {
- // find EXP and keep going until paren are closed
- int expStartPos = alert.indexOf(component);
- if (expStartPos < 0) {
- throw new HelixException(alert + " does not contain component " + component);
- }
- expStartPos += (component.length() + 1); // advance length of string and one for open paren
- int expEndPos = expStartPos;
- int openParenCount = 1;
- while (openParenCount > 0) {
- if (alert.charAt(expEndPos) == '(') {
- openParenCount++;
- } else if (alert.charAt(expEndPos) == ')') {
- openParenCount--;
- }
- expEndPos++;
- }
- if (openParenCount != 0) {
- throw new HelixException(alert + " does not contain valid " + component + " component, "
- + "parentheses do not close");
- }
- // return what is in between paren
- return alert.substring(expStartPos, expEndPos - 1);
- }
-
- public static boolean validateAlert(String alert) throws HelixException {
- // TODO: decide if toUpperCase is going to cause problems with stuff like db name
- alert = alert.replaceAll("\\s+", ""); // remove white space
- String exp = getComponent(EXPRESSION_NAME, alert);
- String cmp = getComponent(COMPARATOR_NAME, alert);
- String val = getComponent(CONSTANT_NAME, alert);
- logger.debug("exp: " + exp);
- logger.debug("cmp: " + cmp);
- logger.debug("val: " + val);
-
- // separately validate each portion
- ExpressionParser.validateExpression(exp);
-
- // validate comparator
- if (!comparatorMap.containsKey(cmp.toUpperCase())) {
- throw new HelixException("Unknown comparator type " + cmp);
- }
- String actionValue = null;
- try {
- actionValue = AlertParser.getComponent(AlertParser.ACTION_NAME, alert);
- } catch (Exception e) {
- logger.info("No action specified in " + alert);
- }
-
- if (actionValue != null) {
- validateActionValue(actionValue);
- }
- // ValParser. Probably don't need this. Just make sure it's a valid tuple. But would also be
- // good
- // to validate that the tuple is same length as exp's output...maybe leave that as future todo
- // not sure we can really do much here though...anything can be in a tuple.
-
- // TODO: try to compare tuple width of CON against tuple width of agg type! Not a good idea,
- // what if
- // is not at full width yet, like with window
-
- // if all of this passes, then we can safely record the alert in zk. still need to implement zk
- // location
-
- return false;
- }
-
- public static void validateActionValue(String actionValue) {
- try {
- ActionOnError actionVal = ActionOnError.valueOf(actionValue);
- } catch (Exception e) {
- String validActions = "";
- for (ActionOnError action : ActionOnError.values()) {
- validActions = validActions + action + " ";
- }
- throw new HelixException("Unknown cmd type " + actionValue + ", valid types : "
- + validActions);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/alerts/AlertProcessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/AlertProcessor.java b/helix-core/src/main/java/org/apache/helix/alerts/AlertProcessor.java
deleted file mode 100644
index 26cabdf..0000000
--- a/helix-core/src/main/java/org/apache/helix/alerts/AlertProcessor.java
+++ /dev/null
@@ -1,308 +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.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.helix.HelixException;
-import org.apache.log4j.Logger;
-
-public class AlertProcessor {
- private static Logger logger = Logger.getLogger(AlertProcessor.class);
-
- private static final String bindingDelim = ",";
- public static final String noWildcardAlertKey = "*";
-
- StatsHolder _statsHolder;
-
- // AlertsHolder _alertsHolder;
-
- /*
- * public AlertProcessor(StatHealthReportProvider statProvider) {
- * }
- */
-
- public AlertProcessor(StatsHolder sh) {
- _statsHolder = sh;
- }
-
- public static Map<String, List<Tuple<String>>> initAlertStatTuples(Alert alert) {
- // get the stats out of the alert
- String[] alertStats = ExpressionParser.getBaseStats(alert.getExpression());
- // init a tuple list for each alert stat
- Map<String, List<Tuple<String>>> alertStatTuples = new HashMap<String, List<Tuple<String>>>();
- for (String currAlertStat : alertStats) {
- List<Tuple<String>> currList = new ArrayList<Tuple<String>>();
- alertStatTuples.put(currAlertStat, currList);
- }
- return alertStatTuples;
- }
-
- /*
- * //this function is all messed up!!! public static void
- * populateAlertStatTuples(Map<String,List<Tuple<String>>> tupleLists,
- * List<Stat> persistentStats) { Set<String> alertStatNames =
- * tupleLists.keySet(); for (Stat persistentStat : persistentStats) { //ignore
- * stats with wildcards, they don't have values...they are just there to catch
- * new actual stats if
- * (ExpressionParser.statContainsWildcards(persistentStat.getName())) {
- * continue; } Iterator<String> alertStatIter = alertStatNames.iterator();
- * while (alertStatIter.hasNext()) { String currAlertStat =
- * alertStatIter.next(); if
- * (ExpressionParser.isAlertStatExactMatch(currAlertStat,
- * persistentStat.getName()) ||
- * ExpressionParser.isAlertStatWildcardMatch(currAlertStat,
- * persistentStat.getName())) {
- * tupleLists.get(currAlertStat).add(persistentStat.getValue()); } } } }
- */
-
- public static String formAlertKey(ArrayList<String> bindings) {
- if (bindings.size() == 0) {
- return null;
- }
- StringBuilder alertKey = new StringBuilder();
- boolean emptyKey = true;
- for (String binding : bindings) {
- if (!emptyKey) {
- alertKey.append(bindingDelim);
- }
- alertKey.append(binding);
- emptyKey = false;
- }
- return alertKey.toString();
- }
-
- // XXX: major change here. return ArrayList of Stats instead of ArrayList of
- // Tuple<String>'s
- public static Map<String, ArrayList<Tuple<String>>> populateAlertStatTuples(String[] alertStats,
- List<Stat> persistentStats) {
- Map<String, ArrayList<Tuple<String>>> tupleSets =
- new HashMap<String, ArrayList<Tuple<String>>>();
-
- // check each persistentStat, alertStat pair
- for (Stat persistentStat : persistentStats) {
- // ignore stats with wildcards, they don't have values...they are just
- // there to catch new actual stats
- if (ExpressionParser.statContainsWildcards(persistentStat.getName())) {
- continue;
- }
- for (int i = 0; i < alertStats.length; i++) {
- String alertStat = alertStats[i];
- ArrayList<String> wildcardBindings = new ArrayList<String>();
- // if match, then proceed. If the match is wildcard, additionally fill
- // in the wildcard bindings
- if (ExpressionParser.isAlertStatExactMatch(alertStat, persistentStat.getName())
- || ExpressionParser.isAlertStatWildcardMatch(alertStat, persistentStat.getName(),
- wildcardBindings)) {
- String alertKey;
- if (wildcardBindings.size() == 0) {
- alertKey = noWildcardAlertKey;
- } else {
- alertKey = formAlertKey(wildcardBindings);
- }
- if (!tupleSets.containsKey(alertKey)) { // don't have an entry for alertKey yet, create
- // one
- ArrayList<Tuple<String>> tuples = new ArrayList<Tuple<String>>(alertStats.length);
- for (int j = 0; j < alertStats.length; j++) { // init all entries to null
- tuples.add(j, null);
- }
- tupleSets.put(alertKey, tuples); // add to map
- }
- tupleSets.get(alertKey).set(i, persistentStat.getValue());
- }
- }
- }
-
- // post-processing step to discard any rows with null vals...
- // TODO: decide if this is best thing to do with incomplete rows
- List<String> selectedKeysToRemove = new ArrayList<String>();
- for (String setKey : tupleSets.keySet()) {
- ArrayList<Tuple<String>> tupleSet = tupleSets.get(setKey);
- for (Tuple<String> tup : tupleSet) {
- if (tup == null) {
- selectedKeysToRemove.add(setKey);
- break; // move on to next setKey
- }
- }
- }
- for (String keyToRemove : selectedKeysToRemove) {
- tupleSets.remove(keyToRemove);
- }
-
- // convert above to a series of iterators
-
- return tupleSets;
- }
-
- public static List<Iterator<Tuple<String>>> convertTupleRowsToTupleColumns(
- Map<String, ArrayList<Tuple<String>>> tupleMap) {
- // input is a map of key -> list of tuples. each tuple list is same length
- // output should be a list of iterators. each column in input becomes
- // iterator in output
-
- ArrayList<ArrayList<Tuple<String>>> columns = new ArrayList<ArrayList<Tuple<String>>>();
- ArrayList<Iterator<Tuple<String>>> columnIters = new ArrayList<Iterator<Tuple<String>>>();
- for (String currStat : tupleMap.keySet()) {
- List<Tuple<String>> currSet = tupleMap.get(currStat);
- for (int i = 0; i < currSet.size(); i++) {
- if (columns.size() < (i + 1)) {
- ArrayList<Tuple<String>> col = new ArrayList<Tuple<String>>();
- columns.add(col);
- }
- columns.get(i).add(currSet.get(i));
- }
- }
- for (ArrayList<Tuple<String>> al : columns) {
- columnIters.add(al.iterator());
- }
- return columnIters;
-
- }
-
- public static Iterator<Tuple<String>> executeOperatorPipeline(
- List<Iterator<Tuple<String>>> tupleIters, String[] operators) {
- List<Iterator<Tuple<String>>> nextIters = tupleIters;
- if (operators != null) {
- for (String opName : operators) {
- Operator op = ExpressionParser.getOperator(opName);
- nextIters = op.execute(nextIters);
- }
- }
-
- if (nextIters.size() != 1) {
- throw new HelixException("operator pipeline produced " + nextIters.size()
- + " tuple sets instead of exactly 1");
- }
-
- return nextIters.get(0);
- }
-
- /*
- * TODO: consider returning actual values, rather than bools. Could just
- * return the triggered alerts
- */
- public static ArrayList<AlertValueAndStatus> executeComparator(Iterator<Tuple<String>> tuples,
- String comparatorName, Tuple<String> constant) {
- ArrayList<AlertValueAndStatus> results = new ArrayList<AlertValueAndStatus>();
- AlertComparator cmp = AlertParser.getComparator(comparatorName);
-
- while (tuples.hasNext()) {
- Tuple<String> currTup = tuples.next();
- boolean fired = cmp.evaluate(currTup, constant);
- results.add(new AlertValueAndStatus(currTup, fired));
- // results.add(cmp.evaluate(currTup, constant));
- }
- return results;
-
- }
-
- /*
- * public static void executeAlert(Alert alert, List<Stat> stats) { //init
- * tuple lists and populate them Map<String,List<Tuple<String>>>
- * alertStatTupleSets = initAlertStatTuples(alert);
- * populateAlertStatTuples(alertStatTupleSets, stats); //TODO: not sure I am
- * being careful enough with sticking stats that match each other in this
- * list! //convert to operator friendly format List<Iterator<Tuple<String>>>
- * tupleIters = convertTupleSetsToTupleIterators(alertStatTupleSets); //get
- * the operators String[] operators =
- * ExpressionParser.getOperators(alert.getExpression()); //do operator
- * pipeline Iterator<Tuple<String>> opResultTuples =
- * executeOperatorPipeline(tupleIters, operators); //execute comparator for
- * tuple list ArrayList<Boolean> evalResults =
- * executeComparator(opResultTuples, alert.getComparator(),
- * alert.getConstant());
- * //TODO: convey this back to execute all
- * }
- */
-
- public static HashMap<String, AlertValueAndStatus> generateResultMap(
- Set<String> alertStatBindings, ArrayList<AlertValueAndStatus> evalResults) {
- HashMap<String, AlertValueAndStatus> resultMap = new HashMap<String, AlertValueAndStatus>();
- Iterator<String> bindingIter = alertStatBindings.iterator();
- Iterator<AlertValueAndStatus> resultIter = evalResults.iterator();
- if (alertStatBindings.size() != evalResults.size()) {
- // can't match up alerts bindings to results
- while (resultIter.hasNext()) {
- resultMap.put(noWildcardAlertKey, resultIter.next());
- }
- } else {
- // they do match up
- while (resultIter.hasNext()) {
- resultMap.put(bindingIter.next(), resultIter.next());
- }
- }
- return resultMap;
- }
-
- public static HashMap<String, AlertValueAndStatus> executeAlert(Alert alert,
- List<Stat> persistedStats) {
- // init tuple lists and populate them
- // Map<String,List<Tuple<String>>> alertStatTupleSets =
- // initAlertStatTuples(alert);
-
- String[] alertStats = ExpressionParser.getBaseStats(alert.getExpression());
-
- Map<String, ArrayList<Tuple<String>>> alertsToTupleRows =
- populateAlertStatTuples(alertStats, persistedStats);
-
- if (alertsToTupleRows.size() == 0) {
- return null;
- }
- // convert to operator friendly format
- List<Iterator<Tuple<String>>> tupleIters = convertTupleRowsToTupleColumns(alertsToTupleRows);
- // get the operators
- String[] operators = ExpressionParser.getOperators(alert.getExpression());
- // do operator pipeline
- Iterator<Tuple<String>> opResultTuples = executeOperatorPipeline(tupleIters, operators);
- // execute comparator for tuple list
- ArrayList<AlertValueAndStatus> evalResults =
- executeComparator(opResultTuples, alert.getComparator(), alert.getConstant());
-
- // stitch alert bindings back together with final result
- // XXX: there is a non-critical bug here. if we have an aggregating
- // operator, but that operator only takes one input,
- // we bind to original wildcard binding, instead of to "*"
-
- HashMap<String, AlertValueAndStatus> alertBindingsToResult =
- generateResultMap(alertsToTupleRows.keySet(), evalResults);
-
- return alertBindingsToResult;
-
- }
-
- public static Map<String, Map<String, AlertValueAndStatus>> executeAllAlerts(List<Alert> alerts,
- List<Stat> stats) {
- Map<String, Map<String, AlertValueAndStatus>> alertsResults =
- new HashMap<String, Map<String, AlertValueAndStatus>>();
-
- for (Alert alert : alerts) {
- HashMap<String, AlertValueAndStatus> result = executeAlert(alert, stats);
- // TODO: decide if sticking null results in here is ok
- alertsResults.put(alert.getName(), result);
- }
-
- return alertsResults;
- }
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/alerts/AlertValueAndStatus.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/AlertValueAndStatus.java b/helix-core/src/main/java/org/apache/helix/alerts/AlertValueAndStatus.java
deleted file mode 100644
index 1582312..0000000
--- a/helix-core/src/main/java/org/apache/helix/alerts/AlertValueAndStatus.java
+++ /dev/null
@@ -1,42 +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.
- */
-
-public class AlertValueAndStatus {
- public final static String VALUE_NAME = "value";
- public final static String FIRED_NAME = "fired";
-
- private Tuple<String> value;
- private boolean fired;
-
- public AlertValueAndStatus(Tuple<String> value, boolean fired) {
- this.value = value;
- this.fired = fired;
- }
-
- public Tuple<String> getValue() {
- return value;
- }
-
- public boolean isFired() {
- return fired;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/alerts/AlertsHolder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/AlertsHolder.java b/helix-core/src/main/java/org/apache/helix/alerts/AlertsHolder.java
deleted file mode 100644
index 80f8561..0000000
--- a/helix-core/src/main/java/org/apache/helix/alerts/AlertsHolder.java
+++ /dev/null
@@ -1,261 +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.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixException;
-import org.apache.helix.HelixManager;
-import org.apache.helix.PropertyKey;
-import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.controller.stages.HealthDataCache;
-import org.apache.helix.model.AlertStatus;
-import org.apache.helix.model.Alerts;
-import org.apache.log4j.Logger;
-
-public class AlertsHolder {
-
- private static final Logger logger = Logger.getLogger(AlertsHolder.class.getName());
-
- HelixDataAccessor _accessor;
- HealthDataCache _cache;
- Map<String, Map<String, String>> _alertsMap; // not sure if map or set yet
- Map<String, Map<String, String>> _alertStatusMap;
- // Alerts _alerts;
- HashSet<String> alerts;
- StatsHolder _statsHolder;
-
- private final HelixManager _manager;
-
- private Builder _keyBuilder;
-
- public AlertsHolder(HelixManager manager, HealthDataCache cache) {
- this(manager, cache, new StatsHolder(manager, cache));
- }
-
- public AlertsHolder(HelixManager manager, HealthDataCache cache, StatsHolder statHolder) {
- _manager = manager;
- _accessor = manager.getHelixDataAccessor();
- _cache = cache;
- _statsHolder = statHolder;
- _keyBuilder = new PropertyKey.Builder(_manager.getClusterName());
- updateCache(_cache);
- }
-
- public void refreshAlerts() {
- _cache.refresh(_accessor);
- updateCache(_cache);
-
- /*
- * _alertsMap = _cache.getAlerts();
- * //TODO: confirm this a good place to init the _statMap when null
- * if (_alertsMap == null) {
- * _alertsMap = new HashMap<String, Map<String,String>>();
- * }\
- */
- }
-
- public void refreshAlertStatus() {
- AlertStatus alertStatusRecord = _cache.getAlertStatus();
- if (alertStatusRecord != null) {
- _alertStatusMap = alertStatusRecord.getMapFields();
- } else {
- _alertStatusMap = new HashMap<String, Map<String, String>>();
- }
- }
-
- public void persistAlerts() {
- // XXX: Am I using _accessor too directly here?
-
- Alerts alerts = _accessor.getProperty(_keyBuilder.alerts());
- if (alerts == null) {
- alerts = new Alerts(Alerts.nodeName); // TODO: fix naming of this record, if it matters
- }
- alerts.getRecord().setMapFields(_alertsMap);
- boolean retVal = _accessor.setProperty(_keyBuilder.alerts(), alerts);
- logger.debug("persistAlerts retVal: " + retVal);
- }
-
- public void persistAlertStatus() {
- // XXX: Am I using _accessor too directly here?
- AlertStatus alertStatus = _accessor.getProperty(_keyBuilder.alertStatus());
- if (alertStatus == null) {
- alertStatus = new AlertStatus(AlertStatus.nodeName); // TODO: fix naming of this record, if it
- // matters
- }
- alertStatus.getRecord().setMapFields(_alertStatusMap);
- boolean retVal = _accessor.setProperty(_keyBuilder.alertStatus(), alertStatus);
- logger.debug("persistAlerts retVal: " + retVal);
- }
-
- // read alerts from cm state
- private void readExistingAlerts() {
-
- }
-
- public void addAlert(String alert) throws HelixException {
- alert = alert.replaceAll("\\s+", ""); // remove white space
- AlertParser.validateAlert(alert);
- refreshAlerts();
- // stick the 3 alert fields in map
- Map<String, String> alertFields = new HashMap<String, String>();
- alertFields.put(AlertParser.EXPRESSION_NAME,
- AlertParser.getComponent(AlertParser.EXPRESSION_NAME, alert));
- alertFields.put(AlertParser.COMPARATOR_NAME,
- AlertParser.getComponent(AlertParser.COMPARATOR_NAME, alert));
- alertFields.put(AlertParser.CONSTANT_NAME,
- AlertParser.getComponent(AlertParser.CONSTANT_NAME, alert));
- try {
- alertFields.put(AlertParser.ACTION_NAME,
- AlertParser.getComponent(AlertParser.ACTION_NAME, alert));
- } catch (Exception e) {
- logger.info("No action specified in " + alert);
- }
- // store the expression as stat
- _statsHolder.addStat(alertFields.get(AlertParser.EXPRESSION_NAME));
- _statsHolder.persistStats();
-
- // naming the alert with the full name
- _alertsMap.put(alert, alertFields);
- persistAlerts();
- }
-
- /*
- * Add a set of alert statuses to ZK
- */
- public void addAlertStatusSet(Map<String, Map<String, AlertValueAndStatus>> statusSet)
- throws HelixException {
- if (_alertStatusMap == null) {
- _alertStatusMap = new HashMap<String, Map<String, String>>();
- }
- _alertStatusMap.clear(); // clear map. all alerts overwrite old alerts
- for (String alert : statusSet.keySet()) {
- Map<String, AlertValueAndStatus> currStatus = statusSet.get(alert);
- if (currStatus != null) {
- addAlertStatus(alert, currStatus);
- }
- }
-
- AlertStatus alertStatus = _accessor.getProperty(_keyBuilder.alertStatus());
- int alertStatusSize = 0;
- if (alertStatus != null) {
- alertStatusSize = alertStatus.getMapFields().size();
- }
- // no need to persist alerts if there are none to persist and none are currently persisted
- if (_alertStatusMap.size() > 0 || alertStatusSize > 0) {
- persistAlertStatus(); // save statuses in zk
- }
- }
-
- private void addAlertStatus(String parentAlertKey, Map<String, AlertValueAndStatus> alertStatus)
- throws HelixException {
- // _alertStatusMap = new HashMap<String,Map<String,String>>();
- for (String alertName : alertStatus.keySet()) {
- String mapAlertKey;
- mapAlertKey = parentAlertKey;
- if (!alertName.equals(ExpressionParser.wildcardChar)) {
- mapAlertKey = mapAlertKey + " : (" + alertName + ")";
- }
- AlertValueAndStatus vs = alertStatus.get(alertName);
- Map<String, String> alertFields = new HashMap<String, String>();
- alertFields.put(AlertValueAndStatus.VALUE_NAME, vs.getValue().toString());
- alertFields.put(AlertValueAndStatus.FIRED_NAME, String.valueOf(vs.isFired()));
- _alertStatusMap.put(mapAlertKey, alertFields);
- }
- }
-
- public AlertValueAndStatus getAlertValueAndStatus(String alertName) {
- Map<String, String> alertFields = _alertStatusMap.get(alertName);
- String val = alertFields.get(AlertValueAndStatus.VALUE_NAME);
- Tuple<String> valTup = new Tuple<String>();
- valTup.add(val);
- boolean fired = Boolean.valueOf(alertFields.get(AlertValueAndStatus.FIRED_NAME));
- AlertValueAndStatus vs = new AlertValueAndStatus(valTup, fired);
- return vs;
- }
-
- public static void parseAlert(String alert, StringBuilder statsName,
- Map<String, String> alertFields) throws HelixException {
- alert = alert.replaceAll("\\s+", ""); // remove white space
- AlertParser.validateAlert(alert);
- // alertFields = new HashMap<String,String>();
- alertFields.put(AlertParser.EXPRESSION_NAME,
- AlertParser.getComponent(AlertParser.EXPRESSION_NAME, alert));
- alertFields.put(AlertParser.COMPARATOR_NAME,
- AlertParser.getComponent(AlertParser.COMPARATOR_NAME, alert));
- alertFields.put(AlertParser.CONSTANT_NAME,
- AlertParser.getComponent(AlertParser.CONSTANT_NAME, alert));
- try {
- alertFields.put(AlertParser.ACTION_NAME,
- AlertParser.getComponent(AlertParser.ACTION_NAME, alert));
- } catch (Exception e) {
- logger.info("No action specified in " + alert);
- }
- statsName.append(alertFields.get(AlertParser.EXPRESSION_NAME));
- }
-
- /*
- * public void evaluateAllAlerts()
- * {
- * for (String alert : _alertsMap.keySet()) {
- * Map<String,String> alertFields = _alertsMap.get(alert);
- * String exp = alertFields.get(AlertParser.EXPRESSION_NAME);
- * String comp = alertFields.get(AlertParser.COMPARATOR_NAME);
- * String con = alertFields.get(AlertParser.CONSTANT_NAME);
- * //TODO: test the fields for null and fail if needed
- * AlertProcessor.execute(exp, comp, con, sh);
- * }
- * }
- */
-
- public List<Alert> getAlertList() {
- List<Alert> alerts = new LinkedList<Alert>();
- for (String alert : _alertsMap.keySet()) {
- Map<String, String> alertFields = _alertsMap.get(alert);
- String exp = alertFields.get(AlertParser.EXPRESSION_NAME);
- String comp = alertFields.get(AlertParser.COMPARATOR_NAME);
- Tuple<String> con = Tuple.fromString(alertFields.get(AlertParser.CONSTANT_NAME));
- // TODO: test the fields for null and fail if needed
-
- Alert a = new Alert(alert, exp, comp, con);
- alerts.add(a);
- }
- return alerts;
- }
-
- public void updateCache(HealthDataCache cache) {
- _cache = cache;
- Alerts alertsRecord = _cache.getAlerts();
- if (alertsRecord != null) {
- _alertsMap = alertsRecord.getMapFields();
- } else {
- _alertsMap = new HashMap<String, Map<String, String>>();
- }
- }
-
- public Map<String, Map<String, String>> getAlertsMap() {
- return _alertsMap;
- }
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/alerts/DecayAggregator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/DecayAggregator.java b/helix-core/src/main/java/org/apache/helix/alerts/DecayAggregator.java
deleted file mode 100644
index fd9f2a6..0000000
--- a/helix-core/src/main/java/org/apache/helix/alerts/DecayAggregator.java
+++ /dev/null
@@ -1,76 +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;
-
-public class DecayAggregator extends Aggregator {
-
- double _decayWeight;
-
- public DecayAggregator(double weight) {
- _decayWeight = weight;
- }
-
- public DecayAggregator() {
- _numArgs = 1;
- }
-
- @Override
- public void merge(Tuple<String> currValTup, Tuple<String> newValTup, Tuple<String> currTimeTup,
- Tuple<String> newTimeTup, String... args) {
-
- _decayWeight = Double.parseDouble(args[0]);
-
- double currVal = 0;
- double currTime = -1;
- double newVal;
- double newTime;
- double mergedVal;
- double mergedTime;
-
- if (currValTup == null || newValTup == null || currTimeTup == null || newTimeTup == null) {
- throw new HelixException("Tuples cannot be null");
- }
-
- // old tuples may be empty, indicating no value/time exist
- if (currValTup.size() > 0 && currTimeTup.size() > 0) {
- currVal = Double.parseDouble(currValTup.iterator().next());
- currTime = Double.parseDouble(currTimeTup.iterator().next());
- }
- newVal = Double.parseDouble(newValTup.iterator().next());
- newTime = Double.parseDouble(newTimeTup.iterator().next());
-
- if (newTime > currTime) { // if old doesn't exist, we end up here
- mergedVal = (1 - _decayWeight) * currVal + _decayWeight * newVal; // if old doesn't exist, it
- // has value "0"
- mergedTime = newTime;
- } else {
- mergedVal = currVal;
- mergedTime = currTime;
- }
-
- currValTup.clear();
- currValTup.add(Double.toString(mergedVal));
- currTimeTup.clear();
- currTimeTup.add(Double.toString(mergedTime));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/alerts/DivideOperator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/DivideOperator.java b/helix-core/src/main/java/org/apache/helix/alerts/DivideOperator.java
deleted file mode 100644
index 122d4c1..0000000
--- a/helix-core/src/main/java/org/apache/helix/alerts/DivideOperator.java
+++ /dev/null
@@ -1,40 +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.Iterator;
-import java.util.List;
-
-public class DivideOperator extends Operator {
-
- public DivideOperator() {
- minInputTupleLists = 2;
- maxInputTupleLists = 2;
- inputOutputTupleListsCountsEqual = false;
- numOutputTupleLists = 1;
- }
-
- @Override
- public List<Iterator<Tuple<String>>> execute(List<Iterator<Tuple<String>>> input) {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/alerts/ExpandOperator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/ExpandOperator.java b/helix-core/src/main/java/org/apache/helix/alerts/ExpandOperator.java
deleted file mode 100644
index ecd4791..0000000
--- a/helix-core/src/main/java/org/apache/helix/alerts/ExpandOperator.java
+++ /dev/null
@@ -1,39 +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.Iterator;
-import java.util.List;
-
-public class ExpandOperator extends Operator {
-
- public ExpandOperator() {
- minInputTupleLists = 1;
- maxInputTupleLists = Integer.MAX_VALUE;
- inputOutputTupleListsCountsEqual = true;
- }
-
- @Override
- public List<Iterator<Tuple<String>>> execute(List<Iterator<Tuple<String>>> input) {
- // TODO: confirm this is a no-op operator
- return input;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/helix/blob/38b43965/helix-core/src/main/java/org/apache/helix/alerts/ExpressionOperatorType.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/ExpressionOperatorType.java b/helix-core/src/main/java/org/apache/helix/alerts/ExpressionOperatorType.java
deleted file mode 100644
index 6c4f913..0000000
--- a/helix-core/src/main/java/org/apache/helix/alerts/ExpressionOperatorType.java
+++ /dev/null
@@ -1,44 +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.
- */
-
-public enum ExpressionOperatorType {
- // each
- EACH(true),
- // standard math
- SUM(false),
- MULTIPLY(false),
- SUBTRACT(false),
- DIVIDE(false),
- // aggregation types
- ACCUMULATE(true),
- DECAY(false),
- WINDOW(false);
-
- boolean isBase;
-
- private ExpressionOperatorType(boolean isBase) {
- this.isBase = isBase;
- }
-
- boolean isBaseOp() {
- return isBase;
- }
-}