Package com.cybozu.vmbkp.profile

Examples of com.cybozu.vmbkp.profile.ProfileGeneration


        System.out.println(msg); logger_.info(msg);
        for (VmdkInfo vmdkInfo : vmdkInfoList) {
            logger_.info(vmdkInfo.toString());
        }
        /* Prepare generation profile. */
        ProfileGeneration profGen =
            vmArcMgr.prepareNewGeneration
            (snap.getVmInfo(), snap.getSnapInfo(), vmdkInfoList, cal,
             backupInfo.isGzip);
        vmArcMgr.setTargetGeneration(profGen);

        /*
         * Export ovf and delete disk information from the ovf.
         */
        String ovfFilePath = profGen.getOvfPath();
        if (ovfFilePath == null) {
            throw new Exception("ovfFilePath is null");
        }
        ret = exportOvfAndSave(vmm, ovfFilePath);
        if (ret == false) {
            throw new Exception
                (String.format("ovf export failed (%s).", ovfFilePath));
        }

        /*
         * Dump each vmdk file.
         */
        boolean isAllVmdkDumpSucceeded = true;
        for (VmdkInfo vmdkInfo : vmdkInfoList) {

            int diskId = profGen.getDiskIdWithUuid(vmdkInfo.uuid_);
           
            if (backupInfo.isNoVmdk) {
                profGen.setVmdkdumpResult(diskId, true);
            } else {
                if (profGen.isIndependentDisk(diskId)) {
                    msg = String.format
                        ("Dump vmdk %s skipped (independent disk)",
                         vmdkInfo.uuid_);
                    System.out.println(msg); logger_.info(msg);
                    ret = true;
View Full Code Here


         VmdkInfo vmdkInfo,
         boolean isSan)
    {
        boolean ret = false;

        ProfileGeneration profGen = vmArcMgr.getTargetGeneration();

        int diskId = profGen.getDiskIdWithUuid(vmdkInfo.uuid_);

        /* Check available backup mode. */
        boolean isDiff = vmArcMgr.canExecDiffBackup(vmdkInfo.uuid_);
        boolean isInc =  vmArcMgr.canExecIncrBackup(vmdkInfo.uuid_);

        profGen.setIsChanged(diskId, true);

        /* Get changed block info and save if required. */
        if (isInc) {
            /* profGen.setIsChange(diskId, false)
               may be called inside it. */
            isInc = getAndSaveChangedBlocksOfDisk
                (snap, vmArcMgr, vmdkInfo, diskId);
        }
               
        /* Dump archives with vmdkbkp tool. */
        BackupMode mode = BackupMode.FULL;
        if (isInc)       { mode = BackupMode.INCR; }
        else if (isDiff) { mode = BackupMode.DIFF; }
        else             { mode = BackupMode.FULL; }
        profGen.setBackupMode(diskId, mode);
           
        logger_.info("isInc: " + isInc +
                     " isDiff: " + isDiff +
                     " mode: " + mode.toString()); /* debug */

        profGen.setDumpBeginTimestamp(diskId);
        if (mode == BackupMode.INCR &&
            profGen.isChanged(diskId) == false) {
           
            logger_.info("The vmdk is not changed at all.");
            vmArcMgr.registerLazyTaskMovePrevDumpAndDigest(diskId);
            ret = true;
        } else {
            /* Soap connection is not required during running vmdkbkp.
               It may take a long time and soap timeout will occur,
               therefore we disconnect and re-connect
               after vmdkbkp has done.
               VirtualMachineManger and SnapshotManager must be reload. */
            gm_.disconnect();
           
            ret = VmdkBkp.doDump
                (mode, vmm.getMoref(), vmArcMgr, diskId, isSan);
        }
        profGen.setDumpEndTimestamp(diskId);
           
        profGen.setVmdkdumpResult(diskId, ret);
           
        if (profGen.isVmdkdumpSucceeded(diskId) &&
            (mode == BackupMode.DIFF ||
             (mode == BackupMode.INCR && profGen.isChanged(diskId)))) {
                   
            vmArcMgr.registerLazyTaskDelPrevDump(diskId);
        }

        return ret;
View Full Code Here

        assert prevChangeId != null && (prevChangeId.equals("*") == false);
       
        VmdkBitmap bmp = snap.getChangedBlocksOfDisk(vmdkInfo, prevChangeId);
        if (bmp == null) { return false; }

        ProfileGeneration profGen = vmArcMgr.getTargetGeneration();

        try {
            /* Save the changed bitmap file */
            FilterOutputStream fos =
                new FilterOutputStream
                (new FileOutputStream
                 (profGen.getBmpInPath(diskId)));
            bmp.writeTo(fos);
            fos.close();

            /* Check whether the bitmap is all zero or not.
               (All zero means the vmdk does not change at all.) */
            profGen.setIsChanged(diskId, bmp.isAllZero() == false);
           
        } catch (Exception e) {
            logger_.warning(Utility.toString(e));
            return false;
        }
View Full Code Here

        msg = restoreInfo.toString();
        System.out.println(msg); logger_.info(msg);
       
        /* 2. Decide generation and load ProfileGeneration data. */
        ProfileGeneration profGen =
            vmArcMgr.loadProfileGeneration(genId);
        if (profGen == null) {
            throw new Exception
                ("ProfileGeneration is null.");
        }
        if (profGen.isSucceeded() == false) {
            throw new Exception
                ("The specified generation is marked FAILED.");
        }
        assert profGen != null;
        vmArcMgr.setTargetGeneration(profGen);
       
        /* 3. Decide the name of the new virtual machine */
        if (newVmName == null) {
            newVmName = vmArcMgr.getName();
            logger_.info
                (String.format
                 ("Use default name for new VM: %s.", newVmName));
        }
        if (newVmName == null) {
            throw new Exception("Could not decide the name of new VM.");
        }

        /* 4. Generate controller-disk mapping data
              from the ProfileGeneration
              as a List<VirtualControllerManager> */
        List<VirtualControllerManager> vcmList =
            vmArcMgr.generateVirtualControllerManagerList(datastoreName);
        logger_.info
            (vmArcMgr.toStringVirtualControllerManagerList(vcmList));

        /* Finish if --dryrun option is specified. */
        if (restoreInfo.isDryRun) {
            msg = "Restore ends cause dryrun.";
            System.out.println(msg); logger_.info(msg);
            return;
        }
       
        /* 5. Import ovf without disks. */
        String ovfPath = profGen.getOvfPath();
        if (ovfPath == null) {
            throw new Exception
                (String.format("ovfPath %s is null.", ovfPath));
        }
        assert (ovfPath != null && newVmName != null);
View Full Code Here

        msg = checkInfo.toString();
        System.out.println(msg); logger_.info(msg);
       
        /* 3. Decide generation and load ProfileGeneration data. */
        ProfileGeneration profGen = null;
        try {
            profGen = vmArcMgr.loadProfileGeneration(genId);
        } catch (BackupFailedException e) {
            System.out.printf("Generation %d is marked FAILED.\n", genId);
            return false;
        }
        if (profGen == null) {
            throw new Exception
                ("ProfileGeneration is null.");
        }
        if (profGen.isSucceeded() == false) {
            throw new Exception
                ("The specified generation is marked FAILED.");
        }
        assert profGen != null;
        vmArcMgr.setTargetGeneration(profGen);

        /* Check vmdk archives. */
        List<Integer> diskIdList = profGen.getDiskIdList();

        boolean ret = true;
        for (Integer diskIdI: diskIdList) {
            if (diskIdI == null) {
                logger_.warning("diskIdList contains null.");
                continue;
            }
            int diskId = diskIdI.intValue();
            if (profGen.isVmdkdumpSucceeded(diskId) == false) {
                System.out.printf
                    ("Dump of disk %d is marked FAILED.\n", diskId);
                ret &= false;
                continue;
            }
View Full Code Here

        /*
         * Make new ProfileGeneration and initialize it.
         */
        String profGenFn = genDir + "/" + ProfileGeneration.FILE_NAME;
        ProfileGeneration profGen = new ProfileGeneration();
        profGen.initializeGeneration
            (newGenId, currGenId,
             vmInfo, snapInfo,
             vmdkInfoList, calendar, isGzip);
        profGen.write(profGenFn);

        return profGen;
    }
View Full Code Here

            throw new BackupFailedException();
        }
        String path = profVm.getDefaultProfileGenerationPath(genId);
        if (path == null) { return null; }

        return new ProfileGeneration(path);
    }
View Full Code Here

        int prevGenId = profVm_.getPrevSucceededGenerationId(genId);
        logger_.fine("prevGenId: " + prevGenId); /* debug */
        if (prevGenId < 0) { return null; }
        assert profVm_.isGenerationSucceeded(prevGenId);

        ProfileGeneration ret = null;
        try {
            ret = loadProfileGeneration(prevGenId);
        } catch (Exception e) {
            logger_.warning(Utility.toString(e));
        }
View Full Code Here

        int nextGenId = profVm_.getNextSucceededGenerationId(genId);
        logger_.fine("nextGenId: " + nextGenId); /* debug */
        if (nextGenId < 0) { return null; }
        assert profVm_.isGenerationSucceeded(nextGenId);

        ProfileGeneration ret = null;
        try {
            ret = loadProfileGeneration(nextGenId);
        } catch (Exception e) {
            logger_.warning(Utility.toString(e));
        }
View Full Code Here

     * @return >=0 in success, or -1 in failure.
     */
    public int getPrevDiskId(int diskId)
    {
        ProfileVm profVm = profVm_;
        ProfileGeneration currGen = currGen_;
       
        String uuid = currGen.getUuid(diskId);

        /* get previous generation and check. */
        ProfileGeneration prevGen = getPrevGeneration();
        if (prevGen == null) { return -1; }

        /* search and check disk id. */
        int prevDiskId = prevGen.getDiskIdWithUuid(uuid);
        if (prevDiskId < 0) { return -1; }

        return prevDiskId;
    }
View Full Code Here

TOP

Related Classes of com.cybozu.vmbkp.profile.ProfileGeneration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.