import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
+
+import java.net.ConnectException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
new ConcurrentHashMap<>();
private static final Logger LOG = LoggerFactory.getLogger(OvsdbConnectionManager.class);
private static final String ENTITY_TYPE = "ovsdb";
+ private static final int DB_FETCH_TIMEOUT = 1000;
private DataBroker db;
private TransactionInvoker txInvoker;
externalClient.getConnectionInfo().getLocalPort());
List<String> databases = new ArrayList<>();
try {
- databases = externalClient.getDatabases().get(1000, TimeUnit.MILLISECONDS);
+ databases = externalClient.getDatabases().get(DB_FETCH_TIMEOUT, TimeUnit.MILLISECONDS);
if (databases.contains(SouthboundConstants.OPEN_V_SWITCH)) {
OvsdbConnectionInstance client = connectedButCallBacksNotRegistered(externalClient);
// Register Cluster Ownership for ConnectionInfo
}
public OvsdbClient connect(InstanceIdentifier<Node> iid,
- OvsdbNodeAugmentation ovsdbNode) throws UnknownHostException {
+ OvsdbNodeAugmentation ovsdbNode) throws UnknownHostException, ConnectException {
LOG.info("Connecting to {}", SouthboundUtil.connectionInfoToString(ovsdbNode.getConnectionInfo()));
// TODO handle case where we already have a connection
ovsdbDeviceEntityOwnershipListener.close();
}
- for (OvsdbClient client: clients.values()) {
+ for (OvsdbConnectionInstance client: clients.values()) {
client.disconnect();
}
}
LogicalDatastoreType.OPERATIONAL, nodePath);
transaction.close();
Optional<Node> optional = nodeFuture.get();
- if (optional != null && optional.isPresent() && optional.get() != null) {
+ if (optional.isPresent()) {
return this.getConnectionInstance(optional.get());
} else {
- LOG.warn("Found non-topological node {} on path {}",optional);
+ LOG.debug("Node was not found on the path in the operational DS: {}", nodePath);
return null;
}
- } catch (Exception e) {
+ } catch (InterruptedException | ExecutionException e) {
LOG.warn("Failed to get Ovsdb Node {}",nodePath, e);
return null;
}
}
public OvsdbClient getClient(ConnectionInfo connectionInfo) {
- return getConnectionInstance(connectionInfo);
+ return getConnectionInstance(connectionInfo).getOvsdbClient();
}
public OvsdbClient getClient(OvsdbBridgeAttributes mn) {
- return getConnectionInstance(mn);
+ return getConnectionInstance(mn).getOvsdbClient();
}
public OvsdbClient getClient(Node node) {
- return getConnectionInstance(node);
+ return getConnectionInstance(node).getOvsdbClient();
}
public Boolean getHasDeviceOwnership(ConnectionInfo connectionInfo) {
iid,
null);
reconciliationManager.dequeue(task);
+ reconciliationManager.cancelTerminationPointReconciliation();
}
private void handleOwnershipChanged(EntityOwnershipChange ownershipChange) {
DatabaseSchema dbSchema = null;
OpenVSwitch openVSwitchRow = null;
try {
- dbSchema = connectionInstance.getSchema(OvsdbSchemaContants.databaseName).get();
+ dbSchema = connectionInstance.getSchema(OvsdbSchemaContants.DATABASE_NAME).get();
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Not able to fetch schema for database {} from device {}",
- OvsdbSchemaContants.databaseName,connectionInstance.getConnectionInfo(),e);
+ OvsdbSchemaContants.DATABASE_NAME,connectionInstance.getConnectionInfo(),e);
}
if (dbSchema != null) {
GenericTableSchema openVSwitchSchema = TyperUtils.getTableSchema(dbSchema, OpenVSwitch.class);