本文整理匯總了Java中org.opennms.netmgt.model.OnmsOutage類的典型用法代碼示例。如果您正苦於以下問題:Java OnmsOutage類的具體用法?Java OnmsOutage怎麽用?Java OnmsOutage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
OnmsOutage類屬於org.opennms.netmgt.model包,在下文中一共展示了OnmsOutage類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
public static void main(String[] args) {
logger.info("OpenNMS Rest Client API");
String baseUrl = "http://localhost:8980/opennms/";
String username = "admin";
String password = "admin";
logger.info("Getting Outages from " + baseUrl);
try {
RestConnectionParameter restConnectionParameter = new OnmsRestConnectionParameter(baseUrl, username, password);
List<OnmsOutage> outages = RestOutageProvider.getOutages(RestHelper.createApacheHttpClient(restConnectionParameter), "", "");
logger.info("Got '{}' from '{}'", outages.size(), baseUrl);
logger.info("Thanks for computing with OpenNMS!");
} catch (MalformedURLException e) {
logger.error("Invalid base URL '{}'", baseUrl, e);
System.exit(1);
}
}
示例2: matchingCurrentOutages
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
/** {@inheritDoc} */
public Collection<OnmsOutage> matchingCurrentOutages(final ServiceSelector selector) {
final Set<InetAddress> matchingAddrs = new HashSet<InetAddress>(FilterDaoFactory.getInstance().getIPAddressList(selector.getFilterRule()));
final Set<String> matchingSvcs = new HashSet<String>(selector.getServiceNames());
final List<OnmsOutage> matchingOutages = new LinkedList<OnmsOutage>();
final Collection<OnmsOutage> outages = currentOutages();
for (final OnmsOutage outage : outages) {
final OnmsMonitoredService svc = outage.getMonitoredService();
if ((matchingSvcs.contains(svc.getServiceName()) || matchingSvcs.isEmpty()) && matchingAddrs.contains(svc.getIpAddress())) {
matchingOutages.add(outage);
}
}
return matchingOutages;
}
示例3: testOutages
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
@Test
@Transactional
public void testOutages() {
assertLoadAll(OnmsOutage.class, new EmptyChecker<OnmsOutage>() {
public void check(OnmsOutage entity) {
assertNotNull("monitored service should not be null", entity.getMonitoredService());
assertNotNull("ip address should not be null", entity.getIpAddress());
assertNotNull("node ID should not be null", entity.getNodeId());
assertNotNull("service lost event should not be null", entity.getServiceLostEvent());
assertNotNull("service lost event UEI should not be null", entity.getServiceLostEvent().getEventUei());
if (entity.getIfRegainedService() != null) {
assertNotNull("outage has ended (ifregainedservice) so service regained event should not be null", entity.getServiceRegainedEvent());
assertNotNull("outage has ended (ifregainedservice) so service regained event UEI should not be null", entity.getServiceRegainedEvent().getEventUei());
}
}
});
}
示例4: testAliases
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
@Test
public void testAliases() throws Exception {
final CriteriaBuilder builder = new CriteriaBuilder(OnmsAlarm.class);
builder.distinct();
builder.fetch("firstEvent", FetchType.EAGER);
builder.fetch("lastEvent", FetchType.EAGER);
builder.alias("node", "node", JoinType.LEFT_JOIN);
builder.alias("node.snmpInterfaces", "snmpInterface", JoinType.LEFT_JOIN);
builder.alias("node.ipInterfaces", "ipInterface", JoinType.LEFT_JOIN);
builder.alias("ipInterface.monitoredServices", "monitoredService", JoinType.LEFT_JOIN);
builder.alias("monitoredService.currentOutages", "currentOutage", JoinType.LEFT_JOIN);
builder.alias("currentOutage.monitoredService", "service", JoinType.LEFT_JOIN);
final Criteria crit = builder.toCriteria();
assertEquals(OnmsIpInterface.class, crit.getType("ipInterface"));
assertEquals(OnmsMonitoredService.class, crit.getType("monitoredService"));
assertEquals(OnmsOutage.class, crit.getType("currentOutage"));
assertEquals(OnmsMonitoredService.class, crit.getType("service"));
}
示例5: mapOnmsOutageToOutage
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
private Outage mapOnmsOutageToOutage(OnmsOutage onmsOutage) {
if(onmsOutage != null){
Outage outage = new Outage();
final String outageAddress = str(onmsOutage.getIpAddress());
outage.outageId = onmsOutage.getId();
outage.ipAddress = outageAddress;
outage.hostname = outageAddress;
outage.lostServiceEventId = onmsOutage.getServiceLostEvent() != null ? onmsOutage.getServiceLostEvent().getId() : 0;
//outage.lostServiceNotificationAcknowledgedBy =
outage.lostServiceTime = onmsOutage.getIfLostService();
outage.nodeId = onmsOutage.getNodeId();
outage.nodeLabel = m_nodeDao.get(onmsOutage.getNodeId()).getLabel();
outage.regainedServiceEventId = onmsOutage.getServiceRegainedEvent() != null ? onmsOutage.getServiceRegainedEvent().getId() : 0;
outage.regainedServiceTime = onmsOutage.getIfRegainedService();
outage.serviceId = onmsOutage.getServiceId();
outage.serviceName = onmsOutage.getMonitoredService() != null ? onmsOutage.getMonitoredService().getServiceName() : "";
outage.suppressedBy = onmsOutage.getSuppressedBy();
outage.suppressTime = onmsOutage.getSuppressTime();
return outage;
}else{
return null;
}
}
示例6: getOutageSummary
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
private List<OutageSummary> getOutageSummary(List<OnmsOutage> onmsOutages) {
List<OutageSummary> outages = new ArrayList<OutageSummary>();
if(onmsOutages.size() > 0){
Iterator<OnmsOutage> outageIt = onmsOutages.iterator();
while(outageIt.hasNext()){
OnmsOutage outage = outageIt.next();
if(outage.getIfRegainedService() == null){
outages.add(mapOnmsOutageToOutageSummary(outage));
}
}
return elimenateDuplicates(outages);
}else {
return outages;
}
}
示例7: getOutages
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
/**
* <p>getOutages</p>
*
* @return a {@link org.opennms.netmgt.model.OnmsOutageCollection} object.
*/
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML})
@Transactional
public OnmsOutageCollection getOutages() {
readLock();
try {
final CriteriaBuilder builder = new CriteriaBuilder(OnmsOutage.class);
applyQueryFilters(m_uriInfo.getQueryParameters(), builder);
final OnmsOutageCollection coll = new OnmsOutageCollection(m_outageDao.findMatching(builder.toCriteria()));
//For getting totalCount
coll.setTotalCount(m_outageDao.countMatching(builder.count().toCriteria()));
return coll;
} finally {
readUnlock();
}
}
示例8: testLoadOneOutage
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
@Test
public void testLoadOneOutage() {
assertNotNull(outageService);
assertNotNull(outageDao);
Integer outageId = Integer.valueOf(505);
OnmsOutage outage = new OnmsOutage();
outage.setId(505);
expect(outageDao.load(outageId)).andReturn(outage);
replay(outageDao);
OnmsOutage outage2 = outageService.load(outageId);
verify(outageDao);
assertTrue("Yay we can load a single outage... ", outage
.equals(outage2));
}
示例9: testCurrentOutages
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
@Test
public void testCurrentOutages() {
assertNotNull(outageService);
assertNotNull(outageDao);
Collection<OnmsOutage> expectedOutages = new HashSet<OnmsOutage>();
OnmsOutage expectedCurrent = new OnmsOutage();
expectedCurrent.setId(1);
expectedOutages.add(expectedCurrent);
expect(outageDao.currentOutages()).andReturn(expectedOutages);
replay(outageDao);
Collection<OnmsOutage> current = outageService.getCurrentOutages();
verify(outageDao);
assertTrue("Current Outages", current.equals(expectedOutages));
}
示例10: testCurrentByRange
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
@Test
public void testCurrentByRange() {
assertNotNull(outageService);
assertNotNull(outageDao);
List<OnmsOutage> expectedOutages = new LinkedList<OnmsOutage>();
OnmsOutage expectedCurrent = new OnmsOutage();
expectedCurrent.setId(1);
expectedCurrent.setMonitoredService(new OnmsMonitoredService());
expectedCurrent.getMonitoredService().setIpInterface(new OnmsIpInterface());
expectedCurrent.getMonitoredService().getIpInterface().setNode(new OnmsNode());
expectedOutages.add(expectedCurrent);
OnmsCriteria criteria = new OnmsCriteria(OnmsOutage.class);
expect(outageDao.findMatching(criteria)).andReturn(expectedOutages);
replay(outageDao);
Collection<OnmsOutage> outages = outageService.getOutagesByRange(1, 1, "iflostservice", "asc", criteria);
verify(outageDao);
assertTrue("Current Outages", outages.equals(expectedOutages));
}
示例11: createOutageForService
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
protected void createOutageForService(OnmsMonitoredService monSvc) {
OnmsEvent outageEvent = new OnmsEvent();
outageEvent.setEventUei("TEST_UEI");
outageEvent.setDistPoller(monSvc.getIpInterface().getNode().getDistPoller());
outageEvent.setEventTime(new Date());
outageEvent.setEventSource("Me");
outageEvent.setEventCreateTime(new Date());
outageEvent.setEventSeverity(0);
outageEvent.setEventLog("L");
outageEvent.setEventDisplay("D");
m_eventDao.save(outageEvent);
m_eventDao.flush();
OnmsOutage outage = new OnmsOutage(new Date(), outageEvent, monSvc);
m_outageDao.save(outage);
m_outageDao.flush();
}
示例12: getOutages
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
/**
* <p>getOutages</p>
*
* @return a {@link org.opennms.netmgt.model.OnmsOutageCollection} object.
*/
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
@Transactional
public OnmsOutageCollection getOutages() {
readLock();
try {
final CriteriaBuilder builder = new CriteriaBuilder(OnmsOutage.class);
applyQueryFilters(m_uriInfo.getQueryParameters(), builder);
final OnmsOutageCollection coll = new OnmsOutageCollection(m_outageDao.findMatching(builder.toCriteria()));
//For getting totalCount
coll.setTotalCount(m_outageDao.countMatching(builder.count().toCriteria()));
return coll;
} finally {
readUnlock();
}
}
示例13: testLoadOneOutage
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
@Test
public void testLoadOneOutage() {
assertNotNull(outageService);
assertNotNull(outageDao);
Integer outageId = new Integer(505);
OnmsOutage outage = new OnmsOutage();
outage.setId(505);
expect(outageDao.load(outageId)).andReturn(outage);
replay(outageDao);
OnmsOutage outage2 = outageService.load(outageId);
verify(outageDao);
assertTrue("Yay we can load a single outage... ", outage
.equals(outage2));
}
示例14: getOutages
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
public static List<OnmsOutage> getOutages(ApacheHttpClient httpClient, String baseUrl, String parameters) {
WebResource webResource = httpClient.resource(baseUrl + "rest/outages" + parameters);
List<OnmsOutage> outages = null;
try {
outages = webResource.header("Accept", "application/xml").get(new GenericType<List<OnmsOutage>>() {
});
} catch (Exception ex) {
logger.debug("Rest-Call for Outages went wrong", ex);
}
return outages;
}
示例15: getOutagesForNodes
import org.opennms.netmgt.model.OnmsOutage; //導入依賴的package包/類
public static Map<OnmsNode, List<OnmsOutage>> getOutagesForNodes(ApacheHttpClient httpClient, String baseUrl, List<OnmsNode> nodes, String parameters) {
Map<OnmsNode, List<OnmsOutage>> nodesToOutages = new HashMap<OnmsNode, List<OnmsOutage>>();
for (OnmsNode node : nodes) {
WebResource webResource = httpClient.resource(baseUrl + "rest/outages/forNode/" + node.getId() + parameters);
List<OnmsOutage> outages = null;
try {
outages = webResource.header("Accept", "application/xml").get(new GenericType<List<OnmsOutage>>() {
});
} catch (Exception ex) {
logger.debug("Rest-Call for Outages for Node '{}' went wrong", node, ex);
}
nodesToOutages.put(node, outages);
}
return nodesToOutages;
}