Java Code Examples for org.apache.commons.configuration.HierarchicalConfiguration#getDouble()
The following examples show how to use
org.apache.commons.configuration.HierarchicalConfiguration#getDouble() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PolatisPowerConfig.java From onos with Apache License 2.0 | 6 votes |
private Long acquirePortAttenuation(PortNumber port) { String filter = getPortAttenuationFilter(port); String reply = netconfGet(handler(), filter); HierarchicalConfiguration info = configAt(reply, KEY_DATA_VOA_PORT); if (info == null) { return null; } long attenuation = 0; try { attenuation = (long) (info.getDouble(KEY_ATTEN_LEVEL) * VOA_MULTIPLIER); } catch (NoSuchElementException e) { log.debug("Could not find atten-level for port {}", port); } return attenuation; }
Example 2
Source File: OplinkOpticalPowerConfig.java From onos with Apache License 2.0 | 6 votes |
private Range<Long> getPowerRange(PortNumber port, String directionKey, String minKey, String maxKey) { // TODO // Optical protection switch does not support power range configuration, it'll reply error. // To prevent replying error log flooding from netconf session when polling all ports information, // use general power range of [-60, 60] instead. if (handler().get(DeviceService.class).getDevice(data().deviceId()).type() == Device.Type.FIBER_SWITCH) { return RANGE_GENERAL; } String reply = netconfGet(handler(), getPowerRangeFilter(port, directionKey)); HierarchicalConfiguration info = configAt(reply, KEY_PORTS_PORT_PROPERTY); if (info == null) { return null; } long minPower = (long) (info.getDouble(minKey) * POWER_MULTIPLIER); long maxPower = (long) (info.getDouble(maxKey) * POWER_MULTIPLIER); return Range.closed(minPower, maxPower); }
Example 3
Source File: CzechLightFlowRuleProgrammable.java From onos with Apache License 2.0 | 6 votes |
private static CzechLightRouting confToMCRouting(final String keyPrefix, final Map<String, MediaChannelDefinition> allChannels, final HierarchicalConfiguration item) { if (!item.containsKey(keyPrefix + ".port")) { return null; } // the leaf port is either just a number, or a number prefixed by "E" final var portStr = item.getString(keyPrefix + ".port"); final int leafPort = Integer.parseInt(portStr.startsWith(CzechLightDiscovery.LINE_EXPRESS_PREFIX) ? portStr.substring(1) : portStr); return new CzechLightRouting( allChannels.get(item.getString("channel")), leafPort, new MCManipulation( item.getDouble(keyPrefix + ".attenuation", null), item.getDouble(keyPrefix + ".power", null) ) ); }
Example 4
Source File: PolatisPowerConfig.java From onos with Apache License 2.0 | 5 votes |
private Long acquirePortPower(PortNumber port) { String filter = getPortPowerFilter(port); String reply = netconfGet(handler(), filter); HierarchicalConfiguration info = configAt(reply, KEY_DATA_OPM_PORT); if (info == null) { return null; } return (long) (info.getDouble(KEY_POWER) * POWER_MULTIPLIER); }
Example 5
Source File: OplinkOpticalPowerConfig.java From onos with Apache License 2.0 | 5 votes |
private Long acquirePortPower(PortNumber port, String selection) { String reply = netconfGet(handler(), getPortPowerFilter(port, selection)); HierarchicalConfiguration info = configAt(reply, KEY_PORTS_PORT); if (info == null) { return null; } return (long) (info.getDouble(selection) * POWER_MULTIPLIER); }
Example 6
Source File: OplinkOpticalPowerConfig.java From onos with Apache License 2.0 | 5 votes |
private Long acquireChannelAttenuation(PortNumber port, OchSignal channel) { log.debug("Get port{} channel{} attenuation...", port, channel.channelSpacing()); String reply = netconfGet(handler(), getChannelAttenuationFilter(port, channel)); HierarchicalConfiguration info = configAt(reply, KEY_CONNS); if (info == null) { return null; } return (long) (info.getDouble(KEY_CHATT) * POWER_MULTIPLIER); }
Example 7
Source File: OplinkOpticalPowerConfig.java From onos with Apache License 2.0 | 5 votes |
private Long acquireChannelPower(PortNumber port, OchSignal channel) { log.debug("Get port{} channel{} power...", port, channel.channelSpacing()); String reply = netconfGet(handler(), getChannelPowerFilter(port, channel)); HierarchicalConfiguration info = configAt(reply, KEY_DATA_CONNS); if (info == null) { return null; } return (long) (info.getDouble(KEY_CHPWR) * POWER_MULTIPLIER); }
Example 8
Source File: LumentumNetconfRoadmFlowRuleProgrammable.java From onos with Apache License 2.0 | 4 votes |
/** * Builds a flow rule from a connection hierarchy. * * @param connection the connection hierarchy * @return the flow rule */ private FlowRule buildFlowrule(HierarchicalConfiguration connection) { String dn = connection.getString(DN); Pair<Short, Short> pair = parseDn(dn); short connId = pair.getRight(); short moduleId = pair.getLeft(); if (pair == null) { log.error("Lumentum NETCONF - device {} error in retrieving DN field", did()); return null; } log.debug("Lumentum NETCONF - retrieved FlowRule module {} connection {}", moduleId, connId); HierarchicalConfiguration config = connection.configurationAt(CONFIG); double startFreq = config.getDouble(START_FREQ); double endFreq = config.getDouble(END_FREQ); String inputPortReference = config.getString(INPUT_PORT_REFERENCE); String outputPortReference = config.getString(OUTPUT_PORT_REFERENCE); HierarchicalConfiguration state = connection.configurationAt(STATE); double attenuation = state.getDouble(CHANNEL_ATTENUATION); double inputPower = state.getDouble(CHANNEL_INPUT_POWER); double outputPower = state.getDouble(CHANNEL_OUTPUT_POWER); PortNumber portNumber = getPortNumber(moduleId, inputPortReference, outputPortReference); //If rule is on module 1 it means input port in the Flow rule is contained in portNumber. //Otherwise the input port in the Flow rule must is the line port. TrafficSelector selector = DefaultTrafficSelector.builder() .matchInPort(moduleId == 1 ? portNumber : LINE_PORT_NUMBER) .add(Criteria.matchOchSignalType(OchSignalType.FIXED_GRID)) .add(Criteria.matchLambda(toOchSignal(startFreq, endFreq))) .build(); log.debug("Lumentum NETCONF - retrieved FlowRule startFreq {} endFreq {}", startFreq, endFreq); //Lookup of connection //Retrieved rules, cached rules are considered equal if the selector is equal FlowRule cacheRule = null; if (getConnectionCache().size(did()) != 0) { cacheRule = getConnectionCache().get(did()).stream() .filter(r -> (r.selector().equals(selector))) .findFirst() .orElse(null); } if (cacheRule == null) { //TODO consider a way to keep "external" FlowRules log.error("Lumentum NETCONF connection not in the cache {}", pair.getRight()); rpcDeleteExternalConnection(moduleId, connId); return null; } else { //Update monitored values log.debug("Attenuation retrieved {} dB for connection {}", attenuation, ((LumentumFlowRule) cacheRule).getConnectionId()); ((LumentumFlowRule) cacheRule).setAttenuation(attenuation); ((LumentumFlowRule) cacheRule).setInputPower(inputPower); ((LumentumFlowRule) cacheRule).setOutputPower(outputPower); return cacheRule; } }