use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method parsePath.
protected void parsePath(final PathsBuilder builder, final List<Object> objects) {
final List<Metrics> pathMetrics = new ArrayList<>();
Object obj;
State state = State.INIT;
while (!objects.isEmpty() && !state.equals(State.END)) {
obj = objects.get(0);
state = insertObject(state, obj, builder, pathMetrics);
if (!state.equals(State.END)) {
objects.remove(0);
}
}
if (!pathMetrics.isEmpty()) {
builder.setMetrics(pathMetrics);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project genius by opendaylight.
the class NodeConnectorStatsImpl method processFlowStatistics.
/**
* This method processes FlowStatistics RPC result.
* It performs:
* - fetches all flows of node
* - stores flows count per table in local map
* - creates/updates Flow table counters using Infrautils metrics API
* - set counter with values fetched from FlowStatistics
*/
private void processFlowStatistics(GetFlowStatisticsOutput flowStatsOutput, BigInteger dpid) {
Map<Short, AtomicInteger> flowTableMap = new HashMap<>();
// Get all flows for node from RPC result
List<FlowAndStatisticsMapList> flowTableAndStatisticsMapList = flowStatsOutput.getFlowAndStatisticsMapList();
for (FlowAndStatisticsMapList flowAndStatisticsMap : flowTableAndStatisticsMapList) {
short tableId = flowAndStatisticsMap.getTableId();
// populate map to maintain flow count per table
flowTableMap.computeIfAbsent(tableId, key -> new AtomicInteger(0)).incrementAndGet();
}
LOG.trace("FlowTableStatistics (tableId:counter): {} for node: {}", flowTableMap.entrySet(), dpid.toString());
for (Map.Entry<Short, AtomicInteger> flowTable : flowTableMap.entrySet()) {
Short tableId = flowTable.getKey();
AtomicInteger flowCount = flowTable.getValue();
Counter counter = getCounter(CounterConstants.IFM_FLOW_TBL_COUNTER_FLOWS_PER_TBL, dpid, null, null, tableId.toString());
// update counter value
updateCounter(counter, flowCount.longValue());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project genius by opendaylight.
the class NodeConnectorStatsImpl method processNodeConnectorStatistics.
/**
* This method processes NodeConnectorStatistics RPC result.
* It performs:
* - fetches various OF Port counters values
* - creates/updates new OF Port counters using Infrautils metrics API
* - set counter with values fetched from NodeConnectorStatistics
*/
private void processNodeConnectorStatistics(GetNodeConnectorStatisticsOutput nodeConnectorStatisticsOutput, BigInteger dpid) {
String port = "";
String portUuid = "";
List<NodeConnectorStatisticsAndPortNumberMap> ncStatsAndPortMapList = nodeConnectorStatisticsOutput.getNodeConnectorStatisticsAndPortNumberMap();
// Parse NodeConnectorStatistics and create/update counters for them
for (NodeConnectorStatisticsAndPortNumberMap ncStatsAndPortMap : ncStatsAndPortMapList) {
NodeConnectorId nodeConnector = ncStatsAndPortMap.getNodeConnectorId();
LOG.trace("Create/update metric counter for NodeConnector: {} of node: {}", nodeConnector, dpid.toString());
port = nodeConnector.getValue();
// update port name as per port name maintained in portNameCache
String portNameInCache = "openflow" + ":" + dpid.toString() + ":" + port;
java.util.Optional<String> portName = portNameCache.get(portNameInCache);
if (portName.isPresent()) {
Optional<List<InterfaceChildEntry>> interfaceChildEntries = interfaceChildCache.getInterfaceChildEntries(portName.get());
if (interfaceChildEntries.isPresent()) {
if (!interfaceChildEntries.get().isEmpty()) {
portUuid = interfaceChildEntries.get().get(0).getChildInterface();
LOG.trace("Retrieved portUuid {} for portname {}", portUuid, portName.get());
} else {
LOG.trace("PortUuid is not found for portname {}. Skipping IFM counters publish for this port.", portName.get());
continue;
}
} else {
LOG.trace("PortUuid is not found for portname {}. Skipping IFM counters publish for this port.", portName.get());
continue;
}
}
Counter counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_DURATION, dpid, port, portUuid, null);
long ofPortDuration = ncStatsAndPortMap.getDuration().getSecond().getValue();
updateCounter(counter, ofPortDuration);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECVDROP, dpid, port, portUuid, null);
long packetsPerOFPortReceiveDrop = ncStatsAndPortMap.getReceiveDrops().longValue();
updateCounter(counter, packetsPerOFPortReceiveDrop);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECVERROR, dpid, port, portUuid, null);
long packetsPerOFPortReceiveError = ncStatsAndPortMap.getReceiveErrors().longValue();
updateCounter(counter, packetsPerOFPortReceiveError);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_SENT, dpid, port, portUuid, null);
long packetsPerOFPortSent = ncStatsAndPortMap.getPackets().getTransmitted().longValue();
updateCounter(counter, packetsPerOFPortSent);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_PKT_RECV, dpid, port, portUuid, null);
long packetsPerOFPortReceive = ncStatsAndPortMap.getPackets().getReceived().longValue();
updateCounter(counter, packetsPerOFPortReceive);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_BYTE_SENT, dpid, port, portUuid, null);
long bytesPerOFPortSent = ncStatsAndPortMap.getBytes().getTransmitted().longValue();
updateCounter(counter, bytesPerOFPortSent);
counter = getCounter(CounterConstants.IFM_PORT_COUNTER_OFPORT_BYTE_RECV, dpid, port, portUuid, null);
long bytesPerOFPortReceive = ncStatsAndPortMap.getBytes().getReceived().longValue();
updateCounter(counter, bytesPerOFPortReceive);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getP2MPSegmentComputation.
protected SegmentComputation getP2MPSegmentComputation(final Queue<Object> objects, final List<Message> errors, final Rp rp) {
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.Metric> metrics = new ArrayList<>();
final P2mpBuilder builder = new P2mpBuilder();
final List<EndpointRroPair> epRros = new ArrayList<>();
P2MPState state = P2MPState.RP;
while (!objects.isEmpty() && state != P2MPState.END) {
state = insertP2MPObject(state, objects, builder, epRros, metrics, errors, rp);
if (!state.equals(P2MPState.END)) {
objects.remove();
}
}
if (!epRros.isEmpty()) {
builder.setEndpointRroPair(epRros);
}
if (!metrics.isEmpty()) {
builder.setMetric(metrics);
}
if (rp.getReoptimization() && builder.getBandwidth() != null) {
if (!isValidReoptimizationRro(epRros) || !isValidReoptimizationBandwidth(epRros)) {
errors.add(createErrorMsg(PCEPErrors.RRO_MISSING, Optional.of(rp)));
}
}
return new SegmentComputationBuilder().setP2mp(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method insertP2PObject.
// Note: objects is expected to be non-empty and caller will remove the first object if non-empty
private static P2PState insertP2PObject(final P2PState p2PState, final Queue<Object> objects, final List<VendorInformationObject> viObjects, final P2pBuilder builder, final List<Metrics> metrics, final List<Message> errors, final Rp rp) {
final Object obj = objects.element();
switch(p2PState) {
case INIT:
if (obj instanceof Rro) {
builder.setRro((Rro) obj);
objects.remove();
// FIXME: should we guard against empty objects?
final Object nextObj = objects.element();
if (nextObj instanceof ReoptimizationBandwidth) {
builder.setReoptimizationBandwidth((ReoptimizationBandwidth) nextObj);
}
return P2PState.REPORTED_IN;
}
// fallthrough
case REPORTED_IN:
if (obj instanceof VendorInformationObject) {
viObjects.add((VendorInformationObject) obj);
return P2PState.REPORTED_IN;
}
// fallthrough
case VENDOR_INFO_LIST:
if (obj instanceof LoadBalancing) {
builder.setLoadBalancing((LoadBalancing) obj);
return P2PState.LOAD_BIN;
}
// fallthrough
case LOAD_BIN:
if (obj instanceof Lspa) {
builder.setLspa((Lspa) obj);
return P2PState.LSPA_IN;
}
// fallthrough
case LSPA_IN:
if (obj instanceof Bandwidth) {
builder.setBandwidth((Bandwidth) obj);
return P2PState.BANDWIDTH_IN;
}
// fallthrough
case BANDWIDTH_IN:
if (obj instanceof Metric) {
metrics.add(new MetricsBuilder().setMetric((Metric) obj).build());
return P2PState.BANDWIDTH_IN;
}
// fallthrough
case METRIC_IN:
if (obj instanceof Iro) {
builder.setIro((Iro) obj);
return P2PState.IRO_IN;
}
// fallthrough
case IRO_IN:
if (obj instanceof Rro) {
builder.setRro((Rro) obj);
return P2PState.RRO_IN;
}
// fallthrough
case RRO_IN:
if (obj instanceof Xro) {
builder.setXro((Xro) obj);
return P2PState.XRO_IN;
}
// fallthrough
case XRO_IN:
if (obj instanceof Of) {
builder.setOf((Of) obj);
return P2PState.OF_IN;
}
// fallthrough
case OF_IN:
if (obj instanceof ClassType) {
final ClassType classType = (ClassType) obj;
if (!classType.getProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rp)));
} else {
builder.setClassType(classType);
}
return P2PState.CT_IN;
}
// fallthrough
case CT_IN:
case END:
return P2PState.END;
default:
return p2PState;
}
}
Aggregations