Search in sources :

Example 6 with OnmsLocationMonitor

use of org.opennms.netmgt.model.OnmsLocationMonitor in project opennms by OpenNMS.

the class DefaultDistributedPollerService method pauseLocationMonitor.

/** {@inheritDoc} */
@Override
public void pauseLocationMonitor(LocationMonitorIdCommand command, BindingResult errors) {
    if (command == null) {
        throw new IllegalStateException("command argument cannot be null");
    }
    if (errors == null) {
        throw new IllegalStateException("errors argument cannot be null");
    }
    if (errors.hasErrors()) {
        return;
    }
    OnmsLocationMonitor monitor = m_locationMonitorDao.load(command.getMonitorId());
    if (monitor.getStatus() == MonitorStatus.PAUSED) {
        errors.addError(new ObjectError(MonitorStatus.class.getName(), new String[] { "distributed.locationMonitor.alreadyPaused" }, new Object[] { command.getMonitorId() }, "Location monitor " + command.getMonitorId() + " is already paused."));
        return;
    }
    monitor.setStatus(MonitorStatus.PAUSED);
    m_locationMonitorDao.update(monitor);
}
Also used : ObjectError(org.springframework.validation.ObjectError) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor)

Example 7 with OnmsLocationMonitor

use of org.opennms.netmgt.model.OnmsLocationMonitor in project opennms by OpenNMS.

the class DefaultDistributedPollerService method getLocationMonitorList.

/**
     * <p>getLocationMonitorList</p>
     *
     * @return a {@link org.opennms.web.svclayer.model.LocationMonitorListModel} object.
     */
@Override
public LocationMonitorListModel getLocationMonitorList() {
    List<OnmsLocationMonitor> monitors = m_locationMonitorDao.findAll();
    Collections.sort(monitors, m_comparator);
    LocationMonitorListModel model = new LocationMonitorListModel();
    for (OnmsLocationMonitor monitor : monitors) {
        OnmsMonitoringLocation def = m_monitoringLocationDao.get(monitor.getLocation());
        model.addLocationMonitor(new LocationMonitorModel(monitor, def));
    }
    return model;
}
Also used : LocationMonitorListModel(org.opennms.web.svclayer.model.LocationMonitorListModel) LocationMonitorModel(org.opennms.web.svclayer.model.LocationMonitorListModel.LocationMonitorModel) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)

Example 8 with OnmsLocationMonitor

use of org.opennms.netmgt.model.OnmsLocationMonitor in project opennms by OpenNMS.

the class PollerBackEndTest method testReportResultWithBadServiceId.

public void testReportResultWithBadServiceId() {
    expect(m_locMonDao.get(LOCATION_MONITOR_ID)).andReturn(new OnmsLocationMonitor());
    expect(m_monSvcDao.get(1)).andReturn(null);
    m_mocks.replayAll();
    m_backEnd.reportResult(LOCATION_MONITOR_ID, 1, PollStatus.up());
}
Also used : OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor)

Example 9 with OnmsLocationMonitor

use of org.opennms.netmgt.model.OnmsLocationMonitor in project opennms by OpenNMS.

the class RemotePollerAvailabilityService method getAvailabilityByLocation.

@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Path("availability/{location}")
public OnmsLocationAvailDefinitionList getAvailabilityByLocation(@Context final UriInfo uriInfo, @PathParam("location") String location) {
    final MultivaluedMap<String, String> queryParameters = uriInfo.getQueryParameters();
    OnmsMonitoringLocation locationDefinition = m_monitoringLocationDao.get(location);
    if (locationDefinition == null) {
        throw getException(Status.BAD_REQUEST, "Cannot find location definition: {}", location);
    }
    Collection<OnmsLocationMonitor> monitors = m_locationMonitorDao.findByLocationDefinition(locationDefinition);
    OnmsLocationAvailDefinitionList availList = getAvailabilityList(createTimeChunker(queryParameters), getSortedApplications(), monitors, null);
    return availList;
}
Also used : OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor) OnmsLocationAvailDefinitionList(org.opennms.netmgt.model.OnmsLocationAvailDefinitionList) OnmsMonitoringLocation(org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 10 with OnmsLocationMonitor

use of org.opennms.netmgt.model.OnmsLocationMonitor in project opennms by OpenNMS.

the class RemotePollerAvailabilityService method removeUnneededMonitors.

private static void removeUnneededMonitors(Collection<OnmsLocationSpecificStatus> statusesPeriod, Collection<OnmsLocationMonitor> selectedMonitors) {
    if (selectedMonitors != null) {
        Collection<OnmsLocationSpecificStatus> unneededStatuses = new ArrayList<OnmsLocationSpecificStatus>();
        for (OnmsLocationSpecificStatus status : statusesPeriod) {
            for (OnmsLocationMonitor monitor : selectedMonitors) {
                if (status.getLocationMonitor().getId() == monitor.getId()) {
                    unneededStatuses.add(status);
                }
            }
        }
        statusesPeriod.removeAll(unneededStatuses);
    }
}
Also used : OnmsLocationSpecificStatus(org.opennms.netmgt.model.OnmsLocationSpecificStatus) ArrayList(java.util.ArrayList) OnmsLocationMonitor(org.opennms.netmgt.model.OnmsLocationMonitor)

Aggregations

OnmsLocationMonitor (org.opennms.netmgt.model.OnmsLocationMonitor)53 OnmsMonitoringLocation (org.opennms.netmgt.model.monitoringLocations.OnmsMonitoringLocation)18 Date (java.util.Date)15 OnmsMonitoredService (org.opennms.netmgt.model.OnmsMonitoredService)15 ArrayList (java.util.ArrayList)14 OnmsApplication (org.opennms.netmgt.model.OnmsApplication)14 OnmsLocationSpecificStatus (org.opennms.netmgt.model.OnmsLocationSpecificStatus)14 Transactional (org.springframework.transaction.annotation.Transactional)10 LinkedList (java.util.LinkedList)8 Test (org.junit.Test)6 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)6 LocationMonitorIdCommand (org.opennms.web.svclayer.model.LocationMonitorIdCommand)6 BindException (org.springframework.validation.BindException)6 HashSet (java.util.HashSet)5 ObjectError (org.springframework.validation.ObjectError)5 GWTLocationMonitor (org.opennms.features.poller.remote.gwt.client.GWTLocationMonitor)4 OnmsNode (org.opennms.netmgt.model.OnmsNode)4 Criteria (org.opennms.core.criteria.Criteria)3 ApplicationInfo (org.opennms.features.poller.remote.gwt.client.ApplicationInfo)3 LocationMonitorState (org.opennms.features.poller.remote.gwt.client.LocationMonitorState)3