Search in sources :

Example 6 with Alarm

use of cern.laser.client.data.Alarm in project ACS by ACS-Community.

the class CategoryClient method convertAlarmType.

/**
	 * Convert a CORBA alarm into a client alarm.
	 * 
	 * @param alarm The CORBA alarm
	 * @return the client alarm
	 */
private Alarm convertAlarmType(alma.alarmsystem.Alarm alarm) {
    Source source = new Source();
    Building building = new Building(alarm.alarmLocation.buildingNb, alarm.alarmLocation.site, alarm.alarmLocation.zone, alarm.alarmLocation.map);
    Location location = new Location(alarm.alarmLocation.locationId, alarm.alarmLocation.floor, alarm.alarmLocation.mnemonic, alarm.alarmLocation.position, alarm.alarmLocation.room);
    location.setBuilding(building);
    ResponsiblePerson responsiblePerson = new ResponsiblePerson(alarm.alarmResponsiblePerson.responsibleId, alarm.alarmResponsiblePerson.familyName, alarm.alarmResponsiblePerson.firstName, alarm.alarmResponsiblePerson.eMail, alarm.alarmResponsiblePerson.gsmNumber, alarm.alarmResponsiblePerson.phoneNumber);
    Properties userProperties = new Properties();
    for (org.omg.CosPropertyService.Property prop : alarm.alarmStatus.userProperties) {
        userProperties.put(prop.property_name, prop.property_value);
    }
    Status status = new StatusImpl(Boolean.valueOf(alarm.alarmStatus.active), Boolean.valueOf(alarm.alarmStatus.masked), Boolean.valueOf(alarm.alarmStatus.reduced), Boolean.FALSE, Boolean.FALSE, alarm.alarmStatus.sourceHostname, new Timestamp(alarm.alarmStatus.sourceTimestamp.miliseconds), new Timestamp(alarm.alarmStatus.userTimestamp.miliseconds), new Timestamp(alarm.alarmStatus.systemTimestamp.miliseconds), userProperties);
    Triplet triplet = new Triplet(alarm.alarmTriplet.faultFamily, alarm.alarmTriplet.faultMember, alarm.alarmTriplet.faultCode);
    Set<cern.laser.business.data.Category> categories = new HashSet<cern.laser.business.data.Category>();
    for (Category cat : alarm.categories) {
        CategoryImpl catImpl = new CategoryImpl(cat.categoryId, cat.name, cat.description, cat.path, cat.leaf);
        categories.add(catImpl);
    }
    cern.laser.business.data.Alarm businessAlarm = new AlarmImpl(alarm.alarmId, alarm.systemName, alarm.identifier, alarm.problemDescription, Integer.valueOf(alarm.priority), alarm.cause, alarm.action, alarm.consequence, alarm.piquetGSM, alarm.piquetEmail, alarm.helpURL, Boolean.valueOf(alarm.instant), source, location, responsiblePerson, categories, status, triplet, alarm.nodeParent, alarm.multiplicityParent, alarm.nodeChild, alarm.multiplicityChild);
    Alarm ret = new cern.laser.client.impl.data.AlarmImpl(businessAlarm);
    return ret;
}
Also used : Building(cern.laser.business.data.Building) Status(cern.laser.business.data.Status) Category(alma.alarmsystem.Category) Triplet(cern.laser.business.data.Triplet) StatusImpl(cern.laser.business.data.StatusImpl) Properties(java.util.Properties) Timestamp(java.sql.Timestamp) Source(cern.laser.business.data.Source) CategoryImpl(cern.laser.business.data.CategoryImpl) ResponsiblePerson(cern.laser.business.data.ResponsiblePerson) AlarmImpl(cern.laser.business.data.AlarmImpl) Alarm(cern.laser.client.data.Alarm) Location(cern.laser.business.data.Location) HashSet(java.util.HashSet)

Example 7 with Alarm

use of cern.laser.client.data.Alarm in project ACS by ACS-Community.

the class CoreCDBAlarmTest method testCDBAlarm.

/**
	 * To test if the alarm service send an alarm in case of an error 
	 * in the CDB:
	 * <OL>
	 * 	<LI>shut down the AS
	 * 	<LI>change the reading permission of a file
	 * 	<LI>restart the AS
	 * 	<LI>wait for the alarm or a timeout
	 * </OL>
	 * 
	 * @throws Exception
	 */
