Kanagaraj M has posted comments on this change.

Change subject: gluster: Sync job for gluster volume snapshots
......................................................................


Patch Set 6:

(6 comments)

http://gerrit.ovirt.org/#/c/35904/6/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJob.java
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSnapshotSyncJob.java:

Line 71:         if (!supportsGlusterSnapshotFeature(cluster)) {
Line 72:             return;
Line 73:         }
Line 74: 
Line 75:         final VDS upServer = 
getClusterUtils().getRandomUpServer(cluster.getId());
It could be null if there are no up servers
Line 76:         List<GlusterVolumeEntity> volumes = 
getGlusterVolumeDao().getByClusterId(cluster.getId());
Line 77: 
Line 78:         if (volumes != null && volumes.size() > 0) {
Line 79:             List<Callable<Pair<GlusterVolumeEntity, VDSReturnValue>>> 
taskList =


Line 146:                 for (final GlusterVolumeSnapshotEntity 
fetchedSnapshot : fetchedSnapshots) {
Line 147:                     GlusterVolumeSnapshotEntity existingSnapshot = 
existingSnapshotsMap.get(fetchedSnapshot.getId());
Line 148: 
Line 149:                     if (existingSnapshot != null) {
Line 150:                         
existingSnapshot.setStatus(fetchedSnapshot.getStatus());
You can check for status change then update in db if required
Line 151:                         updatedSnapshots.add(existingSnapshot);
Line 152:                     } else {
Line 153:                         newlyAddedSnapshots.add(fetchedSnapshot);
Line 154:                     }


Line 175:     }
Line 176: 
Line 177:     private void addOrUpdateSnapshotsConfig(Guid clusterId, 
GlusterSnapshotConfigInfo configInfo) {
Line 178:         try (EngineLock lock = acquireEntityLock(clusterId)) {
Line 179:             for (String key : 
configInfo.getClusterConfigOptions().keySet()) {
You could use Map.Entry
Line 180:                 String value = 
configInfo.getClusterConfigOptions().get(key);
Line 181:                 if (value != null) {
Line 182:                     addOrUpdateClusterConfig(clusterId, key, value);
Line 183:                 }


Line 185:         }
Line 186: 
Line 187:         Map<String, Map<String, String>> volumeConfigs = 
configInfo.getVolumeConfigOptions();
Line 188:         for (String key : volumeConfigs.keySet()) {
Line 189:             GlusterVolumeEntity volume = 
getGlusterVolumeDao().getByName(clusterId, key);
This might return null if the volume is not present in db
Line 190:             try (EngineLock lock = acquireEntityLock(volume.getId())) 
{
Line 191:                 Map<String, String> volumeConfig = 
volumeConfigs.get(key);
Line 192:                 if (volumeConfig != null) {
Line 193:                     for (String configKey : volumeConfig.keySet()) {


Line 214:             getGlusterVolumeSnapshotConfigDao().save(param);
Line 215:         } else {
Line 216:             
getGlusterVolumeSnapshotConfigDao().updateConfigByClusterIdAndName(clusterId,
Line 217:                     paramName,
Line 218:                     paramValue);
You can update only if the value has changed
Line 219:         }
Line 220:     }
Line 221: 
Line 222:     private void addOrUpdateVolumeConfig(Guid clusterId, Guid 
volumeId, String paramName, String paramValue) {


Line 234:         } else {
Line 235:             
getGlusterVolumeSnapshotConfigDao().updateConfigByVolumeIdIdAndName(clusterId,
Line 236:                     volumeId,
Line 237:                     paramName,
Line 238:                     paramValue);
same here
Line 239:         }
Line 240:     }
Line 241: 
Line 242:     private void saveNewSnapshots(List<GlusterVolumeSnapshotEntity> 
snaphosts) {


-- 
To view, visit http://gerrit.ovirt.org/35904
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I7b7bf79b72fc5680dab301b290e7aa860d5c714d
Gerrit-PatchSet: 6
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Shubhendu Tripathi <shtri...@redhat.com>
Gerrit-Reviewer: Kanagaraj M <kmayi...@redhat.com>
Gerrit-Reviewer: Ramesh N <rnach...@redhat.com>
Gerrit-Reviewer: Sahina Bose <sab...@redhat.com>
Gerrit-Reviewer: Shubhendu Tripathi <shtri...@redhat.com>
Gerrit-Reviewer: Yair Zaslavsky <yzasl...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to