Remove duplicated ovsdb javadoc, harden setController logic

Change-Id: I1b0aad513ded71a767d72e6e2eafb836366285c5
This commit is contained in:
Jian Li 2019-06-13 13:45:26 +09:00
parent a1010de8ea
commit 46fcbe4b91
2 changed files with 34 additions and 71 deletions

View File

@ -55,7 +55,7 @@ public interface OvsdbClientService extends OvsdbRpc {
* selectSrcPort or packets containing selectVlan
* to mirrorPort or to all ports that trunk mirrorVlan.
*
* @param bridgeName the name of the bridge
* @param bridgeName the name of the bridge
* @param mirror the OVSDB mirror description
* @return true if mirror creation is successful, false otherwise
*/
@ -119,14 +119,14 @@ public interface OvsdbClientService extends OvsdbRpc {
/**
* Gets a qos of node.
* @param qosId qos identifier
* @return null if no qos is find
* @return null if no qos is found
*/
OvsdbQos getQos(QosId qosId);
/**
* Gets qoses of node.
*
* @return set of qoses; empty if no qos is find
* @return set of qoses; empty if no qos is found
*/
Set<OvsdbQos> getQoses();
@ -165,14 +165,14 @@ public interface OvsdbClientService extends OvsdbRpc {
/**
* Gets a queue of node.
* @param queueId the queue identifier
* @return null if no queue is find
* @return null if no queue is found
*/
OvsdbQueue getQueue(QueueId queueId);
/**
* Gets queues of node.
*
* @return set of queues; empty if no queue is find
* @return set of queues; empty if no queue is found
*/
Set<OvsdbQueue> getQueues();
@ -211,7 +211,7 @@ public interface OvsdbClientService extends OvsdbRpc {
/**
* Gets bridges of node.
*
* @return set of bridges; empty if no bridge is find
* @return set of bridges; empty if no bridge is found
*/
Set<OvsdbBridge> getBridges();
@ -219,7 +219,7 @@ public interface OvsdbClientService extends OvsdbRpc {
* Gets controllers of node.
*
* @param openflowDeviceId target device id
* @return set of controllers; empty if no controller is find
* @return set of controllers; empty if no controller is found
*/
Set<ControllerInfo> getControllers(DeviceId openflowDeviceId);
@ -262,14 +262,14 @@ public interface OvsdbClientService extends OvsdbRpc {
/**
* Gets ports of bridge.
*
* @return set of ports; empty if no ports is find
* @return set of ports; empty if no ports is found
*/
Set<OvsdbPort> getPorts();
/**
* Gets interfaces of bridge.
*
* @return set of interfaces; empty if no interface is find
* @return set of interfaces; empty if no interface is found
*/
Set<Interface> getInterfaces();
@ -292,7 +292,7 @@ public interface OvsdbClientService extends OvsdbRpc {
* Gets the Bridge uuid.
*
* @param bridgeName bridge name
* @return bridge uuid, empty if no uuid is find
* @return bridge uuid, empty if no uuid is found
*/
String getBridgeUuid(String bridgeName);
@ -301,7 +301,7 @@ public interface OvsdbClientService extends OvsdbRpc {
*
* @param portName port name
* @param bridgeUuid bridge uuid
* @return port uuid, empty if no uuid is find
* @return port uuid, empty if no uuid is found
*/
String getPortUuid(String portName, String bridgeUuid);
@ -336,7 +336,7 @@ public interface OvsdbClientService extends OvsdbRpc {
* @param dbName database name
* @param tableName table name
* @param uuid row uuid
* @return row OVSDB row
* @return row, empty if no row is found
*/
Row getRow(String dbName, String tableName, String uuid);
@ -381,7 +381,7 @@ public interface OvsdbClientService extends OvsdbRpc {
* Considered port as created if port's interface table also gets created,irrespective
* of ofport value(has errors or not)
*/
public List<OvsdbPortName> getPorts(List<String> portNames, DeviceId bridgeId);
List<OvsdbPortName> getPorts(List<String> portNames, DeviceId bridgeId);
/**
* Gets error status for the given portNames.
@ -397,20 +397,21 @@ public interface OvsdbClientService extends OvsdbRpc {
*
* @param dbName db name
* @param tblName table name
* @return first table entry
* @return firstRow, first row of the given table from given db if present
*/
public Optional<Object> getFirstRow(String dbName, OvsdbTable tblName);
Optional<Object> getFirstRow(String dbName, OvsdbTable tblName);
/**
* Gets device CPU usage in percentage.
* @return device memory usage.
*
* @return cpuStats, empty data as there is no generic way to fetch such stats
*/
Optional<DeviceCpuStats> getDeviceCpuUsage();
/**
* Gets device memory usage in kilobytes.
* @return device memory usage.
*
* @return memoryStats, empty data as there is no generic way to fetch such stats
*/
Optional<DeviceMemoryStats> getDeviceMemoryUsage();

View File

@ -233,14 +233,6 @@ public class DefaultOvsdbClient implements OvsdbProviderService, OvsdbClientServ
return rowStore;
}
/**
* Gets the ovsdb row.
*
* @param dbName the ovsdb database name
* @param tableName the ovsdb table name
* @param uuid the key of the row
* @return row, empty if row is find
*/
@Override
public Row getRow(String dbName, String tableName, String uuid) {
OvsdbTableStore tableStore = getTableStore(dbName);
@ -283,12 +275,6 @@ public class DefaultOvsdbClient implements OvsdbProviderService, OvsdbClientServ
ovsdbStore.createOrUpdateOvsdbStore(dbName, tableStore);
}
/**
* Gets the Mirror uuid.
*
* @param mirrorName mirror name
* @return mirror uuid, empty if no uuid is found
*/
@Override
public String getMirrorUuid(String mirrorName) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
@ -316,12 +302,6 @@ public class DefaultOvsdbClient implements OvsdbProviderService, OvsdbClientServ
return null;
}
/**
* Gets mirrors of the device.
*
* @param deviceId target device id
* @return set of mirroring; empty if no mirror is found
*/
@Override
public Set<MirroringStatistics> getMirroringStatistics(DeviceId deviceId) {
Uuid bridgeUuid = getBridgeUuid(deviceId);
@ -584,8 +564,20 @@ public class DefaultOvsdbClient implements OvsdbProviderService, OvsdbClientServ
bridgeUuid.value(),
c.getRow()));
removeControllers.forEach(c -> deleteConfig(CONTROLLER, UUID, c.getRow().uuid().value(),
BRIDGE, BRIDGE_CONTROLLER, c.getRow().uuid()));
// Controller removal is extremely dangerous operation, because with
// empty controller list, all existing flow rules will be wiped out.
// To harden the setController operation, we need to double check whether
// the updated controller list size is bigger than the remove controller list size
List<Controller> updatedControllers = getControllers(bridgeUuid);
if (updatedControllers != null && updatedControllers.size() > removeControllers.size()) {
removeControllers.forEach(c ->
deleteConfig(CONTROLLER, UUID, c.getRow().uuid().value(),
BRIDGE, BRIDGE_CONTROLLER, c.getRow().uuid()));
} else {
log.warn("New controllers were not properly configured to OVS " +
"bridge {} or failed to retrieve controller list from OVS " +
"bridge {}", bridgeUuid, bridgeUuid);
}
}
@Override
@ -951,15 +943,7 @@ public class DefaultOvsdbClient implements OvsdbProviderService, OvsdbClientServ
.collect(Collectors.toSet());
return ovsdbqueues;
}
/**
* Creates a mirror port. Mirrors the traffic
* that goes to selectDstPort or comes from
* selectSrcPort or packets containing selectVlan
* to mirrorPort or to all ports that trunk mirrorVlan.
*
* @param mirror the OVSDB mirror description
* @return true if mirror creation is successful, false otherwise
*/
@Override
public boolean createMirror(String bridgeName, OvsdbMirror mirror) {
@ -1071,11 +1055,6 @@ public class DefaultOvsdbClient implements OvsdbProviderService, OvsdbClientServ
return true;
}
/**
* Drops the configuration for mirror.
*
* @param mirroringName name of mirror to drop
*/
@Override
public void dropMirror(MirroringName mirroringName) {
String mirrorUuid = getMirrorUuid(mirroringName.name());
@ -1928,13 +1907,6 @@ public class DefaultOvsdbClient implements OvsdbProviderService, OvsdbClientServ
.findFirst().orElse(null);
}
/**
* Get first row of given table from given db.
*
* @param dbName db name
* @param tblName table name
* @return firstRow, first row of the given table from given db if present
*/
@Override
public Optional<Object> getFirstRow(String dbName, OvsdbTable tblName) {
@ -1969,22 +1941,12 @@ public class DefaultOvsdbClient implements OvsdbProviderService, OvsdbClientServ
}
/**
* Get memory usage of device.
*
* @return memoryStats, empty data as there is no generic way to fetch such stats
*/
@Override
public Optional<DeviceMemoryStats> getDeviceMemoryUsage() {
return Optional.empty();
}
/**
* Get cpu usage of device.
*
* @return cpuStats, empty data as there is no generic way to fetch such stats
*/
@Override
public Optional<DeviceCpuStats> getDeviceCpuUsage() {
return Optional.empty();