当前位置: 首页>>代码示例>>Java>>正文


Java OnmsNode.getForeignId方法代码示例

本文整理汇总了Java中org.opennms.netmgt.model.OnmsNode.getForeignId方法的典型用法代码示例。如果您正苦于以下问题:Java OnmsNode.getForeignId方法的具体用法?Java OnmsNode.getForeignId怎么用?Java OnmsNode.getForeignId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.opennms.netmgt.model.OnmsNode的用法示例。


在下文中一共展示了OnmsNode.getForeignId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isRequisitioned

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
public boolean isRequisitioned(OnmsNode node) {
	String foreignSource = node.getForeignSource();
	String foreignId = node.getForeignId();
	
	// is this a discovered node
	if (foreignSource == null) return false;
	
	OnmsNode reqNode = getRequisitionedNode(foreignSource, foreignId);
	if (reqNode == null) { 
		// this is no requisition node?
		LogUtils.errorf("No requistion exists for node with foreignSource %s and foreignId %s.  Treating node as unrequistioned", foreignSource, foreignId);
		return false;
	} else {
		return true;
	}
	
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:18,代码来源:DefaultProvisionService.java

示例2: parseString

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
 * Parses the string.
 *
 * <p>Valid placeholders are:</p>
 * <ul>
 * <li><b>ipaddr</b>, The Node IP Address</li>
 * <li><b>step</b>, The Collection Step in seconds</li>
 * <li><b>nodeId</b>, The Node ID</li>
 * <li><b>nodeLabel</b>, The Node Label</li>
 * <li><b>foreignId</b>, The Node Foreign ID</li>
 * <li><b>foreignSource</b>, The Node Foreign Source</li>
 * <li>Any asset property defined on the node.</li>
 * </ul>
 * 
 * @param reference the reference
 * @param unformattedString the unformatted string
 * @param node the node
 * @param ipAddress the IP address
 * @return the string
 * @throws IllegalArgumentException the illegal argument exception
 */
protected String parseString(final String reference, final String unformattedString, final OnmsNode node, final String ipAddress) throws IllegalArgumentException {
    if (unformattedString == null)
        return null;
    String formattedString = unformattedString.replaceAll("[{](?i)(ipAddr|ipAddress)[}]", ipAddress);
    formattedString = formattedString.replaceAll("[{](?i)nodeId[}]", node.getNodeId());
    if (node.getLabel() != null)
        formattedString = formattedString.replaceAll("[{](?i)nodeLabel[}]", node.getLabel());
    if (node.getForeignId() != null)
        formattedString = formattedString.replaceAll("[{](?i)foreignId[}]", node.getForeignId());
    if (node.getForeignSource() != null)
        formattedString = formattedString.replaceAll("[{](?i)foreignSource[}]", node.getForeignSource());
    if (node.getAssetRecord() != null) {
        BeanWrapper wrapper = new BeanWrapperImpl(node.getAssetRecord());
        for (PropertyDescriptor p : wrapper.getPropertyDescriptors()) {
            Object obj = wrapper.getPropertyValue(p.getName());
            if (obj != null)
                formattedString = formattedString.replaceAll("[{](?i)" + p.getName() + "[}]", obj.toString());
        }
    }
    if (formattedString.matches(".*[{].+[}].*"))
        throw new IllegalArgumentException("The " + reference + " " + formattedString + " contains unknown placeholders.");
    return formattedString;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:45,代码来源:AbstractXmlCollectionHandler.java

示例3: createChildResource

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
 * <p>createChildResource</p>
 *
 * @param node a {@link org.opennms.netmgt.model.OnmsNode} object.
 * @return a {@link org.opennms.netmgt.model.OnmsResource} object.
 */
public OnmsResource createChildResource(OnmsNode node) {
    NodeChildResourceLoader loader = new NodeChildResourceLoader(node.getId(), node.getForeignSource(), node.getForeignId());
    OnmsResource r = new OnmsResource(node.getId().toString(), node.getLabel(), this, s_emptyAttributeSet, new LazyList<OnmsResource>(loader));
    r.setEntity(node);
    loader.setParent(r);

    return r;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:15,代码来源:NodeResourceType.java

示例4: createScheduleForNode

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private NodeScanSchedule createScheduleForNode(final OnmsNode node, final boolean force) {
     Assert.notNull(node, "Node may not be null");
     final String actualForeignSource = node.getForeignSource();
     if (actualForeignSource == null && !isDiscoveryEnabled()) {
infof(this, "Not scheduling node %s to be scanned since it has a null foreignSource and handling of discovered nodes is disabled in provisiond", node);
         return null;
     }

     final String effectiveForeignSource = actualForeignSource == null ? "default" : actualForeignSource;
     try {
     	final ForeignSource fs = m_foreignSourceRepository.getForeignSource(effectiveForeignSource);

     	final Duration scanInterval = fs.getScanInterval();
     	Duration initialDelay = Duration.ZERO;
         if (node.getLastCapsdPoll() != null && !force) {
         	final DateTime nextPoll = new DateTime(node.getLastCapsdPoll().getTime()).plus(scanInterval);
             final DateTime now = new DateTime();
             if (nextPoll.isAfter(now)) {
                 initialDelay = new Duration(now, nextPoll);
             }
         }

         return new NodeScanSchedule(node.getId(), actualForeignSource, node.getForeignId(), initialDelay, scanInterval);
     } catch (final ForeignSourceRepositoryException e) {
         warnf(this, e, "unable to get foreign source '%s' from repository", effectiveForeignSource);
         return null;
     }
 }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:29,代码来源:DefaultProvisionService.java

示例5: initialize

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
 * Initializes this instance for a given collection agent and a parameter map.
 *
 * @param agent      the collection agent
 * @param parameters the parameter map
 * @throws CollectionInitializationException
 *
 */
public void initialize(CollectionAgent agent, Map<String, Object> parameters) throws CollectionInitializationException {
    OnmsNode onmsNode = m_nodeDao.get(agent.getNodeId());

    // retrieve the assets and
    String vmwareManagementServer = onmsNode.getAssetRecord().getVmwareManagementServer();
    String vmwareManagedEntityType = onmsNode.getAssetRecord().getVmwareManagedEntityType();
    String vmwareManagedObjectId = onmsNode.getForeignId();

    parameters.put("vmwareManagementServer", vmwareManagementServer);
    parameters.put("vmwareManagedEntityType", vmwareManagedEntityType);
    parameters.put("vmwareManagedObjectId", vmwareManagedObjectId);
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:21,代码来源:VmwareCollector.java

示例6: NodeEntry

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
public NodeEntry(final OnmsNode node) {
    final OnmsAssetRecord assetRecord = node.getAssetRecord();
    if (assetRecord != null && assetRecord.getGeolocation() != null) {
        final OnmsGeolocation geolocation = assetRecord.getGeolocation();
        m_longitude = geolocation.getLongitude();
        m_latitude  = geolocation.getLatitude();
    }

    m_nodeId        = node.getId();
    m_nodeLabel     = node.getLabel();
    m_foreignSource = node.getForeignSource();
    m_foreignId     = node.getForeignId();
    
    if (assetRecord != null) {
        m_maintcontract = assetRecord.getMaintcontract();
        m_description   = assetRecord.getDescription();
    }

    if (node.getPrimaryInterface() != null) {
        m_ipAddress = InetAddressUtils.str(node.getPrimaryInterface().getIpAddress());
    }
    
    if (node.getCategories() != null && node.getCategories().size() > 0) {
        for (final OnmsCategory category : node.getCategories()) {
            m_categories.add(category.getName());
        }
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:29,代码来源:MapWidgetComponent.java

示例7: findNodeChildResources

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/** {@inheritDoc} */
public List<OnmsResource> findNodeChildResources(OnmsNode node) {
    List<OnmsResource> resources = new ArrayList<OnmsResource>();
    if (node != null) {
        if (ResourceTypeUtils.isStoreByForeignSource() && node.getForeignSource() != null) {
            String source = node.getForeignSource() + ':' + node.getForeignId();
            resources.addAll(findNodeSourceChildResources(source));
        } else {
            resources.addAll(findNodeChildResources(node.getId()));
        }
    }
    return resources;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:14,代码来源:DefaultResourceService.java

示例8: findNodeResources

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
/**
 * Returns a list of resources for all the nodes.
 *
 * <ul>
 * <li>A resource must be listed once no matter if storeByForeignSource is enabled or not</li>
 * <li>Discovered nodes should have resources based on the nodeId</li>
 * <li>A requisitioned node should have resources based on nodeSource if storeByForeignSource is enabled</li>
 * <li>A requisitioned node should have resources based on nodeId if storeByForeignSource is not enabled</li>
 * </ul>
 * 
 * <p>TODO It does not currently fully check that an IP address that is found to have
 * distributed response time data is in the database on the proper node so it can have false positives.</p>
 * 
 * @return a {@link java.util.List} object.
 */
protected List<OnmsResource> findNodeResources() {
    List<OnmsResource> resources = new LinkedList<OnmsResource>();

    IntSet snmpNodes = findSnmpNodeDirectories();
    Set<String> nodeSources = findNodeSourceDirectories();

    Set<String> responseTimeInterfaces = findChildrenMatchingFilter(new File(getRrdDirectory(), RESPONSE_DIRECTORY), RrdFileConstants.INTERFACE_DIRECTORY_FILTER);
    Set<String> distributedResponseTimeInterfaces = findChildrenChildrenMatchingFilter(new File(new File(getRrdDirectory(), RESPONSE_DIRECTORY), "distributed"), RrdFileConstants.INTERFACE_DIRECTORY_FILTER);

    List<OnmsNode> nodes = m_nodeDao.findAll();
    IntSet nodesFound = new IntSet();
    for (OnmsNode node : nodes) {
        // Only returns non-deleted nodes to fix NMS-2977
        if (nodesFound.contains(node.getId()) || (node.getType() != null && node.getType().equals("D"))) {
            continue;
        }
        boolean nodeIdfound = false;
        boolean nodeSourcefound = false;
        boolean responseTimeFound = false;
        if (node.getForeignSource() != null && node.getForeignId() != null && nodeSources.contains(node.getForeignSource() + ":" + node.getForeignId())) {
            nodeSourcefound = true;
        } else if (snmpNodes.contains(node.getId())) {
            nodeIdfound = true;
        } else if (responseTimeInterfaces.size() > 0 || distributedResponseTimeInterfaces.size() > 0) {
            for (final OnmsIpInterface ip : node.getIpInterfaces()) {
                final String addr = InetAddressUtils.str(ip.getIpAddress());
                if (responseTimeInterfaces.contains(addr) || distributedResponseTimeInterfaces.contains(addr)) {
                    responseTimeFound = true;
                    break;
                }
            }
        }
        boolean storeByFS = ResourceTypeUtils.isStoreByForeignSource();
        if (nodeSourcefound || (responseTimeFound && storeByFS)) {
            log().debug("findNodeResources: adding resources for nodeSource " + node.getForeignSource() + ":" + node.getForeignId());
            resources.add(m_nodeSourceResourceType.createChildResource(node.getForeignSource() + ":" + node.getForeignId()));
            nodesFound.add(node.getId());
        }
        if (nodeIdfound || (responseTimeFound && !storeByFS)) {
            log().debug("findNodeResources: adding resources for nodeId " + node.getId());
            resources.add(m_nodeResourceType.createChildResource(node));
            nodesFound.add(node.getId());
        }
    }

    return resources;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:63,代码来源:DefaultResourceDao.java

示例9: declareBeans

import org.opennms.netmgt.model.OnmsNode; //导入方法依赖的package包/类
private void declareBeans(BSFManager bsfManager) throws BSFException {
    NodeDao nodeDao = Notifd.getInstance().getNodeDao();
    Integer nodeId;
    try {
        nodeId = Integer.valueOf(m_notifParams.get(NotificationManager.PARAM_NODE));
    } catch (NumberFormatException nfe) {
        nodeId = null;
    }

    OnmsNode node = null;
    OnmsAssetRecord assets = null;
    List<String> categories = new ArrayList<String>();
    String nodeLabel = null;
    String foreignSource = null;
    String foreignId = null;

    if (nodeId != null) {
        node = nodeDao.get(nodeId);
        nodeLabel = node.getLabel();
        assets = node.getAssetRecord();
        for (OnmsCategory cat : node.getCategories()) {
            categories.add(cat.getName());
        }
        foreignSource = node.getForeignSource();
        foreignId = node.getForeignId();
    }

    bsfManager.declareBean("bsf_notif_strategy", this, BSFNotificationStrategy.class);
    
    retrieveParams();
    bsfManager.declareBean("notif_params", m_notifParams, Map.class);

    bsfManager.declareBean("node_label", nodeLabel, String.class);
    bsfManager.declareBean("foreign_source", foreignSource, String.class);
    bsfManager.declareBean("foreign_id", foreignId, String.class);
    bsfManager.declareBean("node_assets", assets, OnmsAssetRecord.class);
    bsfManager.declareBean("node_categories", categories, List.class);
    bsfManager.declareBean("node", node, OnmsNode.class);

    for (Argument arg : m_arguments) {
        if (NotificationManager.PARAM_TEXT_MSG.equals(arg.getSwitch())) bsfManager.declareBean("text_message", arg.getValue(), String.class);
        if (NotificationManager.PARAM_NUM_MSG.equals(arg.getSwitch())) bsfManager.declareBean("numeric_message", arg.getValue(), String.class);
        if (NotificationManager.PARAM_NODE.equals(arg.getSwitch())) bsfManager.declareBean("node_id", arg.getValue(), String.class);
        if (NotificationManager.PARAM_INTERFACE.equals(arg.getSwitch())) bsfManager.declareBean("ip_addr", arg.getValue(), String.class);
        if (NotificationManager.PARAM_SERVICE.equals(arg.getSwitch())) bsfManager.declareBean("svc_name", arg.getValue(), String.class);
        if (NotificationManager.PARAM_SUBJECT.equals(arg.getSwitch())) bsfManager.declareBean("subject", arg.getValue(), String.class);
        if (NotificationManager.PARAM_EMAIL.equals(arg.getSwitch())) bsfManager.declareBean("email", arg.getValue(), String.class);
        if (NotificationManager.PARAM_PAGER_EMAIL.equals(arg.getSwitch())) bsfManager.declareBean("pager_email", arg.getValue(), String.class);
        if (NotificationManager.PARAM_XMPP_ADDRESS.equals(arg.getSwitch())) bsfManager.declareBean("xmpp_address", arg.getValue(), String.class);
        if (NotificationManager.PARAM_TEXT_PAGER_PIN.equals(arg.getSwitch())) bsfManager.declareBean("text_pin", arg.getValue(), String.class);
        if (NotificationManager.PARAM_NUM_PAGER_PIN.equals(arg.getSwitch())) bsfManager.declareBean("numeric_pin", arg.getValue(), String.class);
        if (NotificationManager.PARAM_WORK_PHONE.equals(arg.getSwitch())) bsfManager.declareBean("work_phone", arg.getValue(), String.class);
        if (NotificationManager.PARAM_HOME_PHONE.equals(arg.getSwitch())) bsfManager.declareBean("home_phone", arg.getValue(), String.class);
        if (NotificationManager.PARAM_MOBILE_PHONE.equals(arg.getSwitch())) bsfManager.declareBean("mobile_phone", arg.getValue(), String.class);
        if (NotificationManager.PARAM_TUI_PIN.equals(arg.getSwitch())) bsfManager.declareBean("phone_pin", arg.getValue(), String.class);
        if (NotificationManager.PARAM_MICROBLOG_USERNAME.equals(arg.getSwitch())) bsfManager.declareBean("microblog_username", arg.getValue(), String.class);
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:59,代码来源:BSFNotificationStrategy.java


注:本文中的org.opennms.netmgt.model.OnmsNode.getForeignId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。