mirror of
				https://github.com/opennetworkinglab/onos.git
				synced 2025-11-04 10:11:16 +01:00 
			
		
		
		
	Various fixes in preparation of Stratum demo at ONS 2019
- Do not read counters with table entries for Barefoot drivers - If driver behavior setup fails, log which operation we are aborting - Remove unnecessary setup steps in Stratum-related drivers - Always get clients by their key in gRPC-based drivers - Log when P4Runtime group operation fails because of missing group in store - Fix polling of table entry counters for P4Runtime driver Change-Id: Ic9bf19b76d8cb5a191aec24852af4410fea8b998
This commit is contained in:
		
							parent
							
								
									b48533e3f7
								
							
						
					
					
						commit
						c32976e7d5
					
				@ -19,6 +19,7 @@
 | 
				
			|||||||
            swVersion="1.0" extends="p4runtime">
 | 
					            swVersion="1.0" extends="p4runtime">
 | 
				
			||||||
        <behaviour api="org.onosproject.net.behaviour.PiPipelineProgrammable"
 | 
					        <behaviour api="org.onosproject.net.behaviour.PiPipelineProgrammable"
 | 
				
			||||||
                   impl="org.onosproject.drivers.barefoot.TofinoPipelineProgrammable"/>
 | 
					                   impl="org.onosproject.drivers.barefoot.TofinoPipelineProgrammable"/>
 | 
				
			||||||
 | 
					        <property name="tableReadCountersWithTableEntries">false</property>
 | 
				
			||||||
        <property name="tableDeleteBeforeUpdate">true</property>
 | 
					        <property name="tableDeleteBeforeUpdate">true</property>
 | 
				
			||||||
    </driver>
 | 
					    </driver>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -29,6 +30,7 @@
 | 
				
			|||||||
        <!-- The current version of p4lang/PI used in Stratum does not
 | 
					        <!-- The current version of p4lang/PI used in Stratum does not
 | 
				
			||||||
        support reading default table entries -->
 | 
					        support reading default table entries -->
 | 
				
			||||||
        <property name="supportDefaultTableEntry">false</property>
 | 
					        <property name="supportDefaultTableEntry">false</property>
 | 
				
			||||||
 | 
					        <property name="tableReadCountersWithTableEntries">false</property>
 | 
				
			||||||
    </driver>
 | 
					    </driver>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
</drivers>
 | 
					</drivers>
 | 
				
			||||||
 | 
				
			|||||||
@ -20,7 +20,6 @@ import com.google.common.base.Strings;
 | 
				
			|||||||
import org.onosproject.gnmi.api.GnmiClient;
 | 
					import org.onosproject.gnmi.api.GnmiClient;
 | 
				
			||||||
import org.onosproject.gnmi.api.GnmiClientKey;
 | 
					import org.onosproject.gnmi.api.GnmiClientKey;
 | 
				
			||||||
import org.onosproject.gnmi.api.GnmiController;
 | 
					import org.onosproject.gnmi.api.GnmiController;
 | 
				
			||||||
import org.onosproject.net.Device;
 | 
					 | 
				
			||||||
import org.onosproject.net.DeviceId;
 | 
					import org.onosproject.net.DeviceId;
 | 
				
			||||||
import org.onosproject.net.config.NetworkConfigService;
 | 
					import org.onosproject.net.config.NetworkConfigService;
 | 
				
			||||||
import org.onosproject.net.config.basics.BasicDeviceConfig;
 | 
					import org.onosproject.net.config.basics.BasicDeviceConfig;
 | 
				
			||||||
