Search in sources :

Example 1 with LaserConnectionException

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

the class AlarmSelectionHelper method subscribe.

//
// -- PUBLIC METHODS ----------------------------------------------
//
public Map subscribe(Selection selection) throws LaserConnectionException, LaserException, LaserTimeOutException {
    String sql_filter = buildSQLFilter(selection);
    Collection category_ids = setupCategorySubscriptions(selection, sql_filter);
    // start init subscription
    setInitialized(false);
    String console_id = "";
    String host_name = "";
    try {
        console_id = UUIDGenerator.getInstance().getUUID().toString();
        host_name = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException e) {
        throw new LaserException("unable to get a unique id for the console", e);
    }
    String init_topic = getClientRootTopic() + "." + console_id;
    String init_sql_filter = buildInitSQLFilter(sql_filter);
    long init_subscription;
    try {
        init_subscription = getSubscriber().subscribe(init_topic, getInitialSelectionListener(), init_sql_filter);
    } catch (Exception e) {
        LOGGER.error("unable to subscribe to topic " + init_topic, e);
        throw new LaserException("unable to subscribe to topic " + init_topic, e);
    }
    try {
        if (m_laser != null) {
            int[] cis = new int[category_ids.size()];
            int pos = 0;
            for (Iterator iter = category_ids.iterator(); iter.hasNext(); ) {
                cis[pos++] = ((Integer) iter.next()).intValue();
            }
            m_laser.select(cis, console_id);
        } else {
            throw new NullPointerException("AlarmSystem component is null");
        }
    } catch (alma.alarmsystem.LaserProcessingException lpe) {
        try {
            getSubscriber().unSubscribe(init_subscription);
        } catch (JMSException e1) {
        // Intentionally left blank
        } catch (LaserException e1) {
        // Intentionally left blank
        }
        LOGGER.error("server is initializing");
        throw new LaserConnectionException("server is initializing", lpe);
    } catch (Exception e3) {
        throw new LaserException("unable to perform initial selection at host " + host_name, e3);
    }
    resetInitWaitTime();
    waitForInit();
    try {
        // stop init subscription
        getSubscriber().unSubscribe(init_subscription);
    } catch (Exception e) {
        LOGGER.info("exception when unsubscribing", e);
    }
    if (isInitialized()) {
        return getInitialSelection();
    } else {
    //throw new LaserTimeOutException("initial selection timed out");
    }
    return getInitialSelection();
}
Also used : UnknownHostException(java.net.UnknownHostException) JMSException(javax.jms.JMSException) LaserConnectionException(cern.laser.client.LaserConnectionException) LaserConnectionException(cern.laser.client.LaserConnectionException) LaserException(cern.laser.client.LaserException) UnknownHostException(java.net.UnknownHostException) JMSException(javax.jms.JMSException) MOMException(cern.cmw.mom.pubsub.MOMException) LaserSelectionException(cern.laser.client.services.selection.LaserSelectionException) LaserTimeOutException(cern.laser.client.LaserTimeOutException) Iterator(java.util.Iterator) Collection(java.util.Collection) LaserException(cern.laser.client.LaserException)

Example 2 with LaserConnectionException

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

the class AlarmSearchHelper method search.

