ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-19257 BE changes needed for SNMP Ambari MIB support (dsen)
Date Fri, 23 Dec 2016 16:55:22 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 50c770ab9 -> c4d8f2dc8


AMBARI-19257 BE changes needed for SNMP Ambari MIB support (dsen)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c4d8f2dc
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c4d8f2dc
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c4d8f2dc

Branch: refs/heads/trunk
Commit: c4d8f2dc8d28fe6eb42b3bfa102383e089a502f3
Parents: 50c770a
Author: Dmytro Sen <dsen@apache.org>
Authored: Fri Dec 23 18:55:17 2016 +0200
Committer: Dmytro Sen <dsen@apache.org>
Committed: Fri Dec 23 18:55:17 2016 +0200

----------------------------------------------------------------------
 .../dispatchers/AmbariSNMPDispatcher.java       |  5 +++--
 .../apache/ambari/server/state/AlertState.java  | 20 +++++++++++++++-----
 .../dispatchers/AmbariSNMPDispatcherTest.java   |  8 ++++----
 3 files changed, 22 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c4d8f2dc/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcher.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcher.java
b/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcher.java
index 62ef31a..86ef07c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcher.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcher.java
@@ -59,6 +59,7 @@ public class AmbariSNMPDispatcher extends SNMPDispatcher {
 
     public static final String BASE_AMBARI_OID = "1.3.6.1.4.1.18060.16";
     public static final String APACHE_AMBARI_TRAPS_OID = BASE_AMBARI_OID + ".0";
+    public static final String AMBARI_ALERT_TRAP_OID = APACHE_AMBARI_TRAPS_OID + ".1";
     public static final String AMBARI_ALERTS_OID = BASE_AMBARI_OID + ".1";
     public static final String AMBARI_ALERT_TABLE_OID = AMBARI_ALERTS_OID + ".1";
     public static final String AMBARI_ALERT_ENTRY_OID = AMBARI_ALERT_TABLE_OID + ".1";
@@ -111,7 +112,7 @@ public class AmbariSNMPDispatcher extends SNMPDispatcher {
 
         pdu.setType(snmpVersion.getTrapType());
         // Set trap oid for PDU
-        pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, new OID(APACHE_AMBARI_TRAPS_OID)));
+        pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, new OID(AMBARI_ALERT_TRAP_OID)));
         // Set notification body and subject for PDU objects with identifiers specified in
dispatch properties.
         AlertNoticeDispatchService.AlertInfo alertInfo = alertNotification.getAlertInfo();
         addVariableBindingCheckForNull(pdu, AMBARI_ALERT_DEFINITION_ID_OID, alertInfo.getAlertDefinitionId());
