use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.statistics.rev170120.elementrequestdata.Filters in project netvirt by opendaylight.
the class StatisticsImpl method addElementCounterRequest.
private void addElementCounterRequest(List<ElementCountersRequest> ecrList, String portId, int lportTag, BigInteger dpn, ElementCountersDirection direction, Filters filters) {
ElementCountersRequest ecr = new ElementCountersRequest(portId);
ecr.setLportTag(lportTag);
ecr.setDpn(dpn);
ecr.setElementCountersDirection(direction);
if (filters.getIpFilter() != null) {
String ip = filters.getIpFilter().getIp();
if (ip != null) {
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_IP_FILTER_GROUP_NAME, CountersUtils.IP_FILTER_NAME, ip);
}
}
boolean isTcpPortExist = false;
if (filters.getTcpFilter() != null && filters.getTcpFilter().isOn()) {
TcpFilter tcpFilter = filters.getTcpFilter();
int srcPort = tcpFilter.getSrcPort();
int dstPort = tcpFilter.getDstPort();
if (srcPort != -1) {
isTcpPortExist = true;
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_TCP_FILTER_GROUP_NAME, CountersUtils.TCP_SRC_PORT_FILTER_NAME, String.valueOf(srcPort));
}
if (dstPort != -1) {
isTcpPortExist = true;
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_TCP_FILTER_GROUP_NAME, CountersUtils.TCP_DST_PORT_FILTER_NAME, String.valueOf(dstPort));
}
if (!isTcpPortExist) {
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_TCP_FILTER_GROUP_NAME, CountersUtils.TCP_FILTER_NAME, "");
}
} else if (filters.getUdpFilter() != null && filters.getUdpFilter().isOn()) {
UdpFilter udpFilter = filters.getUdpFilter();
int srcPort = udpFilter.getSrcPort();
int dstPort = udpFilter.getDstPort();
if (srcPort != -1) {
isTcpPortExist = true;
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_UDP_FILTER_GROUP_NAME, CountersUtils.UDP_SRC_PORT_FILTER_NAME, String.valueOf(srcPort));
}
if (dstPort != -1) {
isTcpPortExist = true;
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_UDP_FILTER_GROUP_NAME, CountersUtils.UDP_DST_PORT_FILTER_NAME, String.valueOf(dstPort));
}
if (!isTcpPortExist) {
ecr.addFilterToFilterGroup(CountersUtils.ELEMENT_COUNTERS_UDP_FILTER_GROUP_NAME, CountersUtils.UDP_FILTER_NAME, "");
}
}
if (!ecr.getFilters().isEmpty()) {
ecrList.add(ecr);
}
}