use of org.ovirt.engine.core.utils.lock.EngineLock in project ovirt-engine by oVirt.
the class RestoreGlusterVolumeSnapshotCommand method startGeoRepSessions.
private boolean startGeoRepSessions(List<GlusterGeoRepSession> geoRepSessions) {
for (GlusterGeoRepSession session : geoRepSessions) {
try (EngineLock lock = acquireGeoRepSessionLock(session.getId())) {
ActionReturnValue retVal = runInternalAction(ActionType.StartGlusterVolumeGeoRep, new GlusterVolumeGeoRepSessionParameters(getGlusterVolumeId(), session.getId()));
if (!retVal.getSucceeded()) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_GEO_REP_START_FAILED_EXCEPTION, retVal.getExecuteFailedMessages().toString());
setSucceeded(false);
return false;
}
}
}
return true;
}
use of org.ovirt.engine.core.utils.lock.EngineLock in project ovirt-engine by oVirt.
the class AutodefineExternalNetworkCommand method runAutodefineForOneProvider.
// Acquire lock for every provider and run auto-define inside this lock
private void runAutodefineForOneProvider(Guid providerId, int index) {
try (EngineLock lock = acquireLockForProvider(providerId)) {
Network externalNetwork = createExternalNetwork(calcExternalNetworkName(index), providerId);
AddNetworkStoragePoolParameters storagePoolParameters = new AddNetworkStoragePoolParameters(getNetwork().getStoragePoolId(), externalNetwork);
storagePoolParameters.setNetworkClusterList(networkHelper.createNetworkClusters(clustersByProvider.get(providerId)));
storagePoolParameters.setVnicProfilePublicUse(false);
runInternalAction(ActionType.AddNetworkOnProvider, storagePoolParameters);
}
}
use of org.ovirt.engine.core.utils.lock.EngineLock in project ovirt-engine by oVirt.
the class AutodefineExternalNetworkCommand method acquireLockForProvider.
protected EngineLock acquireLockForProvider(Guid providerId) {
EngineLock lock = new EngineLock(networkLocking.getNetworkProviderLock(providerId));
lockManager.acquireLockWait(lock);
return lock;
}
use of org.ovirt.engine.core.utils.lock.EngineLock in project ovirt-engine by oVirt.
the class CreateGlusterVolumeSnapshotCommand method executeCommand.
@Override
protected void executeCommand() {
GlusterVolumeEntity volume = getGlusterVolume();
// Pause geo-rep sessions and create snapshot for slave volumes
Boolean tranRetVal = TransactionSupport.executeInNewTransaction(() -> pauseAndCreateSnapshotForGeoRepSessions());
if (!tranRetVal) {
return;
}
// Create snapshot for the master volume
VDSReturnValue retVal = runVdsCommand(VDSCommandType.CreateGlusterVolumeSnapshot, new CreateGlusterVolumeSnapshotVDSParameters(upServer.getId(), volume.getName(), snapshot.getSnapshotName(), snapshot.getDescription(), force));
setSucceeded(retVal.getSucceeded());
if (!retVal.getSucceeded()) {
handleVdsError(AuditLogType.GLUSTER_VOLUME_SNAPSHOT_CREATE_FAILED, retVal.getVdsError().getMessage());
} else {
GlusterVolumeSnapshotEntity createdSnapshot = (GlusterVolumeSnapshotEntity) retVal.getReturnValue();
createdSnapshot.setClusterId(snapshot.getClusterId());
createdSnapshot.setVolumeId(snapshot.getVolumeId());
createdSnapshot.setDescription(snapshot.getDescription());
createdSnapshot.setStatus(GlusterSnapshotStatus.DEACTIVATED);
glusterVolumeSnapshotDao.save(createdSnapshot);
addCustomValue(GlusterConstants.VOLUME_SNAPSHOT_NAME, createdSnapshot.getSnapshotName());
// check if the snapshot soft limit reached now for the volume and alert
glusterUtil.alertVolumeSnapshotLimitsReached(getGlusterVolume());
}
// Resume the snapshot paused sessions by engine
for (GlusterGeoRepSession session : enginePausedSessions) {
if (session.getStatus() == GeoRepSessionStatus.PAUSED) {
try (EngineLock lock = acquireGeoRepSessionLock(session.getId())) {
ActionReturnValue sessionResumeRetVal = runInternalAction(ActionType.ResumeGeoRepSession, new GlusterVolumeGeoRepSessionParameters(volume.getId(), session.getId()));
if (!sessionResumeRetVal.getSucceeded()) {
handleVdsErrors(AuditLogType.GLUSTER_VOLUME_GEO_REP_RESUME_FAILED, sessionResumeRetVal.getExecuteFailedMessages());
setSucceeded(false);
return;
}
}
}
}
}
use of org.ovirt.engine.core.utils.lock.EngineLock in project ovirt-engine by oVirt.
the class CreateGlusterVolumeSnapshotCommand method acquireGeoRepSessionLock.
protected EngineLock acquireGeoRepSessionLock(Guid id) {
EngineLock lock = new EngineLock(Collections.singletonMap(id.toString(), LockMessagesMatchUtil.makeLockingPair(LockingGroup.GLUSTER_GEOREP, EngineMessage.ACTION_TYPE_FAILED_GEOREP_SESSION_LOCKED)), null);
lockManager.acquireLockWait(lock);
return lock;
}
Aggregations