本文整理汇总了Java中org.opennms.netmgt.provision.persist.foreignsource.ForeignSource.setName方法的典型用法代码示例。如果您正苦于以下问题:Java ForeignSource.setName方法的具体用法?Java ForeignSource.setName怎么用?Java ForeignSource.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.opennms.netmgt.provision.persist.foreignsource.ForeignSource
的用法示例。
在下文中一共展示了ForeignSource.setName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
m_foreignSource = new ForeignSource();
m_foreignSource.setName("imported:");
m_foreignSource.setScanInterval(Duration.standardDays(1));
final PluginConfig detector = new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector");
detector.addParameter("timeout", "1000");
detector.addParameter("retries", "0");
m_foreignSource.addDetector(detector);
m_foreignSourceRepository = new MockForeignSourceRepository();
m_foreignSourceRepository.putDefaultForeignSource(m_foreignSource);
m_provisionService.setForeignSourceRepository(m_foreignSourceRepository);
m_provisioner.setEventForwarder(m_eventSubscriber);
m_provisioner.start();
}
示例2: putDefaultForeignSource
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void putDefaultForeignSource(ForeignSource foreignSource) throws ForeignSourceRepositoryException {
if (foreignSource == null) {
throw new ForeignSourceRepositoryException("foreign source was null");
}
foreignSource.setName("default");
final File outputFile = new File(ConfigFileConstants.getFilePathString() + "default-foreign-source.xml");
Writer writer = null;
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream(outputFile);
writer = new OutputStreamWriter(outputStream, "UTF-8");
JaxbUtils.marshal(foreignSource, writer);
} catch (final Throwable e) {
throw new ForeignSourceRepositoryException("unable to write requisition to " + outputFile.getPath(), e);
} finally {
IOUtils.closeQuietly(writer);
IOUtils.closeQuietly(outputStream);
}
}
示例3: getForeignSource
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
/** {@inheritDoc} */
public ForeignSource getForeignSource(final String foreignSourceName) throws ForeignSourceRepositoryException {
if (foreignSourceName == null) {
throw new ForeignSourceRepositoryException("can't get a foreign source with a null name!");
}
m_readLock.lock();
try {
final File inputFile = RequisitionFileUtils.encodeFileName(m_foreignSourcePath, foreignSourceName);
if (inputFile != null && inputFile.exists()) {
return RequisitionFileUtils.getForeignSourceFromFile(inputFile);
} else {
final ForeignSource fs = getDefaultForeignSource();
fs.setName(foreignSourceName);
return fs;
}
} finally {
m_readLock.unlock();
}
}
示例4: getForeignSource
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
/** {@inheritDoc} */
public ForeignSource getForeignSource(final String foreignSourceName) throws ForeignSourceRepositoryException {
if (foreignSourceName == null) {
throw new ForeignSourceRepositoryException("can't get a foreign source with a null name!");
}
m_readLock.lock();
try {
return m_foreignSources.getContents(foreignSourceName+".xml");
} catch (FileNotFoundException e) {
final ForeignSource fs = getDefaultForeignSource();
fs.setName(foreignSourceName);
return fs;
} finally {
m_readLock.unlock();
}
}
示例5: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Before
public void setUp() {
MockLogAppender.setupLogging();
final MockForeignSourceRepository mfsr = new MockForeignSourceRepository();
final ForeignSource fs = new ForeignSource();
fs.setName("default");
fs.addDetector(new PluginConfig("ICMP", "org.opennms.netmgt.provision.service.MockServiceDetector"));
fs.addDetector(new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector"));
mfsr.putDefaultForeignSource(fs);
m_provisioner.getProvisionService().setForeignSourceRepository(mfsr);
}
示例6: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Before
public void setUp() {
MockLogAppender.setupLogging();
final MockForeignSourceRepository mfsr = new MockForeignSourceRepository();
final ForeignSource fs = new ForeignSource();
fs.setName("default");
fs.addDetector(new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector"));
mfsr.putDefaultForeignSource(fs);
m_provisioner.getProvisionService().setForeignSourceRepository(mfsr);
}
示例7: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Before
public void setUp() {
MockLogAppender.setupLogging();
final MockForeignSourceRepository mfsr = new MockForeignSourceRepository();
final ForeignSource fs = new ForeignSource();
fs.setName("default");
fs.addDetector(new PluginConfig("ICMP", "org.opennms.netmgt.provision.service.MockServiceDetector"));
mfsr.putDefaultForeignSource(fs);
m_provisioner.getProvisionService().setForeignSourceRepository(mfsr);
}
示例8: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
final ForeignSource fs = new ForeignSource();
fs.setName("default");
fs.addDetector(new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector"));
final MockForeignSourceRepository mfsr = new MockForeignSourceRepository();
mfsr.putDefaultForeignSource(fs);
m_provisioner.getProvisionService().setForeignSourceRepository(mfsr);
m_provisioner.start();
}
示例9: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
SnmpPeerFactory.setInstance(m_snmpPeerFactory);
assertTrue(m_snmpPeerFactory instanceof ProxySnmpAgentConfigFactory);
// ensure this property is unset for tests and set it only in tests that need it
System.getProperties().remove("org.opennms.provisiond.enableDeletionOfRequisitionedEntities");
m_eventAnticipator = m_mockEventIpcManager.getEventAnticipator();
//((TransactionAwareEventForwarder)m_provisioner.getEventForwarder()).setEventForwarder(m_mockEventIpcManager);
m_provisioner.start();
m_foreignSource = new ForeignSource();
m_foreignSource.setName("imported:");
m_foreignSource.setScanInterval(Duration.standardDays(1));
final PluginConfig policy = new PluginConfig("setCategory", NodeCategorySettingPolicy.class.getName());
policy.addParameter("category", "TestCategory");
policy.addParameter("label", "localhost");
m_foreignSource.addPolicy(policy);
m_foreignSourceRepository = new MockForeignSourceRepository();
m_foreignSourceRepository.save(m_foreignSource);
m_foreignSourceRepository.flush();
m_provisionService.setForeignSourceRepository(m_foreignSourceRepository);
m_pausibleExecutor.pause();
}
示例10: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Before
public void setUp() {
MockLogAppender.setupLogging();
final MockForeignSourceRepository mfsr = new MockForeignSourceRepository();
final ForeignSource fs = new ForeignSource();
fs.setName("default");
fs.addDetector(new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector"));
PluginConfig policy1 = new PluginConfig("poll-trunk-1", "org.opennms.netmgt.provision.persist.policies.MatchingSnmpInterfacePolicy");
policy1.addParameter("ifDescr", "~^.*Trunk 1.*$");
policy1.addParameter("action", "ENABLE_POLLING");
policy1.addParameter("matchBehavior", "ANY_PARAMETER");
PluginConfig policy2 = new PluginConfig("poll-vlan-600", "org.opennms.netmgt.provision.persist.policies.MatchingIpInterfacePolicy");
policy2.addParameter("ipAddress", "~^10\\.102\\..*$");
policy2.addParameter("action", "ENABLE_SNMP_POLL");
policy2.addParameter("matchBehavior", "ANY_PARAMETER");
System.err.println(policy1.toString());
System.err.println(policy2.toString());
fs.addPolicy(policy1);
fs.addPolicy(policy2);
mfsr.putDefaultForeignSource(fs);
m_provisioner.getProvisionService().setForeignSourceRepository(mfsr);
}
示例11: setUp
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging(true, "ERROR");
SnmpPeerFactory.setInstance(m_snmpPeerFactory);
assertTrue(m_snmpPeerFactory instanceof ProxySnmpAgentConfigFactory);
// ensure this property is unset for tests and set it only in tests that need it
System.getProperties().remove("org.opennms.provisiond.enableDeletionOfRequisitionedEntities");
m_eventAnticipator = m_mockEventIpcManager.getEventAnticipator();
//((TransactionAwareEventForwarder)m_provisioner.getEventForwarder()).setEventForwarder(m_mockEventIpcManager);
m_provisioner.start();
m_foreignSource = new ForeignSource();
m_foreignSource.setName("noRescanOnImport");
m_foreignSource.setScanInterval(Duration.standardDays(1));
final PluginConfig icmpDetector = new PluginConfig("ICMP", IcmpDetector.class.getName());
icmpDetector.addParameter("timeout", "500");
icmpDetector.addParameter("retries", "0");
m_foreignSource.addDetector(icmpDetector);
final PluginConfig snmpDetector = new PluginConfig("SNMP", SnmpDetector.class.getName());
snmpDetector.addParameter("timeout", "500");
snmpDetector.addParameter("retries", "0");
m_foreignSource.addDetector(snmpDetector);
m_foreignSourceRepository = new MockForeignSourceRepository();
m_foreignSourceRepository.save(m_foreignSource);
m_foreignSourceRepository.flush();
m_provisionService.setForeignSourceRepository(m_foreignSourceRepository);
m_pausibleExecutor.pause();
}
示例12: cloneForeignSource
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
/** {@inheritDoc} */
public ForeignSource cloneForeignSource(String name, String target) {
ForeignSource fs = getForeignSource(name);
fs.setDefault(false);
fs.setName(target);
m_deployedForeignSourceRepository.save(fs);
m_pendingForeignSourceRepository.delete(fs);
return m_deployedForeignSourceRepository.getForeignSource(target);
}
示例13: getForeignSource
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Override
public ForeignSource getForeignSource(final String foreignSourceName) throws ForeignSourceRepositoryException {
readLock();
try {
ForeignSource fs = getForeignSourceMap().get(foreignSourceName);
if (fs == null) {
fs = getDefaultForeignSource();
fs.setName(foreignSourceName);
}
return fs;
} finally {
readUnlock();
}
}
示例14: putDefaultForeignSource
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
public void putDefaultForeignSource(final ForeignSource foreignSource) throws ForeignSourceRepositoryException {
if (foreignSource == null) {
throw new ForeignSourceRepositoryException("foreign source was null");
}
foreignSource.setDefault(true);
foreignSource.setName("default");
save(foreignSource);
}
示例15: testPopulateWithIpv6SnmpAndNodeScan
import org.opennms.netmgt.provision.persist.foreignsource.ForeignSource; //导入方法依赖的package包/类
@Test(timeout=300000)
@JUnitTemporaryDatabase // Relies on records created in @Before so we need a fresh database
@JUnitSnmpAgents({
@JUnitSnmpAgent(host="10.1.15.245", resource="classpath:snmpwalk-demo.properties"),
@JUnitSnmpAgent(host="10.3.20.23", resource="classpath:snmpwalk-demo.properties"),
@JUnitSnmpAgent(host="2001:0470:e2f1:cafe:16c1:7cff:12d6:7bb9", resource="classpath:snmpwalk-demo.properties")
})
@Transactional
public void testPopulateWithIpv6SnmpAndNodeScan() throws Exception {
final ForeignSource fs = new ForeignSource();
fs.setName("matt:");
fs.addDetector(new PluginConfig("SNMP", "org.opennms.netmgt.provision.detector.snmp.SnmpDetector"));
m_foreignSourceRepository.putDefaultForeignSource(fs);
importFromResource("classpath:/requisition_then_scanv6.xml", true);
//Verify distpoller count
assertEquals(1, getDistPollerDao().countAll());
//Verify node count
assertEquals(1, getNodeDao().countAll());
//Verify ipinterface count
assertEquals(1, getInterfaceDao().countAll());
//Verify ifservices count
assertEquals(1, getMonitoredServiceDao().countAll());
//Verify service count
assertEquals(1, getServiceTypeDao().countAll());
//Verify snmpInterface count
assertEquals(1, getSnmpInterfaceDao().countAll());
final List<OnmsNode> nodes = getNodeDao().findAll();
final OnmsNode node = nodes.get(0);
final NodeScan scan = m_provisioner.createNodeScan(node.getId(), node.getForeignSource(), node.getForeignId());
runScan(scan);
//Verify distpoller count
assertEquals(1, getDistPollerDao().countAll());
//Verify node count
assertEquals(1, getNodeDao().countAll());
//Verify ipinterface count
assertEquals("Unexpected number of IP interfaces found: " + getInterfaceDao().findAll(), 3, getInterfaceDao().countAll());
//Verify ifservices count - discover snmp service on other if
assertEquals("Unexpected number of services found: "+getMonitoredServiceDao().findAll(), 3, getMonitoredServiceDao().countAll());
//Verify service count
assertEquals("Unexpected number of service types found: " + getServiceTypeDao().findAll(), 1, getServiceTypeDao().countAll());
//Verify snmpInterface count
assertEquals("Unexpected number of SNMP interfaces found: " + getSnmpInterfaceDao().findAll(), 6, getSnmpInterfaceDao().countAll());
// Ensure that collection is on for all ip interfaces
for(OnmsIpInterface iface : getInterfaceDao().findAll()) {
OnmsSnmpInterface snmpIface = iface.getSnmpInterface();
assertNotNull("Expected an snmp interface associated with "+iface.getIpAddress(), snmpIface);
assertTrue("Expected snmp interface associated with "+iface.getIpAddress()+" to have collection enabled.", snmpIface.isCollectionEnabled());
}
}