import static java.util.Objects.requireNonNull;
import static org.opendaylight.ovsdb.lib.operations.Operations.op;
+import com.google.common.collect.Maps;
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
return entityConnectionMap.get(entity);
}
- public Map<InstanceIdentifier<Node>, TransactionHistory> getControllerTxHistory() {
- return controllerTxHistory;
- }
-
- public Map<InstanceIdentifier<Node>, TransactionHistory> getDeviceUpdateHistory() {
- return deviceUpdateHistory;
- }
-
private static class HwvtepDeviceEntityOwnershipListener implements EntityOwnershipListener {
private final HwvtepConnectionManager hcm;
private final EntityOwnershipListenerRegistration listenerRegistration;
}
}
+ final Map<InstanceIdentifier<Node>, HwvtepDeviceInfo> allConnectedInstances() {
+ return Maps.transformValues(Collections.unmodifiableMap(nodeIidVsConnectionInstance),
+ HwvtepConnectionInstance::getDeviceInfo);
+ }
+
+ final Map<InstanceIdentifier<Node>, TransactionHistory> controllerTxHistory() {
+ return Collections.unmodifiableMap(controllerTxHistory);
+ }
+
+ final Map<InstanceIdentifier<Node>, TransactionHistory> deviceUpdateHistory() {
+ return Collections.unmodifiableMap(deviceUpdateHistory);
+ }
+
+ public void cleanupOperationalNode(final InstanceIdentifier<Node> nodeIid) {
+ txInvoker.invoke(new HwvtepGlobalRemoveCommand(nodeIid));
+ }
+
private enum ConnectionReconciliationTriggers {
/*
Reconciliation trigger for scenario where controller's attempt
*/
ON_DISCONNECT
}
-
- public Map<InstanceIdentifier<Node>, HwvtepConnectionInstance> getAllConnectedInstances() {
- return Collections.unmodifiableMap(nodeIidVsConnectionInstance);
- }
-
- public void cleanupOperationalNode(final InstanceIdentifier<Node> nodeIid) {
- txInvoker.invoke(new HwvtepGlobalRemoveCommand(nodeIid));
- }
}
import com.google.common.util.concurrent.FluentFuture;
import java.util.Collection;
+import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.opendaylight.ovsdb.hwvtepsouthbound.transactions.md.TransactionInvokerImpl;
import org.opendaylight.ovsdb.lib.OvsdbConnection;
import org.opendaylight.ovsdb.utils.mdsal.utils.Scheduler;
+import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionHistory;
import org.opendaylight.serviceutils.upgrade.UpgradeState;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Singleton
-@Service(classes = HwvtepSouthboundProvider.class) // only because HwvtepCacheDisplayCmd needs a @Reference to this
-public class HwvtepSouthboundProvider implements ClusteredDataTreeChangeListener<Topology>, AutoCloseable {
+@Service(classes = HwvtepSouthboundProviderInfo.class)
+public class HwvtepSouthboundProvider
+ implements HwvtepSouthboundProviderInfo, ClusteredDataTreeChangeListener<Topology>, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(HwvtepSouthboundProvider.class);
private static final String ENTITY_TYPE = "ovsdb-hwvtepsouthbound-provider";
public HwvtepConnectionManager getHwvtepConnectionManager() {
return cm;
}
+
+ @Override
+ public Map<InstanceIdentifier<Node>, HwvtepDeviceInfo> getAllConnectedInstances() {
+ return cm.allConnectedInstances();
+ }
+
+ @Override
+ public Map<InstanceIdentifier<Node>, TransactionHistory> getControllerTxHistory() {
+ return cm.controllerTxHistory();
+ }
+
+ @Override
+ public Map<InstanceIdentifier<Node>, TransactionHistory> getDeviceUpdateHistory() {
+ return cm.deviceUpdateHistory();
+ }
}
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.ovsdb.hwvtepsouthbound;
+
+import com.google.common.annotations.Beta;
+import java.util.Map;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionHistory;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+@Beta
+public interface HwvtepSouthboundProviderInfo {
+
+ @NonNull Map<InstanceIdentifier<Node>, HwvtepDeviceInfo> getAllConnectedInstances();
+
+ @NonNull Map<InstanceIdentifier<Node>, TransactionHistory> getControllerTxHistory();
+
+ @NonNull Map<InstanceIdentifier<Node>, TransactionHistory> getDeviceUpdateHistory();
+}
String nodeid;
private static final String SEPERATOR = "#######################################################";
- private final HwvtepSouthboundProvider hwvtepProvider;
+ private final HwvtepSouthboundProviderInfo hwvtepProvider;
public TransactionHistoryCmd(HwvtepSouthboundProvider hwvtepProvider) {
this.hwvtepProvider = hwvtepProvider;
@Override
protected Object doExecute() throws Exception {
- Map<InstanceIdentifier<Node>, TransactionHistory> controllerTxLogs
- = hwvtepProvider.getHwvtepConnectionManager().getControllerTxHistory();
- Map<InstanceIdentifier<Node>, TransactionHistory> deviceUpdateLogs
- = hwvtepProvider.getHwvtepConnectionManager().getDeviceUpdateHistory();
+ Map<InstanceIdentifier<Node>, TransactionHistory> controllerTxLogs = hwvtepProvider.getControllerTxHistory();
+ Map<InstanceIdentifier<Node>, TransactionHistory> deviceUpdateLogs = hwvtepProvider.getDeviceUpdateHistory();
if (nodeid != null) {
- InstanceIdentifier<Node> iid = HwvtepSouthboundMapper.createInstanceIdentifier(new NodeId(nodeid));
- printLogs(controllerTxLogs, deviceUpdateLogs, iid);
+ printLogs(controllerTxLogs, deviceUpdateLogs,
+ HwvtepSouthboundMapper.createInstanceIdentifier(new NodeId(nodeid)));
} else {
Map<InstanceIdentifier<Node>, TransactionHistory> txlogs
= controllerTxLogs.isEmpty() ? deviceUpdateLogs : controllerTxLogs;
txlogs.keySet().forEach(iid -> {
printLogs(controllerTxLogs, deviceUpdateLogs, iid);
});
- session.getConsole().println("Device tx logs size " + deviceUpdateLogs.keySet().size());
+ session.getConsole().println("Device tx logs size " + deviceUpdateLogs.size());
}
return null;
}
}
private void printLogs(List<Pair<HwvtepTransactionLogElement, Boolean>> logs) {
- logs.forEach((pair) -> {
+ logs.forEach(pair -> {
HwvtepTransactionLogElement log = pair.getLeft();
session.getConsole().print(new Date(log.getDate()));
session.getConsole().print(" ");
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepConnectionInstance;
import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepDeviceInfo;
-import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundProvider;
+import org.opendaylight.ovsdb.hwvtepsouthbound.HwvtepSouthboundProviderInfo;
import org.opendaylight.ovsdb.lib.notation.UUID;
import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalPort;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
private String nodeid;
@Reference
- private HwvtepSouthboundProvider hwvtepSouthboundProvider;
+ private HwvtepSouthboundProviderInfo hwvtepSouthboundProvider;
private static final TopologyId HWVTEP_TOPOLOGY_ID = new TopologyId(new Uri("hwvtep:1"));
private static final String SEPERATOR = "#######################################################";
@Override
@SuppressWarnings("checkstyle:RegexpSinglelineJava")
public Object execute() throws Exception {
- Map<InstanceIdentifier<Node>, HwvtepConnectionInstance> allConnectedInstances =
- hwvtepSouthboundProvider.getHwvtepConnectionManager().getAllConnectedInstances();
+ Map<InstanceIdentifier<Node>, HwvtepDeviceInfo> allConnectedInstances =
+ hwvtepSouthboundProvider.getAllConnectedInstances();
if (nodeid == null) {
- allConnectedInstances.entrySet().forEach((entry) -> {
+ allConnectedInstances.entrySet().forEach(entry -> {
System.out.println(SEPERATOR + " START " + SEPERATOR);
print(entry.getKey(), entry.getValue());
System.out.println(SEPERATOR + " END " + SEPERATOR);
}
@SuppressWarnings("checkstyle:RegexpSinglelineJava")
- private static void print(InstanceIdentifier<Node> iid, HwvtepConnectionInstance connectionInstance) {
+ private static void print(InstanceIdentifier<Node> iid, HwvtepDeviceInfo deviceInfo) {
PrintStream printStream = System.out;
printStream.print("Printing for Node : ");
printStream.println(iid.firstKeyOf(Node.class).getNodeId().getValue());
printStream.println(SECTION_SEPERATOR);
printStream.println("Config data");
printStream.println(SECTION_SEPERATOR);
- HwvtepDeviceInfo deviceInfo = connectionInstance.getDeviceInfo();
- deviceInfo.getConfigData().entrySet().forEach((entry) -> {
+ deviceInfo.getConfigData().entrySet().forEach(entry -> {
printEntry(printStream, entry);
});
-
printStream.println(SECTION_SEPERATOR);
printStream.println("Oper data");
printStream.println(SECTION_SEPERATOR);
- deviceInfo.getOperData().entrySet().forEach((entry) -> {
+ deviceInfo.getOperData().entrySet().forEach(entry -> {
printEntry(printStream, entry);
});
printStream.println(SECTION_SEPERATOR);
printStream.println("Uuid data");
printStream.println(SECTION_SEPERATOR);
- deviceInfo.getUuidData().entrySet().forEach((entry) -> {
+ deviceInfo.getUuidData().entrySet().forEach(entry -> {
printEntryUUID(printStream, entry);
});
printStream.println(SECTION_SEPERATOR);
Map<InstanceIdentifier, HwvtepDeviceInfo.DeviceData> map = entry.getValue();
String clsName = cls.getSimpleName();
console.println(clsName + " - ");
- map.values().forEach((deviceData) -> {
+ map.values().forEach(deviceData -> {
printTable(console, clsName, deviceData);
});
}
Map<UUID, HwvtepDeviceInfo.DeviceData> map = entry.getValue();
String clsName = cls.getSimpleName();
console.println(clsName + " - ");
- map.values().forEach((deviceData) -> {
+ map.values().forEach(deviceData -> {
printTable(console, clsName, deviceData);
});
}