Selvasundaram has uploaded a new change for review. Change subject: engine: check and peer probe gluster servers ......................................................................
engine: check and peer probe gluster servers Whenever the gluster server comes up, do peer probe if not done already. Change-Id: I13c8de35ac596d89d2a9c631c4a8ef26996ea860 Signed-off-by: Selvasundaram <sesub...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java 2 files changed, 78 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/43/7243/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java index 73f21bb..d81991d 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java @@ -1,5 +1,8 @@ package org.ovirt.engine.core.bll; +import java.util.ArrayList; +import java.util.List; + import org.ovirt.engine.core.bll.storage.StorageHandlingCommandBase; import org.ovirt.engine.core.bll.storage.StoragePoolStatusHandler; import org.ovirt.engine.core.common.AuditLogType; @@ -10,12 +13,17 @@ import org.ovirt.engine.core.common.businessentities.FenceStatusReturnValue; import org.ovirt.engine.core.common.businessentities.NonOperationalReason; import org.ovirt.engine.core.common.businessentities.StoragePoolStatus; +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.VdsSpmStatus; import org.ovirt.engine.core.common.businessentities.storage_pool; import org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; +import org.ovirt.engine.core.common.vdscommands.VdsIdVDSCommandParametersBase; +import org.ovirt.engine.core.common.vdscommands.gluster.GlusterHostAddVDSParameters; +import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.TransactionScopeOption; import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AlertDirector; @@ -46,6 +54,10 @@ if (vdsGroup.supportsVirtService()) { initVirtResources(); + } + + if (vdsGroup.supportsGlusterService()) { + initGlusterPeerProcess(); } setSucceeded(true); } @@ -172,4 +184,68 @@ } return type; } + + private void initGlusterPeerProcess() { + List<VDS> vdsList = DbFacade.getInstance().getVdsDAO().getAllForVdsGroup(getVdsGroupId()); + // If the cluster already having Gluster servers, get an up server + if (vdsList != null && vdsList.size() > 1) { + VDS upServer = null; + for (int i = 0; i < vdsList.size(); i++) { + if (!Guid.OpEquality(getVdsId(), vdsList.get(i).getId()) + && vdsList.get(i).getstatus() == VDSStatus.Up) { + upServer = vdsList.get(i); + break; + } + } + // If new server is not part of the existing gluster peers, add into peer group + if (upServer != null) { + if (!hostExists(getGlusterPeers(upServer.getId()), upServer.getId())) { + String newServerName = + getVds().gethost_name().isEmpty() ? getVds().getManagmentIp() : getVds().gethost_name(); + glusterPeerProbe(upServer.getId(), newServerName); + } + } + } + } + + private boolean hostExists(List<VDS> glusterServers, Guid serverId) { + for (VDS vds : glusterServers) { + if (vds.getId().equals(serverId)) { + return true; + } + } + return false; + } + + private List<VDS> getGlusterPeers(Guid upServerId) { + List<VDS> glusterServers = new ArrayList<VDS>(); + VDSReturnValue returnValue = Backend.getInstance() + .getResourceManager() + .RunVdsCommand(VDSCommandType.GlusterHostsList, + new VdsIdVDSCommandParametersBase(upServerId)); + setSucceeded(returnValue.getSucceeded()); + if (getSucceeded()) { + glusterServers = (List<VDS>) returnValue.getReturnValue(); + } else { + getReturnValue().getFault().setError(returnValue.getVdsError().getCode()); + getReturnValue().getFault().setMessage(returnValue.getVdsError().getMessage()); + AuditLogDirector.log(new AuditLogableBase(upServerId), AuditLogType.GLUSTER_HOST_LIST_FAILED); + } + return glusterServers; + } + + private void glusterPeerProbe(Guid upServerId, String newServerName) { + VDSReturnValue returnValue = + runVdsCommand( + VDSCommandType.GlusterHostAdd, + new GlusterHostAddVDSParameters(upServerId, newServerName)); + setSucceeded(returnValue.getSucceeded()); + if (!getSucceeded()) { + getReturnValue().getFault().setError(returnValue.getVdsError().getCode()); + getReturnValue().getFault().setMessage(returnValue.getVdsError().getMessage()); + AuditLogDirector.log(new AuditLogableBase(upServerId), AuditLogType.GLUSTER_HOST_ADD_FAILED); + return; + } + } + } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java index a770eff..baa4ead 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/VDSCommandType.java @@ -135,7 +135,8 @@ AddBricksToGlusterVolume("org.ovirt.engine.core.vdsbroker.gluster"), ReplaceGlusterVolumeBrick("org.ovirt.engine.core.vdsbroker.gluster"), GlusterHostRemove("org.ovirt.engine.core.vdsbroker.gluster"), - GlusterHostAdd("org.ovirt.engine.core.vdsbroker.gluster"); + GlusterHostAdd("org.ovirt.engine.core.vdsbroker.gluster"), + GlusterHostsList("org.ovirt.engine.core.vdsbroker.gluster"), ; String packageName; -- To view, visit http://gerrit.ovirt.org/7243 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I13c8de35ac596d89d2a9c631c4a8ef26996ea860 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Selvasundaram <sesub...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches