if the conected node does not appear in oper ds
disconnect the node, upon reconnection it may succeed in getting into
operds.
Signed-off-by: Chetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
Change-Id: I1091e0a1a644141467e6d4bda5a058af60110a62
Signed-off-by: Chetan Arakere Gowdru <chetan.arakere@altencalsoftlabs.com>
+ @SuppressWarnings("checkstyle:IllegalCatch")
private static void handleNewPassiveConnection(final OvsdbClient client) {
ListenableFuture<List<String>> echoFuture = client.echo();
LOG.debug("Send echo message to probe the OVSDB switch {}",client.getConnectionInfo());
Futures.addCallback(echoFuture, new FutureCallback<List<String>>() {
@Override
private static void handleNewPassiveConnection(final OvsdbClient client) {
ListenableFuture<List<String>> echoFuture = client.echo();
LOG.debug("Send echo message to probe the OVSDB switch {}",client.getConnectionInfo());
Futures.addCallback(echoFuture, new FutureCallback<List<String>>() {
@Override
- public void onSuccess(@Nullable final List<String> result) {
- LOG.debug("Probe was successful to OVSDB switch {}",client.getConnectionInfo());
- List<OvsdbClient> clientsFromSameNode = getPassiveClientsFromSameNode(client);
+ public void onSuccess(@Nullable List<String> result) {
+ LOG.info("Probe was successful to OVSDB switch {}",client.getConnectionInfo());
+ //List<OvsdbClient> clientsFromSameNode = getPassiveClientsFromSameNode(client);
+ try {
+ getPassiveClientsFromSameNode(client);
+ } catch (Throwable throwable) {
+ LOG.error("Failed to get passive clients from same node", throwable);
+ }
+ notifyListenerForPassiveConnection(client);
+ /*
if (clientsFromSameNode.size() == 0) {
notifyListenerForPassiveConnection(client);
} else {
STALE_PASSIVE_CONNECTION_SERVICE.handleNewPassiveConnection(client, clientsFromSameNode);
}
if (clientsFromSameNode.size() == 0) {
notifyListenerForPassiveConnection(client);
} else {
STALE_PASSIVE_CONNECTION_SERVICE.handleNewPassiveConnection(client, clientsFromSameNode);
}
}
alreadyProcessedClients.put(externalClient, externalClient);
}
alreadyProcessedClients.put(externalClient, externalClient);
- LOG.info("Library connected {} from {}:{} to {}:{}",
+ LOG.info("OvsdbConnectionManager connected {} from {}:{} to {}:{}",
externalClient.getConnectionInfo().getType(),
externalClient.getConnectionInfo().getRemoteAddress(),
externalClient.getConnectionInfo().getRemotePort(),
externalClient.getConnectionInfo().getType(),
externalClient.getConnectionInfo().getRemoteAddress(),
externalClient.getConnectionInfo().getRemotePort(),
OvsdbConnectionInstance client = connectedButCallBacksNotRegistered(externalClient);
// Register Cluster Ownership for ConnectionInfo
registerEntityForOwnership(client);
OvsdbConnectionInstance client = connectedButCallBacksNotRegistered(externalClient);
// Register Cluster Ownership for ConnectionInfo
registerEntityForOwnership(client);
+ OvsdbOperGlobalListener.runAfterTimeoutIfNodeNotCreated(client.getInstanceIdentifier(), () -> {
+ externalClient.disconnect();
+ disconnected(externalClient);
+ });
}
} catch (InterruptedException | ExecutionException | TimeoutException e) {
}
} catch (InterruptedException | ExecutionException | TimeoutException e) {
- LOG.warn("Unable to fetch Database list from device {}. Disconnecting from the device.",
- externalClient.getConnectionInfo().getRemoteAddress(), e);
+ LOG.warn("OvsdbConnectionManager Unable to fetch Database list from device {}."
+ + "Disconnecting from the device.", externalClient.getConnectionInfo().getRemoteAddress(), e);
externalClient.disconnect();
}
externalClient.disconnect();
}
@Override
public void disconnected(final OvsdbClient client) {
alreadyProcessedClients.remove(client);
@Override
public void disconnected(final OvsdbClient client) {
alreadyProcessedClients.remove(client);
- LOG.info("Library disconnected {} from {}:{} to {}:{}. Cleaning up the operational data store",
+ LOG.info("Ovsdb Library disconnected {} from {}:{} to {}:{}. Cleaning up the operational data store",
client.getConnectionInfo().getType(),
client.getConnectionInfo().getRemoteAddress(),
client.getConnectionInfo().getRemotePort(),
client.getConnectionInfo().getType(),
client.getConnectionInfo().getRemoteAddress(),
client.getConnectionInfo().getRemotePort(),
// about to disconnect as well), if current owner get disconnected from
// OVSDB device.
if (ovsdbConnectionInstance.getHasDeviceOwnership()) {
// about to disconnect as well), if current owner get disconnected from
// OVSDB device.
if (ovsdbConnectionInstance.getHasDeviceOwnership()) {
- LOG.info("Library disconnected {} this controller instance has ownership", key);
+ LOG.info("Ovsdb Library disconnected {} this controller instance has ownership", key);
deleteOperNodeAndReleaseOwnership(ovsdbConnectionInstance);
} else {
deleteOperNodeAndReleaseOwnership(ovsdbConnectionInstance);
} else {
- LOG.info("Library disconnected {} this controller does not have ownership", key);
+ LOG.info("Ovsdb Library disconnected {} this controller does not have ownership", key);
unregisterEntityForOwnership(ovsdbConnectionInstance);
}
removeConnectionInstance(key);
unregisterEntityForOwnership(ovsdbConnectionInstance);
}
removeConnectionInstance(key);
ovsdbConnectionInstance.getOvsdbNodeAugmentation(),
ConnectionReconciliationTriggers.ON_DISCONNECT);
} else {
ovsdbConnectionInstance.getOvsdbNodeAugmentation(),
ConnectionReconciliationTriggers.ON_DISCONNECT);
} else {
- LOG.warn("disconnected : Connection instance not found for OVSDB Node {} ", key);
+ LOG.warn("Ovsdb disconnected : Connection instance not found for OVSDB Node {} ", key);
}
LOG.trace("OvsdbConnectionManager: exit disconnected client: {}", client);
}
}
LOG.trace("OvsdbConnectionManager: exit disconnected client: {}", client);
}
justification = "https://github.com/spotbugs/spotbugs/issues/811")
private void handleOwnershipChanged(final EntityOwnershipChange ownershipChange) {
OvsdbConnectionInstance ovsdbConnectionInstance = getConnectionInstanceFromEntity(ownershipChange.getEntity());
justification = "https://github.com/spotbugs/spotbugs/issues/811")
private void handleOwnershipChanged(final EntityOwnershipChange ownershipChange) {
OvsdbConnectionInstance ovsdbConnectionInstance = getConnectionInstanceFromEntity(ownershipChange.getEntity());
- LOG.debug("handleOwnershipChanged: {} event received for device {}",
+ LOG.debug("Ovsdb handleOwnershipChanged: {} event received for device {}",
ownershipChange, ovsdbConnectionInstance != null ? ovsdbConnectionInstance.getConnectionInfo()
: "that's currently NOT registered by *this* southbound plugin instance");
if (ovsdbConnectionInstance == null) {
if (ownershipChange.getState().isOwner()) {
ownershipChange, ovsdbConnectionInstance != null ? ovsdbConnectionInstance.getConnectionInfo()
: "that's currently NOT registered by *this* southbound plugin instance");
if (ovsdbConnectionInstance == null) {
if (ownershipChange.getState().isOwner()) {
- LOG.warn("handleOwnershipChanged: *this* instance is elected as an owner of the device {} but it "
+ LOG.warn("Ovsdb handleOwnershipChanged: *this* instance is elected as an owner of the device {} but it "
+ "is NOT registered for ownership", ownershipChange.getEntity());
} else {
// EntityOwnershipService sends notification to all the nodes, irrespective of whether
+ "is NOT registered for ownership", ownershipChange.getEntity());
} else {
// EntityOwnershipService sends notification to all the nodes, irrespective of whether
// If all the controller instance that was connected to the device are down, so the
// running instance can clear up the operational data store even though it was not
// connected to the device.
// If all the controller instance that was connected to the device are down, so the
// running instance can clear up the operational data store even though it was not
// connected to the device.
- LOG.debug("handleOwnershipChanged: No connection instance found for {}", ownershipChange.getEntity());
+ LOG.debug("Ovsdb handleOwnershipChanged: No connection instance found for {}",
+ ownershipChange.getEntity());
}
// If entity has no owner, clean up the operational data store (it's possible because owner controller
// might went down abruptly and didn't get a chance to clean up the operational data store.
if (!ownershipChange.getState().hasOwner()) {
}
// If entity has no owner, clean up the operational data store (it's possible because owner controller
// might went down abruptly and didn't get a chance to clean up the operational data store.
if (!ownershipChange.getState().hasOwner()) {
- LOG.info("{} has no owner, cleaning up the operational data store", ownershipChange.getEntity());
+ LOG.info("Ovsdb {} has no owner, cleaning up the operational data store", ownershipChange.getEntity());
cleanEntityOperationalData(ownershipChange.getEntity());
}
return;
cleanEntityOperationalData(ownershipChange.getEntity());
}
return;
putConnectionInstance(ovsdbConnectionInstance.getMDConnectionInfo(),ovsdbConnectionInstance);
if (ownershipChange.getState().isOwner() == ovsdbConnectionInstance.getHasDeviceOwnership()) {
putConnectionInstance(ovsdbConnectionInstance.getMDConnectionInfo(),ovsdbConnectionInstance);
if (ownershipChange.getState().isOwner() == ovsdbConnectionInstance.getHasDeviceOwnership()) {
- LOG.info("handleOwnershipChanged: no change in ownership for {}. Ownership status is : {}",
+ LOG.info("Ovsdb handleOwnershipChanged: no change in ownership for {}. Ownership status is : {}",
ovsdbConnectionInstance.getConnectionInfo(), ovsdbConnectionInstance.getHasDeviceOwnership()
? SouthboundConstants.OwnershipStates.OWNER.getState()
: SouthboundConstants.OwnershipStates.NONOWNER.getState());
ovsdbConnectionInstance.getConnectionInfo(), ovsdbConnectionInstance.getHasDeviceOwnership()
? SouthboundConstants.OwnershipStates.OWNER.getState()
: SouthboundConstants.OwnershipStates.NONOWNER.getState());
ovsdbConnectionInstance.setHasDeviceOwnership(ownershipChange.getState().isOwner());
// You were not an owner, but now you are
if (ownershipChange.getState().isOwner()) {
ovsdbConnectionInstance.setHasDeviceOwnership(ownershipChange.getState().isOwner());
// You were not an owner, but now you are
if (ownershipChange.getState().isOwner()) {
- LOG.info("handleOwnershipChanged: *this* southbound plugin instance is an OWNER of the device {}",
+ LOG.info("Ovsdb handleOwnershipChanged: *this* southbound plugin instance is an OWNER of the device {}",
ovsdbConnectionInstance.getConnectionInfo());
//*this* instance of southbound plugin is owner of the device,
//so register for monitor callbacks
ovsdbConnectionInstance.registerCallbacks(instanceIdentifierCodec);
ovsdbConnectionInstance.getConnectionInfo());
//*this* instance of southbound plugin is owner of the device,
//so register for monitor callbacks
ovsdbConnectionInstance.registerCallbacks(instanceIdentifierCodec);
- LOG.trace("isUpgradeInProgress {}", upgradeState.isUpgradeInProgress());
+ LOG.trace("Ovsdb isUpgradeInProgress {}", upgradeState.isUpgradeInProgress());
if (!upgradeState.isUpgradeInProgress()) {
reconcileBridgeConfigurations(ovsdbConnectionInstance);
}
if (!upgradeState.isUpgradeInProgress()) {
reconcileBridgeConfigurations(ovsdbConnectionInstance);
}
//when clustering service implement a ownership grant strategy which can revoke the
//device ownership for load balancing the devices across the instances.
//Once this condition occur, we should unregister the callback.
//when clustering service implement a ownership grant strategy which can revoke the
//device ownership for load balancing the devices across the instances.
//Once this condition occur, we should unregister the callback.
- LOG.error("handleOwnershipChanged: *this* southbound plugin instance is no longer the owner of device {}."
- + "This should NOT happen.",
+ LOG.error("Ovsdb handleOwnershipChanged: *this* southbound plugin instance is no longer"
+ + " the owner of device {}.This should NOT happen.",
ovsdbConnectionInstance.getNodeId().getValue());
}
}
ovsdbConnectionInstance.getNodeId().getValue());
}
}
try {
dbSchema = connectionInstance.getSchema(OvsdbSchemaContants.DATABASE_NAME).get();
} catch (InterruptedException | ExecutionException e) {
try {
dbSchema = connectionInstance.getSchema(OvsdbSchemaContants.DATABASE_NAME).get();
} catch (InterruptedException | ExecutionException e) {
- LOG.warn("Not able to fetch schema for database {} from device {}",
+ LOG.warn("Ovsdb Not able to fetch schema for database {} from device {}",
OvsdbSchemaContants.DATABASE_NAME,connectionInstance.getConnectionInfo(),e);
return null;
}
OvsdbSchemaContants.DATABASE_NAME,connectionInstance.getConnectionInfo(),e);
return null;
}
try {
results = connectionInstance.transact(dbSchema, operations).get();
} catch (InterruptedException | ExecutionException e) {
try {
results = connectionInstance.transact(dbSchema, operations).get();
} catch (InterruptedException | ExecutionException e) {
- LOG.warn("Not able to fetch OpenVswitch table row from device {}", connectionInstance.getConnectionInfo(),
- e);
+ LOG.warn("Ovsdb Not able to fetch OpenVswitch table row from device {}",
+ connectionInstance.getConnectionInfo(), e);
*/
OpenVSwitch openvswitchRow = getOpenVswitchTableEntry(ovsdbConnectionInstance);
iid = SouthboundMapper.getInstanceIdentifier(instanceIdentifierCodec, openvswitchRow);
*/
OpenVSwitch openvswitchRow = getOpenVswitchTableEntry(ovsdbConnectionInstance);
iid = SouthboundMapper.getInstanceIdentifier(instanceIdentifierCodec, openvswitchRow);
- LOG.info("InstanceIdentifier {} generated for device "
+ LOG.info("Ovsdb InstanceIdentifier {} generated for device "
+ "connection {}",iid,ovsdbConnectionInstance.getConnectionInfo());
ovsdbConnectionInstance.setInstanceIdentifier(iid);
}
Entity deviceEntity = new Entity(ENTITY_TYPE, iid);
+ "connection {}",iid,ovsdbConnectionInstance.getConnectionInfo());
ovsdbConnectionInstance.setInstanceIdentifier(iid);
}
Entity deviceEntity = new Entity(ENTITY_TYPE, iid);
- LOG.debug("Entity {} created for device connection {}",
+ LOG.debug("Ovsdb Entity {} created for device connection {}",
deviceEntity, ovsdbConnectionInstance.getConnectionInfo());
return deviceEntity;
}
deviceEntity, ovsdbConnectionInstance.getConnectionInfo());
return deviceEntity;
}
Entity candidateEntity = getEntityFromConnectionInstance(ovsdbConnectionInstance);
if (entityConnectionMap.containsKey(candidateEntity)) {
Entity candidateEntity = getEntityFromConnectionInstance(ovsdbConnectionInstance);
if (entityConnectionMap.containsKey(candidateEntity)) {
- LOG.error("Old connection still hanging for {}", candidateEntity);
+ LOG.error("Ovsdb Old connection still hanging for {}", candidateEntity);
disconnected(ovsdbConnectionInstance.getOvsdbClient());
//TODO do cleanup for old connection or stale check
}
disconnected(ovsdbConnectionInstance.getOvsdbClient());
//TODO do cleanup for old connection or stale check
}
package org.opendaylight.ovsdb.southbound;
import java.util.Collection;
package org.opendaylight.ovsdb.southbound;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.ovsdb.southbound.transactions.md.TransactionInvoker;
+import org.opendaylight.ovsdb.utils.mdsal.utils.Scheduler;
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.TopologyKey;
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.TopologyKey;
+ private static final Map<InstanceIdentifier<Node>, ScheduledFuture> TIMEOUT_FTS = new ConcurrentHashMap<>();
+ public static void runAfterTimeoutIfNodeNotCreated(InstanceIdentifier<Node> iid, Runnable job) {
+ ScheduledFuture<?> ft = TIMEOUT_FTS.get(iid);
+ if (ft != null) {
+ ft.cancel(false);
+ }
+ ft = Scheduler.getScheduledExecutorService().schedule(() -> {
+ TIMEOUT_FTS.remove(iid);
+ if (!OPER_NODE_CACHE.containsKey(iid)) {
+ job.run();
+ }
+ }, SouthboundConstants.EOS_TIMEOUT, TimeUnit.SECONDS);
+ TIMEOUT_FTS.put(iid, ft);
+ }
private Node getCreated(DataObjectModification<Node> mod) {
if ((mod.getModificationType() == DataObjectModification.ModificationType.WRITE)
private Node getCreated(DataObjectModification<Node> mod) {
if ((mod.getModificationType() == DataObjectModification.ModificationType.WRITE)
+
+ int EOS_TIMEOUT = Integer.getInteger("southbound.eos.timeout.delay.secs", 240);