@ -40,18 +39,14 @@ public class AbstractGnmiHandlerBehaviour extends AbstractHandlerBehaviour {
 | 
				
			|||||||
    protected final Logger log = LoggerFactory.getLogger(getClass());
 | 
					    protected final Logger log = LoggerFactory.getLogger(getClass());
 | 
				
			||||||
    protected DeviceId deviceId;
 | 
					    protected DeviceId deviceId;
 | 
				
			||||||
    protected DeviceService deviceService;
 | 
					    protected DeviceService deviceService;
 | 
				
			||||||
    protected Device device;
 | 
					 | 
				
			||||||
    protected GnmiController controller;
 | 
					 | 
				
			||||||
    protected GnmiClient client;
 | 
					    protected GnmiClient client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected boolean setupBehaviour() {
 | 
					    protected boolean setupBehaviour(String opName) {
 | 
				
			||||||
        deviceId = handler().data().deviceId();
 | 
					        deviceId = handler().data().deviceId();
 | 
				
			||||||
        deviceService = handler().get(DeviceService.class);
 | 
					        deviceService = handler().get(DeviceService.class);
 | 
				
			||||||
        controller = handler().get(GnmiController.class);
 | 
					        client = getClientByKey();
 | 
				
			||||||
        client = controller.getClient(deviceId);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (client == null) {
 | 
					        if (client == null) {
 | 
				
			||||||
            log.warn("Unable to find client for {}, aborting operation", deviceId);
 | 
					            log.warn("Missing client for {}, aborting {}", deviceId, opName);
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -76,7 +76,7 @@ public class OpenConfigGnmiDeviceDescriptionDiscovery
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public List<PortDescription> discoverPortDetails() {
 | 
					    public List<PortDescription> discoverPortDetails() {
 | 
				
			||||||
        if (!setupBehaviour()) {
 | 
					        if (!setupBehaviour("discoverPortDetails()")) {
 | 
				
			||||||
            return Collections.emptyList();
 | 
					            return Collections.emptyList();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        log.debug("Discovering port details on device {}", handler().data().deviceId());
 | 
					        log.debug("Discovering port details on device {}", handler().data().deviceId());
 | 
				
			||||||
 | 
				
			|||||||
@ -50,7 +50,7 @@ public class OpenConfigGnmiPortStatisticsDiscovery extends AbstractGnmiHandlerBe
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public Collection<PortStatistics> discoverPortStatistics() {
 | 
					    public Collection<PortStatistics> discoverPortStatistics() {
 | 
				
			||||||
        if (!setupBehaviour()) {
 | 
					        if (!setupBehaviour("discoverPortStatistics()")) {
 | 
				
			||||||
            return Collections.emptyList();
 | 
					            return Collections.emptyList();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -20,11 +20,9 @@ import com.google.common.base.Strings;
 | 
				
			|||||||
import org.onosproject.gnoi.api.GnoiClient;
 | 
					import org.onosproject.gnoi.api.GnoiClient;
 | 
				
			||||||
import org.onosproject.gnoi.api.GnoiClientKey;
 | 
					import org.onosproject.gnoi.api.GnoiClientKey;
 | 
				
			||||||
import org.onosproject.gnoi.api.GnoiController;
 | 
					import org.onosproject.gnoi.api.GnoiController;
 | 
				
			||||||
import org.onosproject.net.Device;
 | 
					 | 
				
			||||||
import org.onosproject.net.DeviceId;
 | 
					import org.onosproject.net.DeviceId;
 | 
				
			||||||
import org.onosproject.net.config.NetworkConfigService;
 | 
					import org.onosproject.net.config.NetworkConfigService;
 | 
				
			||||||
import org.onosproject.net.config.basics.BasicDeviceConfig;
 | 
					import org.onosproject.net.config.basics.BasicDeviceConfig;
 | 
				
			||||||
import org.onosproject.net.device.DeviceService;
 | 
					 | 
				
			||||||
import org.onosproject.net.driver.AbstractHandlerBehaviour;
 | 
					import org.onosproject.net.driver.AbstractHandlerBehaviour;
 | 
				
			||||||
import org.slf4j.Logger;
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
import org.slf4j.LoggerFactory;
 | 
					import org.slf4j.LoggerFactory;
 | 
				
			||||||
@ -39,19 +37,14 @@ public class AbstractGnoiHandlerBehaviour extends AbstractHandlerBehaviour {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    protected final Logger log = LoggerFactory.getLogger(getClass());
 | 
					    protected final Logger log = LoggerFactory.getLogger(getClass());
 | 
				
			||||||
    protected DeviceId deviceId;
 | 
					    protected DeviceId deviceId;
 | 
				
			||||||
    protected DeviceService deviceService;
 | 
					 | 
				
			||||||
    protected Device device;
 | 
					 | 
				
			||||||
    protected GnoiController controller;
 | 
					 | 
				
			||||||
    protected GnoiClient client;
 | 
					    protected GnoiClient client;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected boolean setupBehaviour() {
 | 
					    protected boolean setupBehaviour(String opName) {
 | 
				
			||||||
        deviceId = handler().data().deviceId();
 | 
					        deviceId = handler().data().deviceId();
 | 
				
			||||||
        deviceService = handler().get(DeviceService.class);
 | 
					        client = getClientByKey();
 | 
				
			||||||
        controller = handler().get(GnoiController.class);
 | 
					 | 
				
			||||||
        client = controller.getClient(deviceId);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (client == null) {
 | 
					        if (client == null) {
 | 
				
			||||||
            log.warn("Unable to find client for {}, aborting operation", deviceId);
 | 
					            log.warn("Missing client for {}, aborting {}", deviceId, opName);
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -16,17 +16,18 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
package org.onosproject.drivers.gnoi;
 | 
					package org.onosproject.drivers.gnoi;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import gnoi.system.SystemOuterClass.RebootMethod;
 | 
				
			||||||
import gnoi.system.SystemOuterClass.RebootRequest;
 | 
					import gnoi.system.SystemOuterClass.RebootRequest;
 | 
				
			||||||
import gnoi.system.SystemOuterClass.RebootResponse;
 | 
					import gnoi.system.SystemOuterClass.RebootResponse;
 | 
				
			||||||
import gnoi.system.SystemOuterClass.RebootMethod;
 | 
					 | 
				
			||||||
import org.onosproject.net.behaviour.BasicSystemOperations;
 | 
					import org.onosproject.net.behaviour.BasicSystemOperations;
 | 
				
			||||||
import java.util.concurrent.CompletableFuture;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import org.slf4j.Logger;
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
import org.slf4j.LoggerFactory;
 | 
					import org.slf4j.LoggerFactory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.concurrent.CompletableFuture;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Implementation of the BasicSystemOperations behavior for gNOI-enabled devices.
 | 
					 * Implementation of the BasicSystemOperations behavior for gNOI-enabled
 | 
				
			||||||
 | 
					 * devices.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
public class GnoiBasicSystemOperationsImpl
 | 
					public class GnoiBasicSystemOperationsImpl
 | 
				
			||||||
        extends AbstractGnoiHandlerBehaviour implements BasicSystemOperations {
 | 
					        extends AbstractGnoiHandlerBehaviour implements BasicSystemOperations {
 | 
				
			||||||
@ -36,12 +37,13 @@ public class GnoiBasicSystemOperationsImpl
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public CompletableFuture<Boolean> reboot() {
 | 
					    public CompletableFuture<Boolean> reboot() {
 | 
				
			||||||
        if (!setupBehaviour()) {
 | 
					        if (!setupBehaviour("reboot()")) {
 | 
				
			||||||
            return CompletableFuture.completedFuture(false);
 | 
					            return CompletableFuture.completedFuture(false);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        final RebootRequest.Builder requestMsg = RebootRequest.newBuilder().setMethod(RebootMethod.COLD);
 | 
					        final RebootRequest.Builder requestMsg = RebootRequest.newBuilder().setMethod(RebootMethod.COLD);
 | 
				
			||||||
        final CompletableFuture<Boolean> future = client.reboot(requestMsg.build())
 | 
					
 | 
				
			||||||
 | 
					        return client.reboot(requestMsg.build())
 | 
				
			||||||
                .handle((response, error) -> {
 | 
					                .handle((response, error) -> {
 | 
				
			||||||
                    if (error == null) {
 | 
					                    if (error == null) {
 | 
				
			||||||
                        log.debug("gNOI reboot() for device {} returned {}", deviceId, response);
 | 
					                        log.debug("gNOI reboot() for device {} returned {}", deviceId, response);
 | 
				
			||||||
@ -51,16 +53,14 @@ public class GnoiBasicSystemOperationsImpl
 | 
				
			|||||||
                        return false;
 | 
					                        return false;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return future;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public CompletableFuture<Long> time() {
 | 
					    public CompletableFuture<Long> time() {
 | 
				
			||||||
        if (!setupBehaviour()) {
 | 
					        if (!setupBehaviour("time()")) {
 | 
				
			||||||
            return CompletableFuture.completedFuture(0L);
 | 
					            return CompletableFuture.completedFuture(0L);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        final CompletableFuture<Long> future = client.time()
 | 
					        return client.time()
 | 
				
			||||||
                .handle((response, error) -> {
 | 
					                .handle((response, error) -> {
 | 
				
			||||||
                    if (error == null) {
 | 
					                    if (error == null) {
 | 
				
			||||||
                        log.debug("gNOI time() for device {} returned {}", deviceId.uri(), response.getTime());
 | 
					                        log.debug("gNOI time() for device {} returned {}", deviceId.uri(), response.getTime());
 | 
				
			||||||
@ -70,7 +70,5 @@ public class GnoiBasicSystemOperationsImpl
 | 
				
			|||||||
                        return 0L;
 | 
					                        return 0L;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return future;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -47,43 +47,29 @@ public class AbstractP4RuntimeHandlerBehaviour extends AbstractHandlerBehaviour
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Initialized by setupBehaviour()
 | 
					    // Initialized by setupBehaviour()
 | 
				
			||||||
    protected DeviceId deviceId;
 | 
					    protected DeviceId deviceId;
 | 
				
			||||||
    protected DeviceService deviceService;
 | 
					 | 
				
			||||||
    protected Device device;
 | 
					 | 
				
			||||||
    protected P4RuntimeController controller;
 | 
					 | 
				
			||||||
    protected PiPipeconf pipeconf;
 | 
					    protected PiPipeconf pipeconf;
 | 
				
			||||||
    protected P4RuntimeClient client;
 | 
					    protected P4RuntimeClient client;
 | 
				
			||||||
    protected PiTranslationService translationService;
 | 
					    protected PiTranslationService translationService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Initializes this behaviour attributes. Returns true if the operation was
 | 
					     * Initializes this behaviour attributes. Returns true if the operation was
 | 
				
			||||||
     * successful, false otherwise. This method assumes that the P4Runtime
 | 
					     * successful, false otherwise.
 | 
				
			||||||
     * controller already has a client for this device and that the device has
 | 
					 | 
				
			||||||
     * been created in the core.
 | 
					 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 | 
					     * @param opName name of the operation
 | 
				
			||||||
     * @return true if successful, false otherwise
 | 
					     * @return true if successful, false otherwise
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    protected boolean setupBehaviour() {
 | 
					    protected boolean setupBehaviour(String opName) {
 | 
				
			||||||
        deviceId = handler().data().deviceId();
 | 
					        deviceId = handler().data().deviceId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        deviceService = handler().get(DeviceService.class);
 | 
					        client = getClientByKey();
 | 
				
			||||||
        device = deviceService.getDevice(deviceId);
 | 
					 | 
				
			||||||
        if (device == null) {
 | 
					 | 
				
			||||||
            log.warn("Unable to find device with id {}", deviceId);
 | 
					 | 
				
			||||||
            return false;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        controller = handler().get(P4RuntimeController.class);
 | 
					 | 
				
			||||||
        client = controller.getClient(deviceId);
 | 
					 | 
				
			||||||
        if (client == null) {
 | 
					        if (client == null) {
 | 
				
			||||||
            log.warn("Unable to find client for {}", deviceId);
 | 
					            log.warn("Missing client for {}, aborting {}", deviceId, opName);
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        PiPipeconfService piPipeconfService = handler().get(PiPipeconfService.class);
 | 
					        PiPipeconfService piPipeconfService = handler().get(PiPipeconfService.class);
 | 
				
			||||||
        if (!piPipeconfService.getPipeconf(deviceId).isPresent()) {
 | 
					        if (!piPipeconfService.getPipeconf(deviceId).isPresent()) {
 | 
				
			||||||
            log.warn("Unable to get assigned pipeconf for {} (mapping " +
 | 
					            log.warn("Missing pipeconf for {}, cannot perform {}", deviceId, opName);
 | 
				
			||||||
                             "missing in PiPipeconfService)",
 | 
					 | 
				
			||||||
                     deviceId);
 | 
					 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        pipeconf = piPipeconfService.getPipeconf(deviceId).get();
 | 
					        pipeconf = piPipeconfService.getPipeconf(deviceId).get();
 | 
				
			||||||
@ -100,6 +86,11 @@ public class AbstractP4RuntimeHandlerBehaviour extends AbstractHandlerBehaviour
 | 
				
			|||||||
     * @return interpreter or null
 | 
					     * @return interpreter or null
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    PiPipelineInterpreter getInterpreter() {
 | 
					    PiPipelineInterpreter getInterpreter() {
 | 
				
			||||||
 | 
					        final Device device = handler().get(DeviceService.class).getDevice(deviceId);
 | 
				
			||||||
 | 
					        if (device == null) {
 | 
				
			||||||
 | 
					            log.warn("Unable to find device {}, cannot get interpreter", deviceId);
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        if (!device.is(PiPipelineInterpreter.class)) {
 | 
					        if (!device.is(PiPipelineInterpreter.class)) {
 | 
				
			||||||
            log.warn("Unable to get interpreter for {}, missing behaviour",
 | 
					            log.warn("Unable to get interpreter for {}, missing behaviour",
 | 
				
			||||||
                     deviceId);
 | 
					                     deviceId);
 | 
				
			||||||
 | 
				
			|||||||
@ -81,8 +81,8 @@ public class P4RuntimeActionGroupProgrammable
 | 
				
			|||||||
    private PiGroupTranslator groupTranslator;
 | 
					    private PiGroupTranslator groupTranslator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected boolean setupBehaviour() {
 | 
					    protected boolean setupBehaviour(String opName) {
 | 
				
			||||||
        if (!super.setupBehaviour()) {
 | 
					        if (!super.setupBehaviour(opName)) {
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        groupMirror = this.handler().get(P4RuntimeActionProfileGroupMirror.class);
 | 
					        groupMirror = this.handler().get(P4RuntimeActionProfileGroupMirror.class);
 | 
				
			||||||
@ -95,7 +95,7 @@ public class P4RuntimeActionGroupProgrammable
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void performGroupOperation(DeviceId deviceId,
 | 
					    public void performGroupOperation(DeviceId deviceId,
 | 
				
			||||||
                                      GroupOperations groupOps) {
 | 
					                                      GroupOperations groupOps) {
 | 
				
			||||||
        if (!setupBehaviour()) {
 | 
					        if (!setupBehaviour("performGroupOperation()")) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -107,8 +107,8 @@ public class P4RuntimeActionGroupProgrammable
 | 
				
			|||||||
                    // GroupDescription.
 | 
					                    // GroupDescription.
 | 
				
			||||||
                    Group groupOnStore = groupStore.getGroup(deviceId, op.groupId());
 | 
					                    Group groupOnStore = groupStore.getGroup(deviceId, op.groupId());
 | 
				
			||||||
                    if (groupOnStore == null) {
 | 
					                    if (groupOnStore == null) {
 | 
				
			||||||
                        log.warn("Unable to find group {} in store, aborting {} operation",
 | 
					                        log.warn("Unable to find group {} in store, aborting {} operation [{}]",
 | 
				
			||||||
                                 op.groupId(), op.opType());
 | 
					                                 op.groupId(), op.opType(), op);
 | 
				
			||||||
                        return;
 | 
					                        return;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    GroupDescription groupDesc = new DefaultGroupDescription(
 | 
					                    GroupDescription groupDesc = new DefaultGroupDescription(
 | 
				
			||||||
@ -121,7 +121,7 @@ public class P4RuntimeActionGroupProgrammable
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public Collection<Group> getGroups() {
 | 
					    public Collection<Group> getGroups() {
 | 
				
			||||||
        if (!setupBehaviour()) {
 | 
					        if (!setupBehaviour("getGroups()")) {
 | 
				
			||||||
            return Collections.emptyList();
 | 
					            return Collections.emptyList();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -108,9 +108,9 @@ public class P4RuntimeFlowRuleProgrammable
 | 
				
			|||||||
    private PiFlowRuleTranslator translator;
 | 
					    private PiFlowRuleTranslator translator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected boolean setupBehaviour() {
 | 
					    protected boolean setupBehaviour(String opName) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!super.setupBehaviour()) {
 | 
					        if (!super.setupBehaviour(opName)) {
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -123,7 +123,7 @@ public class P4RuntimeFlowRuleProgrammable
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public Collection<FlowEntry> getFlowEntries() {
 | 
					    public Collection<FlowEntry> getFlowEntries() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!setupBehaviour()) {
 | 
					        if (!setupBehaviour("getFlowEntries()")) {
 | 
				
			||||||
            return Collections.emptyList();
 | 
					            return Collections.emptyList();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -149,12 +149,13 @@ public class P4RuntimeFlowRuleProgrammable
 | 
				
			|||||||
            return Collections.emptyList();
 | 
					            return Collections.emptyList();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        final Map<PiTableEntry, PiCounterCellData> counterCellMap =
 | 
					        final Map<PiTableEntryHandle, PiCounterCellData> counterCellMap =
 | 
				
			||||||
                readEntryCounters(deviceEntries);
 | 
					                readEntryCounters(deviceEntries);
 | 
				
			||||||
        // Forge flow entries with counter values.
 | 
					        // Forge flow entries with counter values.
 | 
				
			||||||
        for (PiTableEntry entry : deviceEntries) {
 | 
					        for (PiTableEntry entry : deviceEntries) {
 | 
				
			||||||
 | 
					            final PiTableEntryHandle handle = entry.handle(deviceId);
 | 
				
			||||||
            final FlowEntry flowEntry = forgeFlowEntry(
 | 
					            final FlowEntry flowEntry = forgeFlowEntry(
 | 
				
			||||||
                    entry, counterCellMap.get(entry));
 | 
					                    entry, handle, counterCellMap.get(handle));
 | 
				
			||||||
            if (flowEntry == null) {
 | 
					            if (flowEntry == null) {
 | 
				
			||||||
                // Entry is on device but unknown to translation service or
 | 
					                // Entry is on device but unknown to translation service or
 | 
				
			||||||
                // device mirror. Inconsistent. Mark for removal.
 | 
					                // device mirror. Inconsistent. Mark for removal.
 | 
				
			||||||
@ -228,8 +229,8 @@ public class P4RuntimeFlowRuleProgrammable
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private FlowEntry forgeFlowEntry(PiTableEntry entry,
 | 
					    private FlowEntry forgeFlowEntry(PiTableEntry entry,
 | 
				
			||||||
 | 
					                                     PiTableEntryHandle handle,
 | 
				
			||||||
                                     PiCounterCellData cellData) {
 | 
					                                     PiCounterCellData cellData) {
 | 
				
			||||||
        final PiTableEntryHandle handle = entry.handle(deviceId);
 | 
					 | 
				
			||||||
        final Optional<PiTranslatedEntity<FlowRule, PiTableEntry>>
 | 
					        final Optional<PiTranslatedEntity<FlowRule, PiTableEntry>>
 | 
				
			||||||
                translatedEntity = translator.lookup(handle);
 | 
					                translatedEntity = translator.lookup(handle);
 | 
				
			||||||
        final TimedEntry<PiTableEntry> timedEntry = tableMirror.get(handle);
 | 
					        final TimedEntry<PiTableEntry> timedEntry = tableMirror.get(handle);
 | 
				
			||||||
@ -262,14 +263,14 @@ public class P4RuntimeFlowRuleProgrammable
 | 
				
			|||||||
    private Collection<FlowEntry> getFlowEntriesFromMirror() {
 | 
					    private Collection<FlowEntry> getFlowEntriesFromMirror() {
 | 
				
			||||||
        return tableMirror.getAll(deviceId).stream()
 | 
					        return tableMirror.getAll(deviceId).stream()
 | 
				
			||||||
                .map(timedEntry -> forgeFlowEntry(
 | 
					                .map(timedEntry -> forgeFlowEntry(
 | 
				
			||||||
                        timedEntry.entry(), null))
 | 
					                        timedEntry.entry(), timedEntry.entry().handle(deviceId), null))
 | 
				
			||||||
                .filter(Objects::nonNull)
 | 
					                .filter(Objects::nonNull)
 | 
				
			||||||
                .collect(Collectors.toList());
 | 
					                .collect(Collectors.toList());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Collection<FlowRule> processFlowRules(Collection<FlowRule> rules,
 | 
					    private Collection<FlowRule> processFlowRules(Collection<FlowRule> rules,
 | 
				
			||||||
                                                  Operation driverOperation) {
 | 
					                                                  Operation driverOperation) {
 | 
				
			||||||
        if (!setupBehaviour() || rules.isEmpty()) {
 | 
					        if (!setupBehaviour("processFlowRules()") || rules.isEmpty()) {
 | 
				
			||||||
            return Collections.emptyList();
 | 
					            return Collections.emptyList();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        // Created batched write request.
 | 
					        // Created batched write request.
 | 
				
			||||||
@ -459,52 +460,38 @@ public class P4RuntimeFlowRuleProgrammable
 | 
				
			|||||||
                originalDefaultEntry.action().equals(entry.action());
 | 
					                originalDefaultEntry.action().equals(entry.action());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private Map<PiTableEntry, PiCounterCellData> readEntryCounters(
 | 
					    private Map<PiTableEntryHandle, PiCounterCellData> readEntryCounters(
 | 
				
			||||||
            Collection<PiTableEntry> tableEntries) {
 | 
					            Collection<PiTableEntry> tableEntries) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!driverBoolProperty(SUPPORT_TABLE_COUNTERS,
 | 
					        if (!driverBoolProperty(SUPPORT_TABLE_COUNTERS,
 | 
				
			||||||
                                DEFAULT_SUPPORT_TABLE_COUNTERS)
 | 
					                                DEFAULT_SUPPORT_TABLE_COUNTERS)
 | 
				
			||||||
                || tableEntries.isEmpty()) {
 | 
					                || tableEntries.isEmpty()) {
 | 
				
			||||||
            return Collections.emptyMap();
 | 
					            return Collections.emptyMap();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        final Map<PiTableEntry, PiCounterCellData> cellDataMap = Maps.newHashMap();
 | 
					        if (driverBoolProperty(READ_COUNTERS_WITH_TABLE_ENTRIES,
 | 
				
			||||||
 | 
					                               DEFAULT_READ_COUNTERS_WITH_TABLE_ENTRIES)) {
 | 
				
			||||||
        // We expect the server to return table entries with counter data (if
 | 
					            return tableEntries.stream()
 | 
				
			||||||
        // the table supports counter). Here we extract such counter data and we
 | 
					                    .filter(t -> t.counter() != null)
 | 
				
			||||||
        // determine if there are missing counter cells (if, for example, the
 | 
					                    .collect(Collectors.toMap(
 | 
				
			||||||
        // serves does not support returning counter data with table entries)
 | 
					                            t -> t.handle(deviceId), PiTableEntry::counter));
 | 
				
			||||||
        final Set<PiHandle> missingCellHandles = tableEntries.stream()
 | 
					 | 
				
			||||||
                .map(t -> {
 | 
					 | 
				
			||||||
                    if (t.counter() != null) {
 | 
					 | 
				
			||||||
                        // Counter data found in table entry.
 | 
					 | 
				
			||||||
                        cellDataMap.put(t, t.counter());
 | 
					 | 
				
			||||||
                        return null;
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
                        return t;
 | 
					            final Set<PiHandle> cellHandles = tableEntries.stream()
 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                })
 | 
					 | 
				
			||||||
                .filter(Objects::nonNull)
 | 
					 | 
				
			||||||
                // Ignore for default entries and for tables without counters.
 | 
					 | 
				
			||||||
                    .filter(e -> !e.isDefaultAction())
 | 
					                    .filter(e -> !e.isDefaultAction())
 | 
				
			||||||
                    .filter(e -> tableHasCounter(e.table()))
 | 
					                    .filter(e -> tableHasCounter(e.table()))
 | 
				
			||||||
                    .map(PiCounterCellId::ofDirect)
 | 
					                    .map(PiCounterCellId::ofDirect)
 | 
				
			||||||
                    .map(id -> PiCounterCellHandle.of(deviceId, id))
 | 
					                    .map(id -> PiCounterCellHandle.of(deviceId, id))
 | 
				
			||||||
                    .collect(Collectors.toSet());
 | 
					                    .collect(Collectors.toSet());
 | 
				
			||||||
        // We might be sending a large read request (for thousands or more
 | 
					            // FIXME: We might be sending a very large read request...
 | 
				
			||||||
        // of counter cell handles). We request the driver to vet this
 | 
					            return client.read(pipeconf)
 | 
				
			||||||
        // operation via driver property.
 | 
					                    .handles(cellHandles)
 | 
				
			||||||
        if (!missingCellHandles.isEmpty()
 | 
					 | 
				
			||||||
                && !driverBoolProperty(READ_COUNTERS_WITH_TABLE_ENTRIES,
 | 
					 | 
				
			||||||
                                       DEFAULT_READ_COUNTERS_WITH_TABLE_ENTRIES)) {
 | 
					 | 
				
			||||||
            client.read(pipeconf)
 | 
					 | 
				
			||||||
                    .handles(missingCellHandles)
 | 
					 | 
				
			||||||
                    .submitSync()
 | 
					                    .submitSync()
 | 
				
			||||||
                    .all(PiCounterCell.class).stream()
 | 
					                    .all(PiCounterCell.class).stream()
 | 
				
			||||||
                    .filter(c -> c.cellId().counterType().equals(PiCounterType.DIRECT))
 | 
					                    .filter(c -> c.cellId().counterType().equals(PiCounterType.DIRECT))
 | 
				
			||||||
                    .forEach(c -> cellDataMap.put(c.cellId().tableEntry(), c.data()));
 | 
					                    .collect(Collectors.toMap(
 | 
				
			||||||
 | 
					                            c -> c.cellId().tableEntry().handle(deviceId),
 | 
				
			||||||
 | 
					                            PiCounterCell::data));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					 | 
				
			||||||
        return cellDataMap;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private boolean tableHasCounter(PiTableId tableId) {
 | 
					    private boolean tableHasCounter(PiTableId tableId) {
 | 
				
			||||||
 | 
				
			|||||||
@ -120,12 +120,12 @@ public class P4RuntimeHandshaker extends AbstractP4RuntimeHandlerBehaviour imple
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void roleChanged(MastershipRole newRole) {
 | 
					    public void roleChanged(MastershipRole newRole) {
 | 
				
			||||||
 | 
					        if (!setupBehaviour("roleChanged()")) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        if (newRole.equals(MastershipRole.NONE)) {
 | 
					        if (newRole.equals(MastershipRole.NONE)) {
 | 
				
			||||||
            final P4RuntimeClient client = getClientByKey();
 | 
					 | 
				
			||||||
            if (client != null) {
 | 
					 | 
				
			||||||
            log.info("Notified role NONE, closing session...");
 | 
					            log.info("Notified role NONE, closing session...");
 | 
				
			||||||
            client.closeSession();
 | 
					            client.closeSession();
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            throw new UnsupportedOperationException(
 | 
					            throw new UnsupportedOperationException(
 | 
				
			||||||
                    "Use preference-based way for setting MASTER or STANDBY roles");
 | 
					                    "Use preference-based way for setting MASTER or STANDBY roles");
 | 
				
			||||||
@ -134,7 +134,9 @@ public class P4RuntimeHandshaker extends AbstractP4RuntimeHandlerBehaviour imple
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void roleChanged(int preference, long term) {
 | 
					    public void roleChanged(int preference, long term) {
 | 
				
			||||||
        if (setupBehaviour()) {
 | 
					        if (!setupBehaviour("roleChanged()")) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        final int clusterSize = handler().get(ClusterService.class)
 | 
					        final int clusterSize = handler().get(ClusterService.class)
 | 
				
			||||||
                .getNodes().size();
 | 
					                .getNodes().size();
 | 
				
			||||||
        if (clusterSize > MAX_CLUSTER_SIZE) {
 | 
					        if (clusterSize > MAX_CLUSTER_SIZE) {
 | 
				
			||||||
@ -146,7 +148,6 @@ public class P4RuntimeHandshaker extends AbstractP4RuntimeHandlerBehaviour imple
 | 
				
			|||||||
                .subtract(BigInteger.valueOf(preference));
 | 
					                .subtract(BigInteger.valueOf(preference));
 | 
				
			||||||
        client.setMastership(preference == 0, electionId);
 | 
					        client.setMastership(preference == 0, electionId);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public MastershipRole getRole() {
 | 
					    public MastershipRole getRole() {
 | 
				
			||||||
 | 
				
			|||||||
@ -66,8 +66,8 @@ public class P4RuntimeMeterProgrammable extends AbstractP4RuntimeHandlerBehaviou
 | 
				
			|||||||
    private PiPipelineModel pipelineModel;
 | 
					    private PiPipelineModel pipelineModel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected boolean setupBehaviour() {
 | 
					    protected boolean setupBehaviour(String opName) {
 | 
				
			||||||
        if (!super.setupBehaviour()) {
 | 
					        if (!super.setupBehaviour(opName)) {
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -80,7 +80,7 @@ public class P4RuntimeMeterProgrammable extends AbstractP4RuntimeHandlerBehaviou
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public CompletableFuture<Boolean> performMeterOperation(MeterOperation meterOp) {
 | 
					    public CompletableFuture<Boolean> performMeterOperation(MeterOperation meterOp) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!setupBehaviour()) {
 | 
					        if (!setupBehaviour("performMeterOperation()")) {
 | 
				
			||||||
            return CompletableFuture.completedFuture(false);
 | 
					            return CompletableFuture.completedFuture(false);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -118,7 +118,7 @@ public class P4RuntimeMeterProgrammable extends AbstractP4RuntimeHandlerBehaviou
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public CompletableFuture<Collection<Meter>> getMeters() {
 | 
					    public CompletableFuture<Collection<Meter>> getMeters() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!setupBehaviour()) {
 | 
					        if (!setupBehaviour("getMeters()")) {
 | 
				
			||||||
            return CompletableFuture.completedFuture(Collections.emptyList());
 | 
					            return CompletableFuture.completedFuture(Collections.emptyList());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -62,8 +62,8 @@ public class P4RuntimeMulticastGroupProgrammable
 | 
				
			|||||||
    private PiMulticastGroupTranslator mcGroupTranslator;
 | 
					    private PiMulticastGroupTranslator mcGroupTranslator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    protected boolean setupBehaviour() {
 | 
					    protected boolean setupBehaviour(String opName) {
 | 
				
			||||||
        if (!super.setupBehaviour()) {
 | 
					        if (!super.setupBehaviour(opName)) {
 | 
				
			||||||
            return false;
 | 
					            return false;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        mcGroupMirror = this.handler().get(P4RuntimeMulticastGroupMirror.class);
 | 
					        mcGroupMirror = this.handler().get(P4RuntimeMulticastGroupMirror.class);
 | 
				
			||||||
@ -74,20 +74,25 @@ public class P4RuntimeMulticastGroupProgrammable
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void performGroupOperation(DeviceId deviceId, GroupOperations groupOps) {
 | 
					    public void performGroupOperation(DeviceId deviceId, GroupOperations groupOps) {
 | 
				
			||||||
        if (!setupBehaviour()) {
 | 
					        if (!setupBehaviour("performGroupOperation()")) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        groupOps.operations().stream()
 | 
					        groupOps.operations().stream()
 | 
				
			||||||
                .filter(op -> op.groupType().equals(GroupDescription.Type.ALL))
 | 
					                .filter(op -> op.groupType().equals(GroupDescription.Type.ALL))
 | 
				
			||||||
                .forEach(op -> {
 | 
					                .forEach(op -> {
 | 
				
			||||||
                    final Group group = groupStore.getGroup(deviceId, op.groupId());
 | 
					                    final Group group = groupStore.getGroup(deviceId, op.groupId());
 | 
				
			||||||
 | 
					                    if (group == null) {
 | 
				
			||||||
 | 
					                        log.warn("Unable to find group {} in store, aborting {} operation [{}]",
 | 
				
			||||||
 | 
					                                 op.groupId(), op.opType(), op);
 | 
				
			||||||
 | 
					                        return;
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    processMcGroupOp(group, op.opType());
 | 
					                    processMcGroupOp(group, op.opType());
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public Collection<Group> getGroups() {
 | 
					    public Collection<Group> getGroups() {
 | 
				
			||||||
        if (!setupBehaviour()) {
 | 
					        if (!setupBehaviour("getGroups()")) {
 | 
				
			||||||
            return Collections.emptyList();
 | 
					            return Collections.emptyList();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return ImmutableList.copyOf(getMcGroups());
 | 
					        return ImmutableList.copyOf(getMcGroups());
 | 
				
			||||||
 | 
				
			|||||||
@ -33,7 +33,7 @@ public class P4RuntimePacketProgrammable
 | 
				
			|||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void emit(OutboundPacket packet) {
 | 
					    public void emit(OutboundPacket packet) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!this.setupBehaviour()) {
 | 
					        if (!this.setupBehaviour("emit()")) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -17,23 +17,23 @@ package org.onosproject.drivers.p4runtime;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import org.onosproject.net.DeviceId;
 | 
					import org.onosproject.net.DeviceId;
 | 
				
			||||||
import org.onosproject.net.behaviour.TableStatisticsDiscovery;
 | 
					import org.onosproject.net.behaviour.TableStatisticsDiscovery;
 | 
				
			||||||
import org.onosproject.net.flow.FlowRuleService;
 | 
					 | 
				
			||||||
import org.onosproject.net.flow.FlowEntry;
 | 
					 | 
				
			||||||
import org.onosproject.net.flow.TableId;
 | 
					 | 
				
			||||||
import org.onosproject.net.flow.IndexTableId;
 | 
					 | 
				
			||||||
import org.onosproject.net.flow.TableStatisticsEntry;
 | 
					 | 
				
			||||||
import org.onosproject.net.flow.DefaultTableStatisticsEntry;
 | 
					import org.onosproject.net.flow.DefaultTableStatisticsEntry;
 | 
				
			||||||
import org.onosproject.net.pi.model.PiPipelineModel;
 | 
					import org.onosproject.net.flow.FlowEntry;
 | 
				
			||||||
 | 
					import org.onosproject.net.flow.FlowRuleService;
 | 
				
			||||||
 | 
					import org.onosproject.net.flow.IndexTableId;
 | 
				
			||||||
 | 
					import org.onosproject.net.flow.TableId;
 | 
				
			||||||
 | 
					import org.onosproject.net.flow.TableStatisticsEntry;
 | 
				
			||||||
import org.onosproject.net.pi.model.PiPipelineInterpreter;
 | 
					import org.onosproject.net.pi.model.PiPipelineInterpreter;
 | 
				
			||||||
 | 
					import org.onosproject.net.pi.model.PiPipelineModel;
 | 
				
			||||||
import org.onosproject.net.pi.model.PiTableId;
 | 
					import org.onosproject.net.pi.model.PiTableId;
 | 
				
			||||||
import org.onosproject.net.pi.model.PiTableModel;
 | 
					import org.onosproject.net.pi.model.PiTableModel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.ArrayList;
 | 
				
			||||||
import java.util.Collections;
 | 
					import java.util.Collections;
 | 
				
			||||||
import java.util.Map;
 | 
					 | 
				
			||||||
import java.util.HashMap;
 | 
					import java.util.HashMap;
 | 
				
			||||||
import java.util.Iterator;
 | 
					import java.util.Iterator;
 | 
				
			||||||
import java.util.ArrayList;
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import static com.google.common.collect.Lists.newArrayList;
 | 
					import static com.google.common.collect.Lists.newArrayList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -45,7 +45,7 @@ public class P4RuntimeTableStatisticsDiscovery extends AbstractP4RuntimeHandlerB
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public List<TableStatisticsEntry> getTableStatistics() {
 | 
					    public List<TableStatisticsEntry> getTableStatistics() {
 | 
				
			||||||
        if (!setupBehaviour()) {
 | 
					        if (!setupBehaviour("getTableStatistics()")) {
 | 
				
			||||||
            return Collections.emptyList();
 | 
					            return Collections.emptyList();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        FlowRuleService flowService = handler().get(FlowRuleService.class);
 | 
					        FlowRuleService flowService = handler().get(FlowRuleService.class);
 | 
				
			||||||
 | 
				
			|||||||
@ -66,8 +66,8 @@ public class StratumDeviceDescriptionDiscovery
 | 
				
			|||||||
                        .set(AnnotationKeys.PROTOCOL, format(
 | 
					                        .set(AnnotationKeys.PROTOCOL, format(
 | 
				
			||||||
                                "%s, %s, %s",
 | 
					                                "%s, %s, %s",
 | 
				
			||||||
                                p4Descr.annotations().value(AnnotationKeys.PROTOCOL),
 | 
					                                p4Descr.annotations().value(AnnotationKeys.PROTOCOL),
 | 
				
			||||||
                                gnoiDescr.annotations().value(AnnotationKeys.PROTOCOL),
 | 
					                                gnmiDescr.annotations().value(AnnotationKeys.PROTOCOL),
 | 
				
			||||||
                                gnmiDescr.annotations().value(AnnotationKeys.PROTOCOL)))
 | 
					                                gnoiDescr.annotations().value(AnnotationKeys.PROTOCOL)))
 | 
				
			||||||
                        .build());
 | 
					                        .build());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -152,7 +152,9 @@ public final class TableEntryCodec
 | 
				
			|||||||
                        .build());
 | 
					                        .build());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // Counter.
 | 
					        // Counter.
 | 
				
			||||||
 | 
					        if (message.hasCounterData()) {
 | 
				
			||||||
            piTableEntryBuilder.withCounterCellData(decodeCounter(message.getCounterData()));
 | 
					            piTableEntryBuilder.withCounterCellData(decodeCounter(message.getCounterData()));
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return piTableEntryBuilder.build();
 | 
					        return piTableEntryBuilder.build();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user