//
// -- PUBLIC METHODS ----------------------------------------------
//
public void search(Selection selection, int nbOfRows) throws LaserConnectionException, LaserException, LaserTimeOutException {
    searchFinished(false);
    String console_id = "";
    String host_name = "";
    try {
        console_id = UUIDGenerator.getInstance().getUUID().toString();
        host_name = InetAddress.getLocalHost().getHostName();
    } catch (UnknownHostException e) {
        throw new LaserException("unable to get a unique id for the console : " + e.getMessage());
    }
    String init_topic = getSearchRootTopic() + "." + console_id;
    long init_subscription;
    try {
        init_subscription = getSubscriber().subscribe(init_topic, getSearchListener(), null);
    } catch (Exception e) {
        throw new LaserException("unable to subscribe to topic " + init_topic + " : " + e.getMessage());
    }
    // activate the selection on the BT
    Integer[] category_ids = getCategoryIds(selection);
    String sql = buildSQLFilter(selection, nbOfRows);
    try {
        if (m_laser != null) {
            int[] cis = new int[category_ids.length];
            for (int i = 0; i < category_ids.length; i++) cis[i] = category_ids[i].intValue();
            m_laser.search(cis, sql, console_id);
        } else {
            throw new NullPointerException("AlarmSystem component is null");
        }
    } catch (Exception e) {
        throw new LaserException("unable to perform initial selection at host " + host_name + " : " + e.getMessage());
    }
    resetInitWaitTime();
    waitForInit();
    try {
        // stop init subscription
        getSubscriber().unSubscribe(init_subscription);
    } catch (Exception e) {
    // Intentionally left blank
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) LaserConnectionException(cern.laser.client.LaserConnectionException) LaserSearchException(cern.laser.client.services.selection.LaserSearchException) LaserException(cern.laser.client.LaserException) UnknownHostException(java.net.UnknownHostException) MOMException(cern.cmw.mom.pubsub.MOMException) LaserTimeOutException(cern.laser.client.LaserTimeOutException) LaserException(cern.laser.client.LaserException)

Example 3 with LaserConnectionException

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

the class AlarmSelectionHandlerImpl method select.

/**
   * DOCUMENT ME!
   * 
   * @param selection DOCUMENT ME!
   * @param listener DOCUMENT ME!
   * 
   * @return DOCUMENT ME!
   * @throws LaserConnectionException
   * @throws LaserException DOCUMENT ME!
   * @throws LaserException
   * @throws LaserTimeOutException
   * @throws LaserConnectionException
   * @throws IllegalArgumentException DOCUMENT ME!
   */
public Map select(Selection selection, AlarmSelectionListener selectionListener) throws LaserException, LaserTimeOutException {
    if (selection == null) {
        throw new IllegalArgumentException("selection parameter is null");
    }
    if (selection.getCategorySelection() == null) {
        throw new IllegalArgumentException("no categories selected");
    }
    try {
        resetSelection();
        // setup the heartbeat reception and start checking
        startHeartbeatSubscription(selectionListener);
        // perform the subscriptions
        if (selection.getCategorySelection().list().length != 0) {
            return subscribe(selection, selectionListener);
        } else {
            return Collections.EMPTY_MAP;
        }
    } catch (LaserConnectionException e) {
        resetSelection();
        throw new LaserException("unable to connect to perform the selection", e);
    }
}
Also used : LaserConnectionException(cern.laser.client.LaserConnectionException) LaserException(cern.laser.client.LaserException)

Example 4 with LaserConnectionException

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

the class HeartbeatHelper method initHeartbeatCheck.

//
// -- PRIVATE METHODS ---------------------------------------------
//
/**
   * @throws LaserException
   * @throws LaserConnectionException
   */
private void initHeartbeatCheck() throws LaserException, LaserConnectionException {
    if (selectionListener != null) {
        try {
            setHeartbeatReceived(true);
            resetHeartbeatReceptionTime();
            getSubscriber().subscribe(heartbeatTopic, getHeartbeatListener(), SQL_FILTER);
        } catch (Exception e1) {
            new LaserException("unable to subscribe to topic " + heartbeatTopic, e1);
        }
    }
}
Also used : LaserConnectionException(cern.laser.client.LaserConnectionException) LaserHeartbeatException(cern.laser.client.services.selection.LaserHeartbeatException) LaserException(cern.laser.client.LaserException) MOMException(cern.cmw.mom.pubsub.MOMException) LaserSelectionException(cern.laser.client.services.selection.LaserSelectionException) LaserException(cern.laser.client.LaserException)

Example 5 with LaserConnectionException

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

the class AlarmSelectionHelper method setupCategorySubscriptions.

private Collection setupCategorySubscriptions(Selection selection, String sql_filter) throws LaserConnectionException, LaserException {
    Category[] categories = selection.getCategorySelection().list();
    Collection category_ids = new ArrayList(categories.length);
    for (int i = 0; i < categories.length; i++) {
        Category category = categories[i];
        String topic = getCategoryRootTopic() + "." + category.getPath();
        if (selectionListener != null) {
            try {
                getSubscriber().subscribe(topic, this, sql_filter);
            } catch (Exception e1) {
                new LaserException("unable to subscribe to topic " + topic, e1);
            }
        }
        category_ids.add(category.getCategoryId());
    }
    return category_ids;
}
Also used : Category(cern.laser.client.data.Category) ArrayList(java.util.ArrayList) Collection(java.util.Collection) LaserConnectionException(cern.laser.client.LaserConnectionException) LaserException(cern.laser.client.LaserException) UnknownHostException(java.net.UnknownHostException) JMSException(javax.jms.JMSException) MOMException(cern.cmw.mom.pubsub.MOMException) LaserSelectionException(cern.laser.client.services.selection.LaserSelectionException) LaserTimeOutException(cern.laser.client.LaserTimeOutException) LaserException(cern.laser.client.LaserException)

Aggregations

LaserConnectionException (cern.laser.client.LaserConnectionException)5 LaserException (cern.laser.client.LaserException)5 MOMException (cern.cmw.mom.pubsub.MOMException)4 LaserTimeOutException (cern.laser.client.LaserTimeOutException)3 LaserSelectionException (cern.laser.client.services.selection.LaserSelectionException)3 UnknownHostException (java.net.UnknownHostException)3 Collection (java.util.Collection)2 JMSException (javax.jms.JMSException)2 Category (cern.laser.client.data.Category)1 LaserHeartbeatException (cern.laser.client.services.selection.LaserHeartbeatException)1 LaserSearchException (cern.laser.client.services.selection.LaserSearchException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1