@@ -119,7 +120,7 @@ public class AmbariSNMPDispatcher extends SNMPDispatcher {
         addVariableBindingCheckForNull(pdu, AMBARI_ALERT_DEFINITION_HASH_OID, alertInfo.getAlertDefinitionHash());
         addVariableBindingCheckForNull(pdu, AMBARI_ALERT_NAME_OID, alertInfo.getAlertName());
         addVariableBindingCheckForNull(pdu, AMBARI_ALERT_TEXT_OID, alertInfo.getAlertText());
-        addVariableBindingCheckForNull(pdu, AMBARI_ALERT_STATE_OID, alertInfo.getAlertState());
+        addVariableBindingCheckForNull(pdu, AMBARI_ALERT_STATE_OID, alertInfo.getAlertState().getIntValue());
         addVariableBindingCheckForNull(pdu, AMBARI_ALERT_HOST_NAME_OID, alertInfo.getHostName());
         addVariableBindingCheckForNull(pdu, AMBARI_ALERT_SERVICE_NAME_OID, alertInfo.getServiceName());
         addVariableBindingCheckForNull(pdu, AMBARI_ALERT_COMPONENT_NAME_OID, alertInfo.getComponentName());

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4d8f2dc/ambari-server/src/main/java/org/apache/ambari/server/state/AlertState.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/AlertState.java b/ambari-server/src/main/java/org/apache/ambari/server/state/AlertState.java
index 3bb70e2..8e04eb1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/AlertState.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/AlertState.java
@@ -24,27 +24,37 @@ public enum AlertState {
   /**
    * Alert does not need to be distributed.  Normal Operation.
    */
-  OK,
+  OK(0),
 
   /**
    * Alert indicates there may be an issue.  The component may be operating
    * normally but may be in danger of becoming <code>CRITICAL</code>.
    */
-  WARNING,
+  WARNING(2),
 
   /**
    * Indicates there is a critical situation that needs to be addressed.
    */
-  CRITICAL,
+  CRITICAL(3),
 
   /**
    * The state of the alert is not known.
    */
-  UNKNOWN,
+  UNKNOWN(1),
 
   /**
    * Indicates that the state of the alert should be discarded, but the alert
    * timestamps should be updated so that it is not considered stale.
    */
-  SKIPPED;
+  SKIPPED(4);
+
+  private final int intValue;
+
+  public int getIntValue() {
+    return intValue;
+  }
+
+  AlertState(int i) {
+    this.intValue = i;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c4d8f2dc/ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcherTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcherTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcherTest.java
index 6cf4990..3561730 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcherTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/notifications/dispatchers/AmbariSNMPDispatcherTest.java
@@ -253,12 +253,12 @@ public class AmbariSNMPDispatcherTest {
             variableBindings.put(variableBinding.getOid().toString(), variableBinding);
         }
         assertEquals(10, variableBindings.size());
-        assertEquals(AmbariSNMPDispatcher.APACHE_AMBARI_TRAPS_OID, variableBindings.get(SnmpConstants.snmpTrapOID.toString()).toValueString());
+        assertEquals(AmbariSNMPDispatcher.AMBARI_ALERT_TRAP_OID, variableBindings.get(SnmpConstants.snmpTrapOID.toString()).toValueString());
         assertEquals(String.valueOf(DEFINITION_ID), variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_DEFINITION_ID_OID).toValueString());
         assertEquals(DEFINITION_NAME, variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_DEFINITION_NAME_OID).toValueString());
         assertEquals(ALERT_LABEL, variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_NAME_OID).toValueString());
         assertEquals(ALERT_TEXT, variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_TEXT_OID).toValueString());
-        assertEquals(String.valueOf(ALERT_STATE), variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_STATE_OID).toValueString());
+        assertEquals(String.valueOf(ALERT_STATE.getIntValue()), variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_STATE_OID).toValueString());
         assertEquals(ALERT_HOSTNAME, variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_HOST_NAME_OID).toValueString());
         assertEquals(ALERT_SERVICE_NAME, variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_SERVICE_NAME_OID).toValueString());
         assertEquals(ALERT_COMPONENT_NAME, variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_COMPONENT_NAME_OID).toValueString());
@@ -293,12 +293,12 @@ public class AmbariSNMPDispatcherTest {
         }
 
         assertEquals(10, variableBindings.size());
-        assertEquals(AmbariSNMPDispatcher.APACHE_AMBARI_TRAPS_OID, variableBindings.get(SnmpConstants.snmpTrapOID.toString()).toValueString());
+        assertEquals(AmbariSNMPDispatcher.AMBARI_ALERT_TRAP_OID, variableBindings.get(SnmpConstants.snmpTrapOID.toString()).toValueString());
         assertEquals(String.valueOf(DEFINITION_ID), variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_DEFINITION_ID_OID).toValueString());
         assertEquals(DEFINITION_NAME, variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_DEFINITION_NAME_OID).toValueString());
         assertEquals(ALERT_LABEL, variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_NAME_OID).toValueString());
         assertEquals(ALERT_TEXT, variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_TEXT_OID).toValueString());
-        assertEquals(String.valueOf(ALERT_STATE), variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_STATE_OID).toValueString());
+        assertEquals(String.valueOf(ALERT_STATE.getIntValue()), variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_STATE_OID).toValueString());
         assertEquals(ALERT_HOSTNAME, variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_HOST_NAME_OID).toValueString());
         assertEquals(ALERT_SERVICE_NAME, variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_SERVICE_NAME_OID).toValueString());
         assertEquals(ALERT_COMPONENT_NAME, variableBindings.get(AmbariSNMPDispatcher.AMBARI_ALERT_COMPONENT_NAME_OID).toValueString());


Mime
View raw message