if (hwvtepDeviceEntityOwnershipListener != null) {
hwvtepDeviceEntityOwnershipListener.close();
}
+ if (hwvtepOperGlobalListener != null) {
+ hwvtepOperGlobalListener.close();
+ }
for (HwvtepConnectionInstance client: clients.values()) {
client.disconnect();
hwvtepConnectionInstance = getConnectionInstance(key);
if (hwvtepConnectionInstance != null) {
if (hwvtepConnectionInstance.getInstanceIdentifier() != null) {
+ int port = hwvtepConnectionInstance.getOvsdbClient().getConnectionInfo().getRemotePort();
deviceUpdateHistory.get(hwvtepConnectionInstance.getInstanceIdentifier()).addToHistory(
TransactionType.DELETE, new ClientConnected(client.getConnectionInfo().getRemotePort()));
+ LOG.info("CONTROLLER - {} {}", TransactionType.DELETE, new ClientConnected(port));
}
TransactionHistory deviceLog = deviceUpdateHistory.get(iid);
int port = hwvtepConnectionInstance.getOvsdbClient().getConnectionInfo().getRemotePort();
deviceLog.addToHistory(TransactionType.ADD, new ClientConnected(port));
+ LOG.info("CONTROLLER - {} {}", TransactionType.ADD, new ClientConnected(port));
hwvtepConnectionInstance.setControllerTxHistory(controllerLog);
hwvtepConnectionInstance.setDeviceUpdateHistory(deviceLog);
}
import com.google.common.util.concurrent.FluentFuture;
import java.util.Collection;
-import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
.create(NetworkTopology.class)
.child(Topology.class, new TopologyKey(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID));
ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
- FluentFuture<Optional<Topology>> hwvtepTp = transaction.read(type, path);
+ FluentFuture<Boolean> hwvtepTp = transaction.exists(type, path);
try {
- if (!hwvtepTp.get().isPresent()) {
+ if (!hwvtepTp.get().booleanValue()) {
TopologyBuilder tpb = new TopologyBuilder();
tpb.setTopologyId(HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID);
transaction.mergeParentStructurePut(type, path, tpb.build());
}
}
+
+
private void openOvsdbPort() {
if (!registered.getAndSet(true)) {
LOG.info("Starting the ovsdb port");
UUID lsUuid = new UUID(TransactUtils.getLogicalSwitchId(lswitch));
updateCurrentTxData(LogicalSwitches.class, lsKey, lsUuid, lswitch);
updateControllerTxHistory(TransactionType.ADD, logicalSwitch);
+ LOG.info("CONTROLLER - {} {}", TransactionType.ADD, logicalSwitch);
} else {
String existingLogicalSwitchName = lswitch.getHwvtepNodeName().getValue();
// Name is immutable, and so we *can't* update it. So we use extraBridge for the schema stuff
.build());
transaction.add(op.comment("Logical Switch: Updating " + existingLogicalSwitchName));
updateControllerTxHistory(TransactionType.UPDATE, logicalSwitch);
+ LOG.info("CONTROLLER - {} {}", TransactionType.UPDATE, logicalSwitch);
}
}
final RemoteMcastMacs mac,
final InstanceIdentifier macIid,
final Object... extraData) {
+ String nodeId = instanceIdentifier.firstKeyOf(Node.class).getNodeId().getValue();
clearConfigData(RemoteMcastMacs.class, macIid);
long transactionId = getOperationalState().getTransactionId();
LOG.debug("Remove received for RemoteMcastMacs key: {} txId: {}", macIid, transactionId);
updateCurrentTxDeleteData(RemoteMcastMacs.class, macIid, mac);
updateControllerTxHistory(TransactionType.DELETE, new StringBuilder(mcastMacsRemote.toString())
.append(": LS: ").append(logicalSwitchUid));
- LOG.info("CONTROLLER - {} {} LS:{}", TransactionType.DELETE, mcastMacsRemote, logicalSwitchUid);
+ LOG.info("CONTROLLER - {} {} LS:{} Node:{}", TransactionType.DELETE,
+ mcastMacsRemote, logicalSwitchUid, nodeId);
+
}
}
if (!deleted && deviceData != null) {
.where(mcastMacsRemote.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
updateControllerTxHistory(TransactionType.DELETE, new StringBuilder(mcastMacsRemote.toString())
.append(": Mac : ").append(macEntryUUID));
- LOG.info("CONTROLLER - {} {} Mac :{}", TransactionType.DELETE, mcastMacsRemote, macEntryUUID);
+ LOG.info("CONTROLLER - {} {} Mac :{} Node:{}", TransactionType.DELETE,
+ mcastMacsRemote, macEntryUUID, nodeId);
} else {
LOG.error("Failed to delete remote mcast entry as it is not found in device {}", macIid);
getDeviceInfo().clearConfigData(RemoteMcastMacs.class, macIid);
transaction.add(op.insert(physicalLocator).withId(locatorUuid));
hwvtepOperationalState.getDeviceInfo().addToControllerTx(TransactionType.ADD,
new StringBuilder(physicalLocator.toString()).append(" Uuid ").append(locatorUuid));
+ LOG.info("CONTROLLER - {} {}", TransactionType.ADD,
+ new StringBuilder(physicalLocator.toString()).append(" Uuid ").append(locatorUuid));
return new UUID(locatorUuid);
}
private void removeUcastMacRemote(final TransactionBuilder transaction,
final InstanceIdentifier<Node> instanceIdentifier,
final List<RemoteUcastMacs> macList) {
+ String nodeId = instanceIdentifier.firstKeyOf(Node.class).getNodeId().getValue();
for (RemoteUcastMacs mac: macList) {
final InstanceIdentifier<RemoteUcastMacs> macIid =
instanceIdentifier.augmentation(HwvtepGlobalAugmentation.class)
.opEqual(logicalSwitchUid))
.and(ucastMacsRemote.getMacColumn().getSchema().opEqual(mac.getMacEntryKey()
.getValue())).build());
- LOG.info("CONTROLLER - {} {}", TransactionType.DELETE, ucastMacsRemote);
+ LOG.info("CONTROLLER - {} Mac:{} LS:{} Node:{}", TransactionType.DELETE,
+ mac.getMacEntryKey(), logicalSwitchUid, nodeId);
+
}
}
}
ucastMacsRemote.getUuidColumn().setData(macEntryUUID);
transaction.add(op.delete(ucastMacsRemote.getSchema())
.where(ucastMacsRemote.getUuidColumn().getSchema().opEqual(macEntryUUID)).build());
- LOG.info("CONTROLLER - {} {}", TransactionType.DELETE, ucastMacsRemote);
+ LOG.info("CONTROLLER - {} {} Node:{}", TransactionType.DELETE, ucastMacsRemote, nodeId);
} else {
LOG.trace("Remove failed to find in op datastore key:{} txId:{}", macIid, getOperationalState()
.getTransactionId());
import org.opendaylight.ovsdb.schema.hardwarevtep.McastMacsRemote;
import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsLocal;
import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsRemote;
+import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepGlobalAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepLogicalSwitchRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteMcastMacsKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.global.attributes.RemoteUcastMacsKey;
+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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
for (UcastMacsLocal lum : deletedLUMRows) {
if (lum.getMac() != null && lum.getLogicalSwitchColumn() != null
&& lum.getLogicalSwitchColumn().getData() != null) {
+ LOG.info("DEVICE - {} LocalUcastMacs for Node {} - {}", TransactionType.DELETE,
+ getOvsdbConnectionInstance().getInstanceIdentifier().firstKeyOf(Node.class)
+ .getNodeId().getValue(), lum.getMac());
InstanceIdentifier<LocalUcastMacs> lumId = getOvsdbConnectionInstance().getInstanceIdentifier()
.augmentation(HwvtepGlobalAugmentation.class).child(LocalUcastMacs.class,
new LocalUcastMacsKey(getLogicalSwitchRef(lum.getLogicalSwitchColumn().getData()),
import org.opendaylight.ovsdb.schema.hardwarevtep.LogicalSwitch;
import org.opendaylight.ovsdb.schema.hardwarevtep.PhysicalLocator;
import org.opendaylight.ovsdb.schema.hardwarevtep.UcastMacsLocal;
+import org.opendaylight.ovsdb.utils.mdsal.utils.TransactionType;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
private void updateData(ReadWriteTransaction transaction, Collection<UcastMacsLocal> ucml) {
final InstanceIdentifier<Node> connectionIId = getOvsdbConnectionInstance().getInstanceIdentifier();
+ LOG.info("DEVICE - {} LocalUcastMacs for Node {} - {}", TransactionType.ADD,
+ connectionIId.firstKeyOf(Node.class).getNodeId().getValue(), ucml);
Node connectionNode = buildConnectionNode(ucml);
transaction.merge(LogicalDatastoreType.OPERATIONAL, connectionIId, connectionNode);
}
InstanceIdentifier<Topology> path =
InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(topologyId));
for (int i = 0; i < 60; i++) {
- Topology topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, path);
- if (topology != null) {
+ Boolean topology = mdsalUtils.exists(LogicalDatastoreType.OPERATIONAL, path);
+ if (topology) {
LOG.info("getHwvtepTopology: found {}...", HwvtepSouthboundConstants.HWVTEP_TOPOLOGY_ID.getValue());
found = true;
break;
reconciliationManager.enqueueForRetry(task);
break;
case ON_DISCONNECT: {
- FluentFuture<Optional<Node>> readNodeFuture;
+ FluentFuture<Boolean> readNodeFuture;
try (ReadTransaction tx = db.newReadOnlyTransaction()) {
- readNodeFuture = tx.read(LogicalDatastoreType.CONFIGURATION, iid);
+ readNodeFuture = tx.exists(LogicalDatastoreType.CONFIGURATION, iid);
}
- readNodeFuture.addCallback(new FutureCallback<Optional<Node>>() {
+ readNodeFuture.addCallback(new FutureCallback<Boolean>() {
@Override
- public void onSuccess(final Optional<Node> node) {
- if (node.isPresent()) {
+ public void onSuccess(final Boolean node) {
+ if (node.booleanValue()) {
LOG.info("Disconnected/Failed connection {} was controller initiated, attempting "
+ "reconnection", ovsdbNode.getConnectionInfo());
reconciliationManager.enqueue(task);
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.PostConstruct;
.create(NetworkTopology.class)
.child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID));
ReadWriteTransaction transaction = db.newReadWriteTransaction();
- FluentFuture<Optional<Topology>> ovsdbTp = transaction.read(type, path);
+ FluentFuture<Boolean> ovsdbTp = transaction.exists(type, path);
try {
- if (!ovsdbTp.get().isPresent()) {
+ if (!ovsdbTp.get().booleanValue()) {
TopologyBuilder tpb = new TopologyBuilder();
tpb.setTopologyId(SouthboundConstants.OVSDB_TOPOLOGY_ID);
transaction.mergeParentStructurePut(type, path, tpb.build());
when(db.newReadOnlyTransaction()).thenReturn(tx);
when(tx.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)))
.thenReturn(mock(FluentFuture.class));
+ when(tx.exists(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)))
+ .thenReturn(mock(FluentFuture.class));
when(ovsdbConnectionInstance.getInstanceIdentifier()).thenReturn(mock(InstanceIdentifier.class));
ovsdbConnManager.disconnected(externalClient);
Map<ConnectionInfo, OvsdbConnectionInstance> testClients = Whitebox.getInternalState(ovsdbConnManager,
return Optional.empty();
}
+
+ public boolean exists(
+ final LogicalDatastoreType store, final InstanceIdentifier<? extends DataObject> path) {
+ int trialNo = 0;
+ ReadTransaction transaction = databroker.newReadOnlyTransaction();
+ do {
+ try {
+ FluentFuture<Boolean> result = transaction.exists(store, path);
+ transaction.close();
+ return result.get().booleanValue();
+ } catch (InterruptedException | ExecutionException e) {
+ if (trialNo == 0) {
+ logReadFailureError(path, " mdsal Read failed exception retrying the read after sleep");
+ }
+ try {
+ transaction.close();
+ Thread.sleep(MDSAL_READ_SLEEP_INTERVAL_MS);
+ transaction = databroker.newReadOnlyTransaction();
+ } catch (InterruptedException e1) {
+ logReadFailureError(path, " Sleep interrupted");
+ }
+ }
+ } while (trialNo++ < MDSAL_MAX_READ_TRIALS);
+ logReadFailureError(path, " All read trials exceeded");
+ return false;
+ }
+
private <D extends DataObject> void logReadFailureError(
InstanceIdentifier<D> path, String cause) {
LOG.error("{}: Failed to read {} Cause : {}", Thread.currentThread().getStackTrace()[2], path, cause);