void setOtherConfig(Map<String, String> otherConfig);
@TypedColumn (name = "max_backoff", method = MethodType.GETCOLUMN, fromVersion = "1.0.0")
- Column<GenericTableSchema, Long> getMaxBackoffColumn();
+ Column<GenericTableSchema, Set<Long>> getMaxBackoffColumn();
@TypedColumn (name = "max_backoff", method = MethodType.SETDATA, fromVersion = "1.0.0")
- void setMaxBackoff(Long maxBackoff);
+ void setMaxBackoff(Set<Long> maxBackoff);
@TypedColumn (name = "local_ip", method = MethodType.GETCOLUMN, fromVersion = "1.0.0")
Column<GenericTableSchema, Set<String>> getLocalIpColumn();
leaf is-connected {
type boolean;
}
+ leaf max_backoff {
+ description
+ "Maximum number of milliseconds to wait between
+ connection attempts";
+ type uint32 {
+ range "1000..max";
+ }
+ }
+ leaf inactivity_probe {
+ description
+ "Maximum number of milliseconds of idle time on connection
+ to controller before sending an inactivity probe message.
+ A value of 0 disables inactivity probes.";
+ type uint32;
+ }
}
final org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid uuid =
new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang
.ietf.yang.types.rev130715.Uuid(controller.getUuid().toString());
+ ControllerEntryBuilder builder = new ControllerEntryBuilder();
- controllerEntries.add(new ControllerEntryBuilder()
+ if (controller.getMaxBackoffColumn() != null && controller.getMaxBackoffColumn().getData() != null
+ && !controller.getMaxBackoffColumn().getData().isEmpty()) {
+ builder.setMaxBackoff(controller.getMaxBackoffColumn().getData().iterator().next());
+ }
+ if (controller.getInactivityProbeColumn() != null && controller.getInactivityProbeColumn().getData() != null
+ && !controller.getInactivityProbeColumn().getData().isEmpty()) {
+ builder.setInactivityProbe(controller.getInactivityProbeColumn().getData().iterator().next());
+ }
+ controllerEntries.add(builder
.setTarget(new Uri(targetString))
.setIsConnected(controller.getIsConnectedColumn().getData())
.setControllerUuid(uuid).build());
}
}
+ // This is not called from anywhere but test. Do we need this?
public static Map<UUID, Controller> createOvsdbController(OvsdbBridgeAugmentation omn,DatabaseSchema dbSchema) {
List<ControllerEntry> controllerEntries = omn.getControllerEntry();
Map<UUID,Controller> controllerMap = new HashMap<>();
final String targetString = manager.getTargetColumn().getData();
final Map<String, String> statusAttributeMap =
- (manager.getStatusColumn() == null) ? null : manager.getStatusColumn().getData();
- if ((statusAttributeMap != null) && statusAttributeMap.containsKey(N_CONNECTIONS_STR)) {
+ manager.getStatusColumn() == null ? null : manager.getStatusColumn().getData();
+ if (statusAttributeMap != null && statusAttributeMap.containsKey(N_CONNECTIONS_STR)) {
String numberOfConnectionValueStr = statusAttributeMap.get(N_CONNECTIONS_STR);
numberOfConnections = Integer.parseInt(numberOfConnectionValueStr);
} else {
&& ovsdbBridge.getBridgeName() != null
&& entry.getValue() != null
&& entry.getValue().getTarget() != null) {
+ ControllerEntry controllerEntry = entry.getValue();
Controller controller =
TyperUtils.getTypedRowWrapper(transaction.getDatabaseSchema(), Controller.class);
- controller.setTarget(entry.getValue().getTarget().getValue());
+ controller.setTarget(controllerEntry.getTarget().getValue());
+ if (controllerEntry.getMaxBackoff() != null) {
+ controller.setMaxBackoff(Sets.newHashSet(controllerEntry.getMaxBackoff()));
+ }
+ if (controllerEntry.getInactivityProbe() != null) {
+ controller.setInactivityProbe(Sets.newHashSet(controllerEntry.getInactivityProbe()));
+ }
String controllerNamedUuidString = SouthboundMapper.getRandomUuid();
UUID controllerNamedUuid = new UUID(controllerNamedUuidString);
transaction.add(op.insert(controller).withId(controllerNamedUuidString));
import java.util.ArrayList;
import java.util.List;
-
+import java.util.NoSuchElementException;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.ovsdb.lib.message.TableUpdates;
import org.opendaylight.ovsdb.lib.notation.Version;
public class OvsdbOperationalCommandAggregator implements TransactionCommand {
private static final Logger LOG = LoggerFactory.getLogger(OvsdbOperationalCommandAggregator.class);
- private List<TransactionCommand> commands = new ArrayList<>();
+ private final List<TransactionCommand> commands = new ArrayList<>();
public OvsdbOperationalCommandAggregator(InstanceIdentifierCodec instanceIdentifierCodec,
OvsdbConnectionInstance key, TableUpdates updates, DatabaseSchema dbSchema) {
for (TransactionCommand command: commands) {
try {
command.execute(transaction);
- } catch (NullPointerException e) {
+ } catch (NullPointerException | NoSuchElementException | ClassCastException e) {
LOG.warn("Exception trying to execute {}", command, e);
}
}
private static final String FORMAT_STR = "%s_%s_%d";
private static final Version AUTOATTACH_FROM_VERSION = Version.fromString("7.11.2");
private static final Version IF_INDEX_FROM_VERSION = Version.fromString("7.2.1");
+ private static final Long MAX_BACKOFF = 10000L;
+ private static final Long INACTIVITY_PROBE = 30000L;
private static String addressStr;
private static int portNumber;
private static String connectionType;
if (entry.getTarget() != null) {
Assert.assertEquals(setUri.toString(), entry.getTarget().toString());
}
+ if (entry.getMaxBackoff() != null) {
+ Assert.assertEquals(entry.getMaxBackoff(), MAX_BACKOFF);
+ }
+ if (entry.getInactivityProbe() != null) {
+ Assert.assertEquals(entry.getInactivityProbe(),INACTIVITY_PROBE);
+ }
}
}
}
List<ControllerEntry> controllerEntriesList = new ArrayList<>();
controllerEntriesList.add(new ControllerEntryBuilder()
.setTarget(new Uri(controllerTarget))
+ .setMaxBackoff(MAX_BACKOFF)
+ .setInactivityProbe(INACTIVITY_PROBE)
.build());
return controllerEntriesList;
}
* @return success if the write to md-sal was successful
*/
public boolean setBridgeController(Node ovsdbNode, String bridgeName, List<String> controllers) {
+ return setBridgeController(ovsdbNode, bridgeName, controllers, null, null);
+ }
+ /**
+ * Set the controllers of an existing bridge node
+ * @param ovsdbNode where the bridge is
+ * @param bridgeName Name of the bridge
+ * @param controllers controller strings
+ * @param maxBackoff Max backoff in milliseconds
+ * @param inactivityProbe inactivity probe in milliseconds
+ * @return success if the write to md-sal was successful
+ */
+ public boolean setBridgeController(Node ovsdbNode, String bridgeName, List<String> controllers,
+ Long maxBackoff, Long inactivityProbe) {
LOG.debug("setBridgeController: ovsdbNode: {}, bridgeNode: {}, controller(s): {}",
ovsdbNode, bridgeName, controllers);
List<ControllerEntry> newControllerEntries = new ArrayList<>();
if(existingControllerEntries != null) {
NEW_ENTRY_LOOP:
- for (ControllerEntry newEntry : createControllerEntries(controllers)) {
+ for (ControllerEntry newEntry : createControllerEntries(controllers, maxBackoff, inactivityProbe)) {
for (ControllerEntry existingEntry : existingControllerEntries) {
if (newEntry.getTarget().equals(existingEntry.getTarget())) {
continue NEW_ENTRY_LOOP;
newControllerEntries.add(newEntry);
}
} else {
- newControllerEntries = createControllerEntries(controllers);
+ newControllerEntries = createControllerEntries(controllers,maxBackoff, inactivityProbe);
}
if(newControllerEntries.isEmpty()) {
}
public boolean addBridge(Node ovsdbNode, String bridgeName, List<String> controllersStr,
- final Class<? extends DatapathTypeBase> dpType, String mac) {
+ final Class<? extends DatapathTypeBase> dpType, String mac) {
+ return addBridge(ovsdbNode, bridgeName, controllersStr, dpType, mac, null, null);
+ }
+
+ public boolean addBridge(Node ovsdbNode, String bridgeName, List<String> controllersStr,
+ final Class<? extends DatapathTypeBase> dpType, String mac,
+ Long maxBackoff, Long inactivityProbe) {
boolean result;
LOG.info("addBridge: node: {}, bridgeName: {}, controller(s): {}", ovsdbNode, bridgeName, controllersStr);
NodeId bridgeNodeId = createManagedNodeId(bridgeIid);
bridgeNodeBuilder.setNodeId(bridgeNodeId);
OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder();
- ovsdbBridgeAugmentationBuilder.setControllerEntry(createControllerEntries(controllersStr));
+ ovsdbBridgeAugmentationBuilder.setControllerEntry(createControllerEntries(
+ controllersStr, maxBackoff, inactivityProbe));
ovsdbBridgeAugmentationBuilder.setBridgeName(new OvsdbBridgeName(bridgeName));
ovsdbBridgeAugmentationBuilder.setProtocolEntry(createMdsalProtocols());
ovsdbBridgeAugmentationBuilder.setFailMode( OVSDB_FAIL_MODE_MAP.inverse().get("secure"));
return found;
}
- private List<ControllerEntry> createControllerEntries(List<String> controllersStr) {
+ private List<ControllerEntry> createControllerEntries(List<String> controllersStr,
+ Long maxBackoff, Long inactivityProbe) {
List<ControllerEntry> controllerEntries = new ArrayList<>();
if (controllersStr != null) {
for (String controllerStr : controllersStr) {
ControllerEntryBuilder controllerEntryBuilder = new ControllerEntryBuilder();
controllerEntryBuilder.setTarget(new Uri(controllerStr));
+ if (maxBackoff != null) {
+ controllerEntryBuilder.setMaxBackoff(maxBackoff);
+ }
+ if (inactivityProbe != null) {
+ controllerEntryBuilder.setInactivityProbe(inactivityProbe);
+ }
controllerEntries.add(controllerEntryBuilder.build());
}
}