public void testCDBAlarm() throws Exception {
    logger.info("Waiting for alarms");
    long timeout = System.currentTimeMillis() + 60 * 1000;
    do {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            continue;
        }
        if (alarms.size() > 0) {
            break;
        }
    } while (System.currentTimeMillis() < timeout);
    assertEquals(1, alarms.size());
    // Check if the alarm is the right one
    Alarm alarm = alarms.get(0);
    assertNotNull(alarm);
    String expectedID = LaserCoreFaultState.FaultFamily + ":" + LaserCoreFaultState.FaultMember + ":" + LaserCoreFaultCodes.ALARMS_CDB.faultCode;
    assertEquals(expectedID, alarm.getAlarmId());
}
Also used : Alarm(cern.laser.client.data.Alarm)

Example 8 with Alarm

use of cern.laser.client.data.Alarm in project ACS by ACS-Community.

the class CategoryClientTest method testAlarmReception.

/**
	 * Sends a couple of alarms and check if they arrive from the client
	 * @throws Exception
	 */
public void testAlarmReception() throws Exception {
    categoryClient.connect(this);
    // Send the alarms
    send_alarm("TEST", "TEST_MEMBER1", 1, true);
    try {
        Thread.sleep(5000);
    } catch (Exception e) {
    }
    send_alarm("TEST", "TEST_MEMBER1", 2, true);
    try {
        Thread.sleep(5000);
    } catch (Exception e) {
    }
    send_alarm("TEST", "TEST_MEMBER2", 1, true);
    try {
        Thread.sleep(5000);
    } catch (Exception e) {
    }
    send_alarm("TEST", "TEST_MEMBER2", 2, true);
    try {
        Thread.sleep(5000);
    } catch (Exception e) {
    }
    send_alarm("TEST", "TEST_MEMBER1", 1, false);
    try {
        Thread.sleep(5000);
    } catch (Exception e) {
    }
    send_alarm("TEST", "TEST_MEMBER1", 2, false);
    try {
        Thread.sleep(5000);
    } catch (Exception e) {
    }
    send_alarm("TEST", "TEST_MEMBER2", 1, false);
    try {
        Thread.sleep(5000);
    } catch (Exception e) {
    }
    send_alarm("TEST", "TEST_MEMBER2", 2, false);
    // Wait for all the messages
    assertEquals(8, waitForMessages(8));
    // Check the correctness of the messages
    for (Alarm alarm : alarmsReceived) {
        assertEquals("Alex", alarm.getResponsiblePerson().getFirstName());
        assertEquals("123456", alarm.getResponsiblePerson().getGsmNumber());
        assertEquals("http://tempuri.org", alarm.getHelpURL().toString());
        AlarmsFromCDB cdbAlarm = AlarmsFromCDB.getCDBAlarm(alarm.getTriplet().getFaultFamily(), alarm.getTriplet().getFaultMember(), alarm.getTriplet().getFaultCode());
        String alarmDesc = "<" + alarm.getTriplet().getFaultFamily() + ", " + alarm.getTriplet().getFaultMember() + ", " + alarm.getTriplet().getFaultCode() + "> ";
        assertEquals(alarmDesc + "Priority", cdbAlarm.priority, alarm.getPriority());
        assertEquals(alarmDesc + "Cause", cdbAlarm.cause, alarm.getCause());
        assertEquals(alarmDesc + "Description", cdbAlarm.description, alarm.getProblemDescription());
        assertEquals(alarmDesc + "Consequence", cdbAlarm.consequence, alarm.getConsequence());
        assertEquals(alarmDesc + "Action", cdbAlarm.action, alarm.getAction());
    }
}
Also used : Alarm(cern.laser.client.data.Alarm) LaserSelectionException(cern.laser.client.services.selection.LaserSelectionException)

Example 9 with Alarm

use of cern.laser.client.data.Alarm in project ACS by ACS-Community.

the class ReducedChainDlg method getAlarmChain.

/**
	 * Get the chain of reduction of the given alarm.
	 * <P>
	 * <i>Implementation notes</i>: 
	 * <UL>
	 * 	<LI>this method is recursive and therefore could lead to an out of memory if the chain is very deep.
	 * 	<LI><code>getAlarmChain(Alarm, DefaultMutableTreeNode)</code> uses the {@link #categoryClient} to get
	 * the children of an alarm. This operation involves a CORBA call so it must not be executed
	 * inside the swing EDT.
	 * </UL>
	 * 
	 * @param al The alarm to get reduced nodes
	 * @param parentNode The parent node of the tree
	 */
