Tal Nisan has posted comments on this change. Change subject: core: Change connect/disconnect storage commands to type agnostic ......................................................................
Patch Set 2: (8 comments) http://gerrit.ovirt.org/#/c/23296/2/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectHostToStoragePooServerCommandBase.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectHostToStoragePooServerCommandBase.java: Line 25: return connectionsTypeMap; Line 26: } Line 27: Line 28: protected void initConnectionList() { Line 29: _connections = new ArrayList<StorageServerConnections>( > this should be part of the object creation and thus _connections should nev Done, the DbFacade call guarantees a not null list as it is so _connections cannot be null Line 30: DbFacade.getInstance().getStorageServerConnectionDao().getAllConnectableStorageSeverConnection(getStoragePool().getId())); Line 31: updateConnectionsTypeMap(); Line 32: } Line 33: Line 33: Line 34: private void updateConnectionsTypeMap() { Line 35: connectionsTypeMap = new HashMap<>(); Line 36: for (StorageServerConnections conn : _connections) { Line 37: if (!connectionsTypeMap.containsKey(conn.getstorage_type())) { > please add: Done Line 38: connectionsTypeMap.put(conn.getstorage_type(), new ArrayList<StorageServerConnections>()); Line 39: } Line 40: connectionsTypeMap.get(conn.getstorage_type()).add(conn); Line 41: } http://gerrit.ovirt.org/#/c/23296/2/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectHostToStoragePoolServersCommand.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectHostToStoragePoolServersCommand.java: Line 42: } Line 43: Line 44: private boolean connectStorageServer(Map<StorageType, List<StorageServerConnections>> connectionsByType) { Line 45: boolean connectSucceeded = true; Line 46: if (connectionsByType != null && connectionsByType.size() > 0) { > 1. I don't see where it would be valid to pass null to this method (getConn Correct, changed Line 47: for (Map.Entry<StorageType, List<StorageServerConnections>> connectionToType : connectionsByType.entrySet()) { Line 48: connectSucceeded = connectSucceeded && connectStorageServersByType(connectionToType.getKey(), connectionToType.getValue()); Line 49: } Line 50: Line 43: Line 44: private boolean connectStorageServer(Map<StorageType, List<StorageServerConnections>> connectionsByType) { Line 45: boolean connectSucceeded = true; Line 46: if (connectionsByType != null && connectionsByType.size() > 0) { Line 47: for (Map.Entry<StorageType, List<StorageServerConnections>> connectionToType : connectionsByType.entrySet()) { > looping over the entrySet makes the variable names illegible. I agree on the fact that it's less illegible yet it's very inefficient to iterate like this, even though we are limited to a low number of connection types, instead I've extracted it to variables to make it more readable StorageType connectionsType = connectionToType.getKey(); List<StorageServerConnections> connections = connectionToType.getValue(); connectSucceeded = connectSucceeded && connectStorageServersByType(connectionsType, connections); Line 48: connectSucceeded = connectSucceeded && connectStorageServersByType(connectionToType.getKey(), connectionToType.getValue()); Line 49: } Line 50: Line 51: log.infoFormat("Host {0} storage connection was {1} ", getVds().getName(), Line 44: private boolean connectStorageServer(Map<StorageType, List<StorageServerConnections>> connectionsByType) { Line 45: boolean connectSucceeded = true; Line 46: if (connectionsByType != null && connectionsByType.size() > 0) { Line 47: for (Map.Entry<StorageType, List<StorageServerConnections>> connectionToType : connectionsByType.entrySet()) { Line 48: connectSucceeded = connectSucceeded && connectStorageServersByType(connectionToType.getKey(), connectionToType.getValue()); > connectSucceeded which returs false if any of the connections failed and tr I see what you mean, but it's not in the scope of these patchsets Line 49: } Line 50: Line 51: log.infoFormat("Host {0} storage connection was {1} ", getVds().getName(), Line 52: connectSucceeded ? "succeeded" : "failed"); http://gerrit.ovirt.org/#/c/23296/2/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/DisconnectHostFromStoragePoolServersCommand.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/DisconnectHostFromStoragePoolServersCommand.java: Line 16: Line 17: @InternalCommandAttribute Line 18: @NonTransactiveCommandAttribute Line 19: public class DisconnectHostFromStoragePoolServersCommand extends Line 20: ConnectHostToStoragePooServerCommandBase<HostStoragePoolParametersBase> { > ConnectHostToStorage Poo? Indeed hehe, Maor fixed that in another patch, I will rebase on it soon Line 21: Line 22: public DisconnectHostFromStoragePoolServersCommand(HostStoragePoolParametersBase parameters) { Line 23: super(parameters); Line 24: setStoragePool(parameters.getStoragePool()); Line 27: Line 28: @Override Line 29: protected void executeCommand() { Line 30: initConnectionList(); Line 31: // TODO: check if host belong to more than one storage pool > please remove this comment, it's plain wrong Done Line 32: Line 33: if (getConnectionsTypeMap() != null && getConnectionsTypeMap().size() > 0) { Line 34: for (Map.Entry<StorageType, List<StorageServerConnections>> connectionToType : getConnectionsTypeMap().entrySet()) { Line 35: disconnectStorageByType(connectionToType.getKey(), connectionToType.getValue()); Line 29: protected void executeCommand() { Line 30: initConnectionList(); Line 31: // TODO: check if host belong to more than one storage pool Line 32: Line 33: if (getConnectionsTypeMap() != null && getConnectionsTypeMap().size() > 0) { > 1. getConnectionsTypeMap should never be null so check is redundant Done Line 34: for (Map.Entry<StorageType, List<StorageServerConnections>> connectionToType : getConnectionsTypeMap().entrySet()) { Line 35: disconnectStorageByType(connectionToType.getKey(), connectionToType.getValue()); Line 36: } Line 37: } -- To view, visit http://gerrit.ovirt.org/23296 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I07a7fb8af9ce89a38b51cdb07a43a15f9c13f839 Gerrit-PatchSet: 2 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tal Nisan <[email protected]> Gerrit-Reviewer: Allon Mureinik <[email protected]> Gerrit-Reviewer: Ayal Baron <[email protected]> Gerrit-Reviewer: Daniel Erez <[email protected]> Gerrit-Reviewer: Federico Simoncelli <[email protected]> Gerrit-Reviewer: Liron Ar <[email protected]> Gerrit-Reviewer: Maor Lipchuk <[email protected]> Gerrit-Reviewer: Sergey Gotliv <[email protected]> Gerrit-Reviewer: Tal Nisan <[email protected]> Gerrit-Reviewer: Vered Volansky <[email protected]> Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
