alarm-go rmr init cleaned
[ric-plt/alarm-go.git] / alarm / types.go
index ffe5d39..5954c73 100755 (executable)
@@ -21,6 +21,8 @@
 package alarm
 
 import (
+       "fmt"
+       "os"
        "sync"
        "unsafe"
 )
@@ -47,8 +49,8 @@ type Alarm struct {
        ApplicationId     string   `json:"applicationId"`
        SpecificProblem   int      `json:"specificProblem"`
        PerceivedSeverity Severity `json:"perceivedSeverity"`
-       AdditionalInfo    string   `json:"additionalInfo"`
        IdentifyingInfo   string   `json:"identifyingInfo"`
+       AdditionalInfo    string   `json:"additionalInfo"`
 }
 
 // Alarm actions
@@ -67,13 +69,20 @@ type AlarmMessage struct {
        AlarmTime int64
 }
 
+type AlarmConfigParams struct {
+       MaxActiveAlarms int `json:"maxactivealarms"`
+       MaxAlarmHistory int `json:"maxalarmhistory"`
+}
+
 // RICAlarm is an alarm instance
 type RICAlarm struct {
-       moId     string
-       appId    string
-       rmrCtx   unsafe.Pointer
-       rmrReady bool
-       mutex    sync.Mutex
+       moId        string
+       appId       string
+       managerUrl  string
+       rmrEndpoint string
+       rmrCtx      unsafe.Pointer
+       rmrReady    bool
+       mutex       sync.Mutex
 }
 
 const (
@@ -83,42 +92,26 @@ const (
 
 // Temp alarm constants & definitions
 const (
-       RIC_RT_DISTRIBUTION_FAILED     int = 8004
-       TCP_CONNECTIVITY_LOST_TO_DBAAS int = 8005
-       E2_CONNECTIVITY_LOST_TO_GNODEB int = 8006
-       E2_CONNECTIVITY_LOST_TO_ENODEB int = 8007
+       E2_CONNECTION_PROBLEM              int = 72004
+       ACTIVE_ALARM_EXCEED_MAX_THRESHOLD  int = 72007
+       ALARM_HISTORY_EXCEED_MAX_THRESHOLD int = 72008
 )
 
 type AlarmDefinition struct {
-       AlarmId               int
-       AlarmText             string
-       EventType             string
-       OperationInstructions string
+       AlarmId               int    `json:"alarmId"`
+       AlarmText             string `json:"alarmText"`
+       EventType             string `json:"eventType"`
+       OperationInstructions string `json:"operationInstructions"`
+       RaiseDelay            int    `json:"raiseDelay"`
+       ClearDelay            int    `json:"clearDelay"`
+       TimeToLive            int    `json:"timeToLive"`
 }
 
-var RICAlarmDefinitions = map[int]AlarmDefinition{
-       RIC_RT_DISTRIBUTION_FAILED: AlarmDefinition{
-               AlarmId:               RIC_RT_DISTRIBUTION_FAILED,
-               AlarmText:             "RIC ROUTING TABLE DISTRIBUTION FAILED",
-               EventType:             "Processing error",
-               OperationInstructions: "Not defined",
-       },
-       TCP_CONNECTIVITY_LOST_TO_DBAAS: AlarmDefinition{
-               AlarmId:               TCP_CONNECTIVITY_LOST_TO_DBAAS,
-               AlarmText:             "TCP CONNECTIVITY LOST TO DBAAS",
-               EventType:             "Communication error",
-               OperationInstructions: "Not defined",
-       },
-       E2_CONNECTIVITY_LOST_TO_GNODEB: AlarmDefinition{
-               AlarmId:               E2_CONNECTIVITY_LOST_TO_GNODEB,
-               AlarmText:             "E2 CONNECTIVITY LOST TO G-NODEB",
-               EventType:             "Communication error",
-               OperationInstructions: "Not defined",
-       },
-       E2_CONNECTIVITY_LOST_TO_ENODEB: AlarmDefinition{
-               AlarmId:               E2_CONNECTIVITY_LOST_TO_ENODEB,
-               AlarmText:             "E2 CONNECTIVITY LOST TO E-NODEB",
-               EventType:             "Communication error",
-               OperationInstructions: "Not defined",
-       },
-}
+var RICAlarmDefinitions map[int]*AlarmDefinition
+var RICPerfAlarmObjects map[int]*Alarm
+
+var (
+       namespace                     = os.Getenv("PLT_NAMESPACE")
+       ALARM_MANAGER_HTTP_URL string = fmt.Sprintf("http://service-%s-alarmmanager-http.%s:8080", namespace, namespace)
+       ALARM_MANAGER_RMR_URL  string = fmt.Sprintf("service-%s-alarmmanager-rmr.%s:4560", namespace, namespace)
+)