Search in sources :

Example 11 with Alarm

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

the class CategoryClient method connect.

/**
	 * Connects to the passed categories of the alarm system
	 * 
	 * @param listener The lister to notify of the alarms received from the categories
	 * @param categories The categories to connect to
	 * @throws AcsJCannotGetComponentEx In case the AlarmService is not available
	 * @throws AlarmClientException In case of failure connecting the client
	 */
public void connect(AlarmSelectionListener listener, Category[] categories) throws AlarmClientException, AcsJCannotGetComponentEx {
    if (listener == null) {
        throw new IllegalArgumentException("The listener can't be null");
    }
    if (closed) {
        throw new IllegalStateException("SourceClient is closed!");
    }
    try {
        CernAlarmServiceUtils alarmUtils = new CernAlarmServiceUtils(orb, logger);
        alarm = alarmUtils.getCernAlarmService();
    } catch (Throwable t) {
        AcsJCannotGetComponentEx ex = new AcsJCannotGetComponentEx(t);
        ex.setReason("Alarm service unavailable");
        throw ex;
    }
    try {
        userHandler = new UserHandlerImpl(orb, logger);
        logger.log(AcsLogLevel.DEBUG, "UserHandler succesfully built");
        testUser = userHandler.getUser("test", orb, logger);
        logger.log(AcsLogLevel.DEBUG, "User generated");
        defaultConf = testUser.getDefaultConfiguration();
        logger.log(AcsLogLevel.DEBUG, "Getting the selection handler");
        jms_selectionHandler = AlarmSelectionHandler.get(orb, logger);
        addCategories(defaultConf, categories);
        // Get the active alarms (they are received by the listener)
        java.util.Map<String, Alarm> alreadyActive = jms_selectionHandler.select(defaultConf.getSelection(), listener);
        if (alreadyActive != null && alreadyActive.size() > 0) {
            Set<String> keys = alreadyActive.keySet();
            for (String key : keys) {
                listener.onAlarm(alreadyActive.get(key));
            }
        }
    } catch (Throwable t) {
        throw new AlarmClientException("Exception connecting the category client", t);
    }
}
Also used : Alarm(cern.laser.client.data.Alarm) AlarmClientException(alma.alarmsystem.clients.alarm.AlarmClientException) AcsJCannotGetComponentEx(alma.maciErrType.wrappers.AcsJCannotGetComponentEx) CernAlarmServiceUtils(alma.alarmsystem.corbaservice.CernAlarmServiceUtils) UserHandlerImpl(cern.laser.console.impl.UserHandlerImpl)

Example 12 with Alarm

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

the class CategoryClient method getChildren.

/**
	 * Get the parents of a reduced alarm.
	 * <P>
	 * The method asks the alarm service component for the 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[] getChildren(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.getNodeChildren(id);
        } else {
            alarms = alarm.getMultiplicityChildren(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)

Example 13 with Alarm

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

the class CategoryClient method getParents.

/**
	 * Get the parents of a reduced alarm.
	 * <P>
	 * The method asks the alarm service component for the parents 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[] getParents(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.getNodeParents(id);
        } else {
            alarms = alarm.getMultiplicityParents(id);
        }
    } catch (Throwable t) {
        throw new AlarmClientException("Error getting parents 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)

Example 14 with Alarm

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

the class UserPropsTest method setUp.

/**
	 * @see extends ComponentClientTestCase
	 */
protected void setUp() throws Exception {
    super.setUp();
    categoryClient = new CategoryClient(getContainerServices());
    assertNotNull(categoryClient);
    categoryClient.connect(this);
    // Instantiate and connect the source client
    sourceClient = new SourceClient(getContainerServices());
    assertNotNull(sourceClient);
    sourceClient.addAlarmListener(this);
    sourceClient.connect();
    alarmsReceived = new Vector<Alarm>();
}
Also used : Alarm(cern.laser.client.data.Alarm) CategoryClient(alma.alarmsystem.clients.CategoryClient) SourceClient(alma.alarmsystem.clients.SourceClient)

Example 15 with Alarm

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

the class AlarmCategoryClientTest method testAlarmReception.

/**
	 * Sends a couple of alarms and check if they arrive from the client
	 * @throws Exception
	 */
public void testAlarmReception() throws Exception {
    categoryClient.connect();
    // Send the alarms
    send_alarm("TEST", "TEST_MEMBER1", 1, true);
    send_alarm("TEST", "TEST_MEMBER1", 2, true);
    send_alarm("TEST", "TEST_MEMBER2", 1, true);
    send_alarm("TEST", "TEST_MEMBER2", 2, true);
    /// Clear the alarms
    try {
        Thread.sleep(5000);
    } catch (Exception e) {
    }
    send_alarm("TEST", "TEST_MEMBER1", 1, false);
    send_alarm("TEST", "TEST_MEMBER1", 2, false);
    send_alarm("TEST", "TEST_MEMBER2", 1, false);
    send_alarm("TEST", "TEST_MEMBER2", 2, false);
    // Wait for all the messages
    assertTrue("TIMEOUT: not all the alarms have been received", waitForMessages(latch));
    // Check the correctness of the messages
    for (Alarm alarm : alarmsReceived) {
        assertEquals("Wrong responsible person in " + alarm, "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)

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