private void getAlarmChain(Alarm al, DefaultMutableTreeNode parentNode) {
    model.onAlarm(al);
    DefaultMutableTreeNode newNode = tree.add(al, parentNode);
    if (al != null) {
        Alarm[] alarms = null;
        try {
            if (al.isNodeParent()) {
                alarms = categoryClient.getChildren(al.getAlarmId(), true);
            } else {
                alarms = categoryClient.getChildren(al.getAlarmId(), false);
            }
        } catch (Throwable error) {
            System.err.println("Error getting the children of " + alarm.getAlarmId());
            error.printStackTrace(System.err);
            JOptionPane.showMessageDialog(table, "Error getting children of " + alarm.getAlarmId(), "Error getting alarms", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (alarms != null) {
            for (Alarm child : alarms) {
                getAlarmChain(child, newNode);
            }
        }
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Alarm(cern.laser.client.data.Alarm)

Example 10 with Alarm

use of cern.laser.client.data.Alarm in project ACS by ACS-Community.

the class CategoryClient method getActiveChildren.

/**
	 * Get the active children of a reduced alarm.
	 * <P>
	 * The method asks the alarm service component for the active children of a reduced
	 * alarm.
	 * 
	 * @param id The id of the alarm 
	 * @param node <code>true</code> if the alarm is a Node alarm;
	 * 			   <code>false</code> if the alarm of the passed ID is a multiplicity.
	 * @return The array of the alarm parent of the alarm with the passed ID
	 * @throws AlarmClientException In case of error getting the alarms from the component 
	 */
public Alarm[] getActiveChildren(String id, boolean node) throws AlarmClientException {
    if (id == null || id.isEmpty()) {
        throw new IllegalArgumentException("Invalid alarm ID");
    }
    alma.alarmsystem.Alarm[] alarms = null;
    try {
        if (node) {
            alarms = alarm.getActiveNodeChildren(id);
        } else {
            alarms = alarm.getActiveMultiplicityChildren(id);
        }
    } catch (Throwable t) {
        throw new AlarmClientException("Error getting children from component", t);
    }
    Alarm[] ret = new Alarm[alarms.length];
    for (int t = 0; t < ret.length; t++) {
        ret[t] = convertAlarmType(alarms[t]);
    }
    return ret;
}
Also used : Alarm(cern.laser.client.data.Alarm) AlarmClientException(alma.alarmsystem.clients.alarm.AlarmClientException)

Aggregations

Alarm (cern.laser.client.data.Alarm)21 AlarmTableEntry (alma.acsplugins.alarmsystem.gui.table.AlarmTableEntry)4 AlarmClientException (alma.alarmsystem.clients.alarm.AlarmClientException)4 Vector (java.util.Vector)4 SpecialAlarm (alma.acsplugins.alarmsystem.gui.specialalarm.SpecialAlarm)2 CategoryClient (alma.alarmsystem.clients.CategoryClient)2 LaserSelectionException (cern.laser.client.services.selection.LaserSelectionException)2 Properties (java.util.Properties)2 AlarmGUIType (alma.acsplugins.alarmsystem.gui.table.AlarmGUIType)1 AlarmContainerException (alma.acsplugins.alarmsystem.gui.table.AlarmsContainer.AlarmContainerException)1 AlarmSelectionListener (alma.acsplugins.alarmsystem.gui.viewcoordination.ViewCoordinator.AlarmSelectionListener)1 Category (alma.alarmsystem.Category)1 AlarmCategoryClient (alma.alarmsystem.clients.AlarmCategoryClient)1 SourceClient (alma.alarmsystem.clients.SourceClient)1 AlarmFilter (alma.alarmsystem.clients.alarm.AlarmFilter)1 AlarmListenerForTesting (alma.alarmsystem.clients.test.utils.AlarmListenerForTesting)1 AlrmStatListenerForTesting (alma.alarmsystem.clients.test.utils.AlrmStatListenerForTesting)1 CernAlarmServiceUtils (alma.alarmsystem.corbaservice.CernAlarmServiceUtils)1 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)1 AlarmImpl (cern.laser.business.data.AlarmImpl)1