Search in sources :

Example 1 with CollectionUnknown

use of org.opennms.netmgt.collectd.CollectionUnknown in project opennms by OpenNMS.

the class TcaCollectionHandler method collect.

/**
	 * Collect.
	 *
	 * @throws CollectionException the collection exception
	 */
protected CollectionSet collect() throws CollectionException {
    try {
        CollectionSetBuilder builder = new CollectionSetBuilder(m_agent);
        TcaData tracker = new TcaData(m_agent.getAddress());
        CompletableFuture<TcaData> future = m_locationAwareSnmpClient.walk(m_agent.getAgentConfig(), tracker).withDescription("TcaCollector for " + m_agent.getHostAddress()).withLocation(m_agent.getLocationName()).execute();
        LOG.debug("collect: successfully instantiated TCA Collector for {}", m_agent.getHostAddress());
        future.get();
        LOG.info("collect: node TCA query for address {} complete.", m_agent.getHostAddress());
        process(tracker, builder);
        return builder.build();
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new CollectionUnknown("Collection of node TCA data for interface " + m_agent.getHostAddress() + " interrupted: " + e, e);
    } catch (ExecutionException e) {
        final Throwable cause = e.getCause();
        if (cause != null && cause instanceof RequestTimedOutException) {
            throw new CollectionUnknown(String.format("No response received when remotely collecting TCA data" + " for interface %s at location %s interrupted.", m_agent.getHostAddress(), m_agent.getLocationName()), e);
        } else if (cause != null && cause instanceof RequestRejectedException) {
            throw new CollectionUnknown(String.format("The request to remotely collect TCA data" + " for interface %s at location %s was rejected.", m_agent.getHostAddress(), m_agent.getLocationName()), e);
        }
        throw new CollectionException(String.format("Unexpected exception when collecting TCA data for interface %s at location %s.", m_agent.getHostAddress(), m_agent.getLocationName()), e);
    }
}
Also used : RequestTimedOutException(org.opennms.core.rpc.api.RequestTimedOutException) CollectionSetBuilder(org.opennms.netmgt.collection.support.builder.CollectionSetBuilder) RequestRejectedException(org.opennms.core.rpc.api.RequestRejectedException) CollectionException(org.opennms.netmgt.collection.api.CollectionException) CollectionUnknown(org.opennms.netmgt.collectd.CollectionUnknown) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)1 RequestRejectedException (org.opennms.core.rpc.api.RequestRejectedException)1 RequestTimedOutException (org.opennms.core.rpc.api.RequestTimedOutException)1 CollectionUnknown (org.opennms.netmgt.collectd.CollectionUnknown)1 CollectionException (org.opennms.netmgt.collection.api.CollectionException)1 CollectionSetBuilder (org.opennms.netmgt.collection.support.builder.CollectionSetBuilder)1