use of org.opennms.netmgt.events.api.EventProxyException in project opennms by OpenNMS.
the class DefaultRequisitionAccessService method importRequisition.
@Override
public void importRequisition(final String foreignSource, final String rescanExisting) {
final URL activeUrl = createSnapshot(foreignSource);
final String url = activeUrl.toString();
LOG.debug("importRequisition: Sending import event with URL {}", url);
final EventBuilder bldr = new EventBuilder(EventConstants.RELOAD_IMPORT_UEI, "Web");
bldr.addParam(EventConstants.PARM_URL, url);
if (rescanExisting != null) {
bldr.addParam(EventConstants.PARM_IMPORT_RESCAN_EXISTING, rescanExisting);
}
try {
getEventProxy().send(bldr.getEvent());
} catch (final EventProxyException e) {
throw new DataAccessResourceFailureException("Unable to send event to import group " + foreignSource, e);
}
}
use of org.opennms.netmgt.events.api.EventProxyException in project opennms by OpenNMS.
the class DefaultResourceService method promoteGraphAttributesForResource.
/** {@inheritDoc} */
@Override
public void promoteGraphAttributesForResource(OnmsResource resource) {
final String rrdBaseDir = System.getProperty("rrd.base.dir");
List<String> rrdFiles = new LinkedList<String>();
for (RrdGraphAttribute attribute : resource.getRrdGraphAttributes().values()) {
rrdFiles.add(rrdBaseDir + File.separator + attribute.getRrdRelativePath());
}
EventBuilder bldr = new EventBuilder(EventConstants.PROMOTE_QUEUE_DATA_UEI, "OpenNMS.Webapp");
bldr.addParam(EventConstants.PARM_FILES_TO_PROMOTE, rrdFiles);
try {
m_eventProxy.send(bldr.getEvent());
} catch (EventProxyException e) {
LOG.warn("Unable to send file promotion event to opennms: {}", e, e);
}
}
use of org.opennms.netmgt.events.api.EventProxyException in project opennms by OpenNMS.
the class NCSComponentServiceImpl method addOrUpdateComponents.
@Override
@Transactional
public NCSComponent addOrUpdateComponents(final NCSComponent component, final boolean deleteOrphans) {
final ComponentIdentifier componentId = getIdentifier(component);
LOG.debug("addOrUpdateComponents({}, {})", componentId, Boolean.valueOf(deleteOrphans));
final ComponentEventQueue ceq = new ComponentEventQueue();
final NCSComponent updatedComponent = addOrUpdateComponents(componentId, component, ceq, deleteOrphans);
try {
ceq.sendAll(m_eventProxy);
} catch (final EventProxyException e) {
LOG.warn("Component {} added, but an error occured while sending add/delete/update events.", componentId, e);
}
return updatedComponent;
}
use of org.opennms.netmgt.events.api.EventProxyException in project opennms by OpenNMS.
the class HeartbeatConsumer method handleMessage.
@Override
@Transactional
public void handleMessage(MinionIdentityDTO minionHandle) {
LOG.info("Received heartbeat for Minion with id: {} at location: {}", minionHandle.getId(), minionHandle.getLocation());
OnmsMinion minion = minionDao.findById(minionHandle.getId());
if (minion == null) {
minion = new OnmsMinion();
minion.setId(minionHandle.getId());
// The real location is filled in below, but we set this to null
// for now to detect requisition changes
minion.setLocation(null);
}
final String prevLocation = minion.getLocation();
final String nextLocation = minionHandle.getLocation();
minion.setLocation(minionHandle.getLocation());
// Provision the minions node before we alter the location
this.provision(minion, prevLocation, nextLocation);
if (minionHandle.getTimestamp() == null) {
// The heartbeat does not contain a timestamp - use the current time
minion.setLastUpdated(new Date());
LOG.info("Received heartbeat without a timestamp: {}", minionHandle);
} else if (minion.getLastUpdated() == null) {
// The heartbeat does contain a timestamp, and we don't have
// one set yet, so use whatever we've been given
minion.setLastUpdated(minionHandle.getTimestamp());
} else if (minionHandle.getTimestamp().after(minion.getLastUpdated())) {
// The timestamp in the heartbeat is more recent than the one we
// have stored, so update it
minion.setLastUpdated(minionHandle.getTimestamp());
} else {
// The timestamp in the heartbeat is earlier than the
// timestamp we have stored, so ignore it
LOG.info("Ignoring stale timestamp from heartbeat: {}", minionHandle);
}
minionDao.saveOrUpdate(minion);
if (prevLocation == null) {
final EventBuilder eventBuilder = new EventBuilder(EventConstants.MONITORING_SYSTEM_ADDED_UEI, "OpenNMS.Minion.Heartbeat");
eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_TYPE, OnmsMonitoringSystem.TYPE_MINION);
eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_ID, minionHandle.getId());
eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_LOCATION, nextLocation);
try {
eventProxy.send(eventBuilder.getEvent());
} catch (final EventProxyException e) {
throw new DataAccessResourceFailureException("Unable to send event", e);
}
} else if (!prevLocation.equals(nextLocation)) {
final EventBuilder eventBuilder = new EventBuilder(EventConstants.MONITORING_SYSTEM_LOCATION_CHANGED_UEI, "OpenNMS.Minion.Heartbeat");
eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_TYPE, OnmsMonitoringSystem.TYPE_MINION);
eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_ID, minionHandle.getId());
eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_PREV_LOCATION, prevLocation);
eventBuilder.addParam(EventConstants.PARAM_MONITORING_SYSTEM_LOCATION, nextLocation);
try {
eventProxy.send(eventBuilder.getEvent());
} catch (final EventProxyException e) {
throw new DataAccessResourceFailureException("Unable to send event", e);
}
}
}
use of org.opennms.netmgt.events.api.EventProxyException in project opennms by OpenNMS.
the class IfServicesRestService method sendEvent.
private void sendEvent(String eventUEI, OnmsMonitoredService dbObj) {
final EventBuilder bldr = new EventBuilder(eventUEI, "ReST");
bldr.setNodeid(dbObj.getNodeId());
bldr.setInterface(dbObj.getIpAddress());
bldr.setService(dbObj.getServiceName());
try {
m_eventProxy.send(bldr.getEvent());
} catch (EventProxyException ex) {
throw getException(Status.INTERNAL_SERVER_ERROR, "Cannot send event {} : {}", eventUEI, ex.getMessage());
}
}
Aggregations