diff --git a/src/com/platform/service/impl/VolumeServiceImpl.java b/src/com/platform/service/impl/VolumeServiceImpl.java index 483ace6d..1ae8288e 100644 --- a/src/com/platform/service/impl/VolumeServiceImpl.java +++ b/src/com/platform/service/impl/VolumeServiceImpl.java @@ -41,10 +41,10 @@ public class VolumeServiceImpl implements IVolumeService { int rest = 1; //createVolume("lili_test1", 0, "distributed", bricksToCreate, "/home/lili_test1_point") List vols = volumeDao.findAll(); - Map volMap = new HashMap(); + Map volMap = new HashMap(); if (null!= vols) { for (VolumeInitEntity volumeInitEntity : vols) { - volMap.put(volumeInitEntity.getPath(), null); + volMap.put(volumeInitEntity.getPath(), volumeInitEntity); } } List result = gfsService.getAllVolumes(); @@ -67,6 +67,19 @@ public class VolumeServiceImpl implements IVolumeService { } } + //记录volume信息, + VolumeInitEntity volInSql = new VolumeInitEntity(); + volInSql.setName(entity.getName()); + volInSql.setPath(entity.getPath()); + volInSql.setMark(entity.getHot()); + if (volMap.keySet().contains(volInSql.getPath())) { + VolumeInitEntity tmp = volMap.get(volInSql.getPath()); + volInSql.setId(tmp.getId()); + volumeDao.update(volInSql); + } + else { + volumeDao.save(volInSql); + } boolean isContinue = true; // 对比volume信息--原数据没有该volume,则新增volume: for (VolumeDataEntity add : addVolumes) { @@ -95,13 +108,7 @@ public class VolumeServiceImpl implements IVolumeService { rest = createreslt; } } - //记录volume信息, - VolumeInitEntity volInSql = new VolumeInitEntity(); - volInSql.setName(add.getName()); - volInSql.setPath(add.getPath()); - if (!volMap.keySet().contains(volInSql.getPath())) { - volumeDao.save(volInSql); - } + isContinue = false; } // 修改 brick