Thomas Vachuska
Committed by Gerrit Code Review

Adding multi-instance support for flow stats.

Change-Id: I428c5a7cb58f4f9773a125fc94fb368ed846cb0d
......@@ -61,6 +61,22 @@ public final class DefaultPortStatistics implements PortStatistics {
this.durationNano = durationNano;
}
// Constructor for serializer
private DefaultPortStatistics() {
this.deviceId = null;
this.port = 0;
this.packetsReceived = 0;
this.packetsSent = 0;
this.bytesReceived = 0;
this.bytesSent = 0;
this.packetsRxDropped = 0;
this.packetsTxDropped = 0;
this.packetsRxErrors = 0;
this.packetsTxErrors = 0;
this.durationSec = 0;
this.durationNano = 0;
}
/**
* Creates a builder for DefaultPortStatistics object.
*
......
......@@ -55,6 +55,7 @@ import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
import org.onosproject.store.cluster.messaging.ClusterMessage;
import org.onosproject.store.cluster.messaging.ClusterMessageHandler;
import org.onosproject.store.cluster.messaging.MessageSubject;
import org.onosproject.store.consistent.impl.DatabaseManager;
import java.io.IOException;
import java.util.Arrays;
......@@ -157,7 +158,7 @@ public class GossipDeviceStoreTest {
clusterCommunicator = createNiceMock(ClusterCommunicationService.class);
clusterCommunicator.addSubscriber(anyObject(MessageSubject.class),
anyObject(ClusterMessageHandler.class), anyObject(ExecutorService.class));
anyObject(ClusterMessageHandler.class), anyObject(ExecutorService.class));
expectLastCall().anyTimes();
replay(clusterCommunicator);
ClusterService clusterService = new TestClusterService();
......@@ -165,6 +166,10 @@ public class GossipDeviceStoreTest {
testGossipDeviceStore = new TestGossipDeviceStore(deviceClockService, clusterService, clusterCommunicator);
testGossipDeviceStore.mastershipService = new TestMastershipService();
TestDatabaseManager testDatabaseManager = new TestDatabaseManager();
testDatabaseManager.init(clusterService, clusterCommunicator);
testGossipDeviceStore.storageService = testDatabaseManager;
gossipDeviceStore = testGossipDeviceStore;
gossipDeviceStore.activate();
deviceStore = gossipDeviceStore;
......@@ -885,4 +890,12 @@ public class GossipDeviceStoreTest {
nodeStates.put(NID2, ACTIVE);
}
}
private class TestDatabaseManager extends DatabaseManager {
void init(ClusterService clusterService,
ClusterCommunicationService clusterCommunicator) {
this.clusterService = clusterService;
this.clusterCommunicator = clusterCommunicator;
}
}
}
......
......@@ -71,9 +71,11 @@ import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DefaultDeviceDescription;
import org.onosproject.net.device.DefaultPortDescription;
import org.onosproject.net.device.DefaultPortStatistics;
import org.onosproject.net.device.OchPortDescription;
import org.onosproject.net.device.OduCltPortDescription;
import org.onosproject.net.device.OmsPortDescription;
import org.onosproject.net.device.PortStatistics;
import org.onosproject.net.flow.CompletedBatchOperation;
import org.onosproject.net.flow.DefaultFlowEntry;
import org.onosproject.net.flow.DefaultFlowRule;
......@@ -380,7 +382,9 @@ public final class KryoNamespaces {
IntentOperation.class,
FlowRuleExtPayLoad.class,
Frequency.class,
DefaultAnnotations.class
DefaultAnnotations.class,
PortStatistics.class,
DefaultPortStatistics.class
)
.register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class)
.register(new URISerializer(), URI.class)
......
......@@ -14,7 +14,7 @@ cut -c7- $aux | cut -d\ -f1 | sort > $aux.1
# Normalize the expected apps
apps=${ONOS_APPS:-drivers,openflow}
(for app in ${apps/,/ }; do echo org.onosproject.$app; done) | sort > $aux.2
(for app in ${apps//,/ }; do echo org.onosproject.$app; done) | sort > $aux.2
# Check for differences
diff $aux.1 $aux.2
......
# Madan's ProxMox ONOS instances 1,2,3 & ONOS mininet box
export ONOS_NIC="10.128.4.*"
export OC1="10.128.4.2"
export OC2="10.128.4.3"
export OC3="10.128.4.4"
export OCN="10.128.4.5"
# Office ProxMox ONOS instances 1,2,3 & ONOS mininet box
# Tom's ProxMox ONOS instances 1,2,3 & ONOS mininet box
export ONOS_NIC=10.128.11.*
export ONOS_NIC="10.128.11.*"
export OC1="10.128.11.1"
export OC2="10.128.11.2"
export OC3="10.128.11.3"
......
......@@ -850,7 +850,7 @@ public abstract class TopologyViewMessageHandlerBase extends UiMessageHandler {
if (load != null) {
this.hasTraffic = hasTraffic || load.rate() > threshold;
this.bytes += load.latest();
this.rate = load.rate();
this.rate += load.rate();
}
}
......