Search in sources :

Example 1 with ModifyVolume

use of com.zimbra.cs.redolog.op.ModifyVolume in project zm-mailbox by Zimbra.

the class VolumeManager method update.

public Volume update(Volume update, boolean noRedo) throws ServiceException {
    // Don't allow changing type of a current volume. The volume must be first made non-current before its type can
    // be changed. A volume can be made non-current when another volume is made current for the volume type.
    Volume vol = getVolume(update.getId());
    if (update.getType() != vol.getType()) {
        if (isCurrent(vol)) {
            throw VolumeServiceException.CANNOT_CHANGE_TYPE_OF_CURRVOL(vol, update.getType());
        }
    }
    ModifyVolume redoRecorder = null;
    if (!noRedo) {
        redoRecorder = new ModifyVolume(update);
        redoRecorder.start(System.currentTimeMillis());
    }
    boolean success = false;
    DbConnection conn = DbPool.getConnection();
    try {
        update = DbVolume.update(conn, update);
        success = true;
        if (!noRedo) {
            redoRecorder.log();
        }
        return update;
    } finally {
        endTransaction(success, conn, redoRecorder);
        if (success) {
            synchronized (this) {
                id2volume.put(update.getId(), update);
                updateSweptDirectories();
                if (isCurrent(vol)) {
                    updateCurrentVolumeRefs(update, update.getType());
                }
            }
        }
    }
}
Also used : DeleteVolume(com.zimbra.cs.redolog.op.DeleteVolume) ModifyVolume(com.zimbra.cs.redolog.op.ModifyVolume) DbVolume(com.zimbra.cs.db.DbVolume) CreateVolume(com.zimbra.cs.redolog.op.CreateVolume) SetCurrentVolume(com.zimbra.cs.redolog.op.SetCurrentVolume) ModifyVolume(com.zimbra.cs.redolog.op.ModifyVolume) DbConnection(com.zimbra.cs.db.DbPool.DbConnection)

Aggregations

DbConnection (com.zimbra.cs.db.DbPool.DbConnection)1 DbVolume (com.zimbra.cs.db.DbVolume)1 CreateVolume (com.zimbra.cs.redolog.op.CreateVolume)1 DeleteVolume (com.zimbra.cs.redolog.op.DeleteVolume)1 ModifyVolume (com.zimbra.cs.redolog.op.ModifyVolume)1 SetCurrentVolume (com.zimbra.cs.redolog.op.SetCurrentVolume)1