Shireesh Anjal has uploaded a new change for review. Change subject: core: Adding locks in case of gluster hosts ......................................................................
core: Adding locks in case of gluster hosts If the host being added/removed belongs to a gluster enabled cluster, an exclusive lock will be acquired on the cluster. Change-Id: If9d4fec2fafd5f9f32521025da301f8b07b6e713 Signed-off-by: Shireesh Anjal <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVdsCommand.java 2 files changed, 36 insertions(+), 17 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/50/10850/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java index cef856f..4b25836 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java @@ -36,6 +36,7 @@ import org.ovirt.engine.core.common.errors.VdcBllErrors; import org.ovirt.engine.core.common.job.Step; import org.ovirt.engine.core.common.job.StepEnum; +import org.ovirt.engine.core.common.locks.LockingGroup; import org.ovirt.engine.core.common.utils.ValidationUtils; import org.ovirt.engine.core.common.validation.group.CreateEntity; import org.ovirt.engine.core.common.validation.group.PowerManagementCheck; @@ -315,7 +316,7 @@ addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_INSTALL_EMPTY_PASSWORD); returnValue = false; } else if (!IsPowerManagementLegal(getParameters().getVdsStaticData(), getVdsGroup() - .getcompatibility_version().toString())) { + .getcompatibility_version().toString())) { returnValue = false; } else { returnValue = returnValue && canConnect(vds); @@ -360,28 +361,25 @@ sshclient.setPassword(getParameters().getRootPassword()); sshclient.connect(); sshclient.authenticate(); - } - catch (AuthenticationException e) { + } catch (AuthenticationException e) { log.errorFormat( - "Failed to authenticate session with host {0}", - vds.getvds_name(), - e - ); + "Failed to authenticate session with host {0}", + vds.getvds_name(), + e + ); addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_AUTHENTICATE_TO_SERVER); returnValue = false; - } - catch (Exception e) { + } catch (Exception e) { log.errorFormat( - "Failed to establish session with host {0}", - vds.getvds_name(), - e - ); + "Failed to establish session with host {0}", + vds.getvds_name(), + e + ); addCanDoActionMessage(VdcBllMessages.VDS_CANNOT_CONNECT_TO_SERVER); returnValue = false; - } - finally { + } finally { if (sshclient != null) { sshclient.disconnect(); } @@ -444,4 +442,12 @@ private List<VDS> getAllVds(Guid clusterId) { return getVdsDAO().getAllForVdsGroup(clusterId); } + + @Override + protected Map<String, String> getExclusiveLocks() { + if (getVdsGroup().supportsGlusterService() && !isInternalExecution()) { + return Collections.singletonMap(getVdsGroupId().toString(), LockingGroup.GLUSTER.name()); + } + return super.getExclusiveLocks(); + } } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVdsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVdsCommand.java index 21c33d4..b4d6a5e 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVdsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVdsCommand.java @@ -1,6 +1,6 @@ package org.ovirt.engine.core.bll; -import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -10,6 +10,7 @@ import org.ovirt.engine.core.common.action.RemoveVdsParameters; import org.ovirt.engine.core.common.businessentities.StorageType; import org.ovirt.engine.core.common.businessentities.VDS; +import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VDSStatus; import org.ovirt.engine.core.common.businessentities.VdsDynamic; import org.ovirt.engine.core.common.businessentities.storage_pool; @@ -233,6 +234,18 @@ @Override protected Map<String, String> getExclusiveLocks() { - return Collections.singletonMap(getParameters().getVdsId().toString(), LockingGroup.VDS.name()); + Map<String, String> locks = new HashMap<String, String>(); + + VDSGroup cluster = getVdsGroup(); + if(cluster.supportsVirtService()) { + locks.put(getParameters().getVdsId().toString(), LockingGroup.VDS.name()); + } + + // Need to acquire lock on cluster if the host belongs to a gluster cluster + if(cluster.supportsGlusterService()) { + locks.put(cluster.getId().toString(), LockingGroup.GLUSTER.name()); + } + + return locks; } } -- To view, visit http://gerrit.ovirt.org/10850 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If9d4fec2fafd5f9f32521025da301f8b07b6e713 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Shireesh Anjal <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
