@Transactional
  private void updateCapacity(long total, long avail) {
    PrimaryStorageCapacityVO cvo =
        dbf.getEntityManager()
            .find(PrimaryStorageCapacityVO.class, self.getUuid(), LockModeType.PESSIMISTIC_WRITE);
    DebugUtils.Assert(
        cvo != null,
        String.format("how can there is no PrimaryStorageCapacityVO[uuid:%s]", self.getUuid()));

    cvo.setTotalPhysicalCapacity(total);
    cvo.setAvailablePhysicalCapacity(avail);
    dbf.getEntityManager().merge(cvo);
  }
 @Transactional
 private void handle(TakePrimaryStorageCapacityMsg msg) {
   PrimaryStorageCapacityVO vo =
       dbf.getEntityManager()
           .find(PrimaryStorageCapacityVO.class, self.getUuid(), LockModeType.PESSIMISTIC_WRITE);
   vo.setAvailableCapacity(vo.getAvailableCapacity() - msg.getSize());
   if (vo.getAvailableCapacity() < 0) {
     vo.setAvailableCapacity(0);
   }
   dbf.getEntityManager().merge(vo);
   TakePrimaryStorageCapacityReply reply = new TakePrimaryStorageCapacityReply();
   bus.reply(msg, reply);
 }
  @Transactional
  private void handle(PrimaryStorageReportCapacityMsg msg) {
    PrimaryStorageCapacityVO vo =
        dbf.getEntityManager()
            .find(PrimaryStorageCapacityVO.class, self.getUuid(), LockModeType.PESSIMISTIC_WRITE);
    if (vo.getTotalCapacity() == 0) {
      vo.setTotalCapacity(msg.getTotalCapacity());
      vo.setAvailableCapacity(msg.getAvailableCapacity());
      dbf.getEntityManager().merge(vo);
    }

    PrimaryStorageReportCapacityReply reply = new PrimaryStorageReportCapacityReply();
    bus.reply(msg, reply);
  }