| |
|
Line 28
|
Parallel
|
Line 28
|
Parallel
|
| 28 |
import com.dnms.source.com.dhyan.nms.server.fault.resources.alarmcorreltion.Matchingfields; |
28 |
import com.dnms.source.com.dhyan.nms.server.fault.resources.alarmcorreltion.Matchingfields; |
| 29 |
import com.dnms.source.com.dhyan.nms.server.fault.resources.alarmpublish.Alarmpublish; |
29 |
import com.dnms.source.com.dhyan.nms.server.fault.resources.alarmpublish.Alarmpublish; |
| 30 |
import com.dnms.source.com.dhyan.nms.server.fault.resources.alarmpublish.AlarmpublishDocument; |
30 |
import com.dnms.source.com.dhyan.nms.server.fault.resources.alarmpublish.AlarmpublishDocument; |
|
|
31 |
import com.dnms.source.com.dhyan.nms.server.fault.resources.classificationdetails.AlarmClassification; |
|
|
32 |
import com.dnms.source.com.dhyan.nms.server.fault.resources.classificationdetails.AlarmClassificationDocument; |
|
|
33 |
import com.dnms.source.com.dhyan.nms.server.fault.resources.classificationdetails.Alarmspecification; |
|
|
34 |
import com.dnms.source.com.dhyan.nms.server.fault.resources.classificationdetails.FieldDetails; |
|
|
35 |
import com.dnms.source.com.dhyan.nms.server.fault.resources.classificationdetails.MappingDetails; |
| 31 |
|
36 |
|
| 32 |
public final class AlarmManager |
37 |
public final class AlarmManager |
| 33 |
{ |
38 |
{ |
| |
| |
|
Line 41
|
Parallel
|
Line 46
|
Parallel
|
| 41 |
private String remedyHandling; |
46 |
private String remedyHandling; |
| 42 |
private ArrayList<String> publishFieldList = null; |
47 |
private ArrayList<String> publishFieldList = null; |
| 43 |
private boolean publishClearedAlarms = false; |
48 |
private boolean publishClearedAlarms = false; |
|
|
49 |
private Alarmspecification[] alarmSpecList = null; |
| 44 |
|
50 |
|
| 45 |
/** |
51 |
/** |
| 46 |
* No-args constructor. All the member variables are initialized. |
52 |
* No-args constructor. All the member variables are initialized. |
| |
| |
|
Line 54
|
Parallel
|
Line 60
|
Parallel
|
| 54 |
loadAlarmCorrelator(); |
60 |
loadAlarmCorrelator(); |
| 55 |
parseAlarmCorrelation(); |
61 |
parseAlarmCorrelation(); |
| 56 |
loadPublishersFields(); |
62 |
loadPublishersFields(); |
|
|
63 |
parseAlarmClassification(); |
| 57 |
} |
64 |
} |
| 58 |
|
65 |
|
| 59 |
/** |
66 |
/** |
| |
| |
|
Line 95
|
Parallel
|
Line 102
|
Parallel
|
| 95 |
} |
102 |
} |
| 96 |
} |
103 |
} |
| 97 |
|
104 |
|
|
|
105 |
private void parseAlarmClassification() |
|
|
106 |
{ |
|
|
107 |
try |
|
|
108 |
{ |
|
|
109 |
AlarmClassificationDocument document = |
|
|
110 |
AlarmClassificationDocument.Factory.parse(AlarmManager.class.getResource("resources/AlarmClassification.xml")); |
|
|
111 |
if (document != null) |
|
|
112 |
{ |
|
|
113 |
AlarmClassification alarm_classification = document.getAlarmClassification(); |
|
|
114 |
alarmSpecList = alarm_classification.getAlarmspecificationArray(); |
|
|
115 |
} |
|
|
116 |
} |
|
|
117 |
catch (Exception e) |
|
|
118 |
{ |
|
|
119 |
LOG.error("Exception occured while reading alarmcorrelationfieldmapping.xml file" + e.getMessage()); |
|
|
120 |
} |
|
|
121 |
} |
|
|
122 |
|
|
|
123 |
/** |
|
|
124 |
* Method to retrieve trap details based on given alarm information. |
|
|
125 |
* @param alarmDetails alarmDetails |
|
|
126 |
* @return Trap |
|
|
127 |
* @throws Exception Exception |
|
|
128 |
*/ |
|
|
129 |
public boolean isDeviceAlarm(final Alarm alarmDetails) throws Exception |
|
|
130 |
{ |
|
|
131 |
try |
|
|
132 |
{ |
|
|
133 |
if (alarmSpecList != null && alarmSpecList.length > 0) |
|
|
134 |
{ |
|
|
135 |
for (Alarmspecification alarm_value : alarmSpecList) |
|
|
136 |
{ |
|
|
137 |
if (alarm_value.getType().trim().equalsIgnoreCase("DEVICE")) |
|
|
138 |
{ |
|
|
139 |
return isMatchingAlarmDetails(alarm_value.getMappingDetailsArray(), alarmDetails); |
|
|
140 |
} |
|
|
141 |
} |
|
|
142 |
} |
|
|
143 |
else |
|
|
144 |
{ |
|
|
145 |
throw new Exception("Problem in getting alarm specification details. Classification details not found"); |
|
|
146 |
} |
|
|
147 |
} |
|
|
148 |
catch (Exception e) |
|
|
149 |
{ |
|
|
150 |
LOG.error("Exception occured while getting TrapDetails " + e.getMessage()); |
|
|
151 |
} |
|
|
152 |
return false; |
|
|
153 |
} |
|
|
154 |
|
|
|
155 |
/** |
|
|
156 |
* Method to retrieve trap details based on given alarm information. |
|
|
157 |
* @param alarmDetails alarmDetails |
|
|
158 |
* @return Trap |
|
|
159 |
* @throws Exception Exception |
|
|
160 |
*/ |
|
|
161 |
public String getAlarmSpecificationType(final Alarm alarmDetails) throws Exception |
|
|
162 |
{ |
|
|
163 |
try |
|
|
164 |
{ |
|
|
165 |
if (alarmSpecList != null && alarmSpecList.length > 0) |
|
|
166 |
{ |
|
|
167 |
boolean isMatch = false; |
|
|
168 |
for (Alarmspecification alarm_value : alarmSpecList) |
|
|
169 |
{ |
|
|
170 |
isMatch = isMatchingAlarmDetails(alarm_value.getMappingDetailsArray(), alarmDetails); |
|
|
171 |
if (isMatch) |
|
|
172 |
{ |
|
|
173 |
return alarm_value.getDisplayName(); |
|
|
174 |
} |
|
|
175 |
} |
|
|
176 |
} |
|
|
177 |
else |
|
|
178 |
{ |
|
|
179 |
throw new Exception("Problem in getting alarm specification details. Classification details not found"); |
|
|
180 |
} |
|
|
181 |
} |
|
|
182 |
catch (Exception e) |
|
|
183 |
{ |
|
|
184 |
LOG.error("Exception occured while getting TrapDetails " + e.getMessage()); |
|
|
185 |
} |
|
|
186 |
return null; |
|
|
187 |
} |
|
|
188 |
|
|
|
189 |
private boolean isMatchingAlarmDetails(final MappingDetails[] mappingFields, final Alarm alarmDetails) |
|
|
190 |
{ |
|
|
191 |
if (mappingFields != null && mappingFields.length > 0) |
|
|
192 |
{ |
|
|
193 |
MappingDetails mapping_field = mappingFields[0]; |
|
|
194 |
boolean isFieldMapped = true; |
|
|
195 |
String expectedValue = null; |
|
|
196 |
String actualObject = null; |
|
|
197 |
for (FieldDetails field_list : mapping_field.getFieldDetailsArray()) |
|
|
198 |
{ |
|
|
199 |
expectedValue = field_list.getValue(); |
|
|
200 |
actualObject = alarmDetails.get(field_list.getName()); |
|
|
201 |
if (expectedValue == null || actualObject == null) |
|
|
202 |
{ |
|
|
203 |
isFieldMapped = false; |
|
|
204 |
break; |
|
|
205 |
} |
|
|
206 |
if (field_list.getOperation().toString().equalsIgnoreCase("EQUALS")) |
|
|
207 |
{ |
|
|
208 |
if (!expectedValue.trim().equalsIgnoreCase(actualObject.toString())) |
|
|
209 |
{ |
|
|
210 |
isFieldMapped = false; |
|
|
211 |
break; |
|
|
212 |
} |
|
|
213 |
} |
|
|
214 |
else |
|
|
215 |
{ |
|
|
216 |
if (expectedValue.trim().equalsIgnoreCase(actualObject.toString())) |
|
|
217 |
{ |
|
|
218 |
isFieldMapped = false; |
|
|
219 |
break; |
|
|
220 |
} |
|
|
221 |
} |
|
|
222 |
} |
|
|
223 |
return isFieldMapped; |
|
|
224 |
} |
|
|
225 |
return false; |
|
|
226 |
} |
|
|
227 |
|
| 98 |
private AbstractAlarmCorrelator getAlarmCorrelatorIfc(final String correlatorClassName) |
228 |
private AbstractAlarmCorrelator getAlarmCorrelatorIfc(final String correlatorClassName) |
| 99 |
{ |
229 |
{ |
| 100 |
AbstractAlarmCorrelator correlatorIfc = null; |
230 |
AbstractAlarmCorrelator correlatorIfc = null; |
| |