Package com.cybozu.vmbkp.profile

Examples of com.cybozu.vmbkp.profile.ProfileGeneration


     * @return change id in success, or null in failure.
     */
    public String getPrevChangeId(int diskId)
    {
        /* get previous generation and check. */
        ProfileGeneration prevGen = getPrevGeneration();
        if (prevGen == null) { return null; }

        int prevDiskId = getPrevDiskId(diskId);
        if (prevDiskId < 0) { return null; }
       
        /* check that changed block information is available */
        String prevChangeId = prevGen.getChangeId(prevDiskId);

        if (prevChangeId != null && prevChangeId.equals("*") == false) {
            return prevChangeId;
        } else {
            return null;
View Full Code Here


     * Get previous dump path
     * using diskId of the current generation.
     */
    public String getPrevDumpPath(int diskId)
    {
        ProfileGeneration prevGen = getPrevGeneration();
        if (prevGen == null) { return null; }
        int prevDiskId = getPrevDiskId(diskId);
        if (prevDiskId < 0) { return null; }

        return prevGen.getDumpOutPath(prevDiskId);
    }
View Full Code Here

     * Get previous digest path
     * using diskId of the current generation.
     */
    public String getPrevDigestPath(int diskId)
    {
        ProfileGeneration prevGen = getPrevGeneration();
        if (prevGen == null) { return null; }
        int prevDiskId = getPrevDiskId(diskId);
        if (prevDiskId < 0) { return null; }

        return prevGen.getDigestOutPath(prevDiskId);
    }
View Full Code Here

        int diskId = currGen_.getDiskIdWithUuid(uuid);
        logger_.info("diskId: " + diskId); /* debug */
        if (diskId < 0) { return false; };

        /* Check the previous dump succeeded */
        ProfileGeneration prevGen = this.getPrevGeneration();
        if (prevGen == null) {
            logger_.warning("prevGen is null.");
            return false;
        }
        int prevDiskId = prevGen.getDiskIdWithUuid(uuid);
        if (prevDiskId < 0) {
            logger_.warning("prevDiskId < 0");
            return false;
        }
        if (prevGen.isVmdkdumpSucceeded(prevDiskId) == false) {
            logger_.warning("vmdkbkp did not succeed.");
            return false;
        }
       
        /* Capacity check. */
        long capacity = currGen_.getCapacity(diskId);
        long prevCapacity = prevGen.getCapacity(prevDiskId);
        if (capacity < 0 || capacity != prevCapacity) {
            logger_.info("capacity is invalid or different.");
            return false;
        }
       
        /* Check full dump file exists in previous generation. */
        if (prevGen.isDumpOutExist(prevDiskId) == false ||
            prevGen.isDigestOutExist(prevDiskId) == false) {
            logger_.info("dump or digest does not exist.");
            return false;
        }

        return true;
View Full Code Here

        int diskId = currGen_.getDiskIdWithUuid(uuid);
        if (diskId < 0) {
            logger_.warning("diskId < 0");
            return false;
        };
        ProfileGeneration prevGen = this.getPrevGeneration();
        if (prevGen == null) {
            logger_.warning("prevGen is null.");
            return false;
        }
        int prevDiskId = prevGen.getDiskIdWithUuid(uuid);
        if (prevDiskId < 0) {
            logger_.warning("prevDiskId < 0");
            return false;
        }
       
        /* Check that changed block information of both
           previous and current generation is available */
        String currChangeId = currGen_.getChangeId(diskId);
        if (currChangeId == null || currChangeId.equals("*")) {
            logger_.info("currChangeId is null or \"*\"");
            return false;
        }
        String prevChangeId = prevGen.getChangeId(prevDiskId);
        logger_.info("prevChangeId: " + prevChangeId);
        if (prevChangeId == null || prevChangeId.equals("*")) {
            logger_.info("prevChangeId is null or \"*\"");
            return false;
        }
View Full Code Here

     *         Return null in failure.
     */
    public List<String> getDumpPathListForRestore(int diskId)
    {
        assert currGen_ != null;
        ProfileGeneration currGen = currGen_;
       
        logger_.info
            (String.format
             ("------------------------------------------------------\n" +
              "getDumpPathListForRestore start for diskID %d.\n" +
              "------------------------------------------------------\n",
              diskId));
       
        /* Initialize */
        LinkedList<String> ret = new LinkedList<String>();
        String uuid = currGen.getUuid(diskId);

        /* Check the generation backup succeeded. */
        if (currGen.isVmdkdumpSucceeded(diskId) == false) {
            logger_.warning
                (String.format
                 ("Skipping: " +
                  "generation %d disk %d (%s) is marked FAILED.\n",
                  currGen.getGenerationId(), diskId, currGen.getUuid(diskId)));
            return null;
        }

        /* Does this generation have the full dump */
        String dumpPath;
        dumpPath = currGen.getDumpOutPath(diskId);
        logger_.info(String.format("dumpPath: %s\n", dumpPath));
        if (currGen.isDumpOutExist(diskId)) {
            ret.add(dumpPath);
            return ret;
        }

        /* There is no dump of the current generation,
           so search corresponding dump in newer generations. */
        assert ret.isEmpty();
        String rdiffPath;

        boolean isFirstElementDump = false;
        ProfileGeneration next = this.getNextGeneration();
        while (next != null) {

            /* Get nextDiskId */
            int nextDiskId = next.getDiskIdWithUuid(uuid);
            if (nextDiskId < 0) {
                logger_.warning("diskId is invalid."); /* debug */
                return null;
            }

            /* Check the vmdk backup succeeded. */
            if (next.isVmdkdumpSucceeded(nextDiskId) == false) {
                logger_.warning
                    (String.format
                     ("backup of vmdk with diskId %d is failed.",
                      nextDiskId));
                return null;
            }
           
            dumpPath = next.getDumpOutPath(nextDiskId);
            rdiffPath = next.getRdiffOutPath(nextDiskId);

            logger_.info
                (String.format
                 ("dumpPath: %s\n" + "rdiffPath: %s\n",
                  dumpPath, rdiffPath));

            boolean notFoundFile = true;
            if (next.isRdiffOutExist(nextDiskId)) {
                /* Rdiff file is found. */
                ret.addFirst(FormatString.toQuatedString(rdiffPath));
                notFoundFile = false;
            }
            if (next.isDumpOutExist(nextDiskId)) {
                /* Dump file is found. */
                ret.addFirst(FormatString.toQuatedString(dumpPath));
                isFirstElementDump = true;
                break;
            }
            if (next.isChanged(nextDiskId) == false) {
                /* The vmdk is not changed at all in This generation.
                   This generation may have none of dump, digest, and rdiff.
                   Just skip. */
                notFoundFile = false;
            }
            if (notFoundFile) {
                /* Error. */
                logger_.warning
                    (String.format
                     ("Error: neither dump nor rdiff is available in " +
                      " generation %d\n", next.getGenerationId()));
                return null;
            }
               
            next = this.getNextGeneration(next.getGenerationId());
        }
           
        if (isFirstElementDump == false) {
            logger_.warning
                (String.format("isFirstElementDump is false."));
View Full Code Here

     * @return Full path of the target digest file.
     */
    public String getDigestPathForCheck(int diskId)
    {
        assert currGen_ != null;
        ProfileGeneration currGen = currGen_;

        String uuid = currGen.getUuid(diskId);

        /* There is no digest file in the current generation.
           Search newer generations. */
        boolean isFound = false;
        ProfileGeneration next = currGen;
        while (next != null) {

            int nextDiskId = next.getDiskIdWithUuid(uuid);
            if (nextDiskId < 0) {
                logger_.warning("diskId is invalid.");
                return null;
            }

            if (next.isVmdkdumpSucceeded(nextDiskId) == false) {
                logger_.warning
                    (String.format
                     ("Geneartion %d disk %d (%s) is marked FAILED.\n",
                      next.getGenerationId(), nextDiskId, uuid));
                return null;
            }

            String digestPath;
            digestPath = next.getDigestOutPath(nextDiskId);
            if (next.isDigestOutExist(nextDiskId)) {
                logger_.info(String.format("digestPath: %s\n", digestPath));
                return digestPath;
            }

            next = this.getNextGeneration(next.getGenerationId());
        }

        /* not found */
        logger_.warning
            (String.format
View Full Code Here

    /**
     * Delete dump file of previous succeeded generation.
     */
    public boolean deletePrevDump(int diskId)
    {
        ProfileGeneration prevGen = this.getPrevGeneration();
        if (prevGen == null) {
            logger_.warning("prevGen is null.");
            return false;
        }
        String prevDumpPath = this.getPrevDumpPath(diskId);
View Full Code Here

        generateVirtualControllerManagerList(String datastoreName)
    {
        assert datastoreName != null;
        assert currGen_ != null;
       
        ProfileGeneration profGen = currGen_;
       
        /* Set to make sorted and deduplicated list later. */
        TreeSet<VirtualControllerManager> vcmSet =
            new TreeSet<VirtualControllerManager>();

        List<Integer> diskIdList = profGen.getDiskIdList();
        for (Integer diskIdI : diskIdList) {

            int diskId = diskIdI.intValue();
            assert diskId >= 0;

            /* Skip independent disk. */
            if (profGen.isIndependentDisk(diskId)) { continue; }
           
            /* Get required parameters */
            int key = profGen.getDiskDeviceKey(diskId);
            int unitNumber = profGen.getUnitNumber(diskId);
            long capacity = profGen.getCapacity(diskId);
            assert capacity % 1024L == 0;
            long capacityInKb = capacity / 1024L;

            AdapterType type = profGen.getAdapterType(diskId);
            assert type != AdapterType.UNKNOWN;
            int ckey = profGen.getControllerDeviceKey(diskId);
            int busNumber = profGen.getBusNumber(ckey);

            /* Create virtual disk manager and virtual controller manager. */
            VirtualDiskManager vdm = new VirtualDiskManager
                (key, unitNumber, capacityInKb, datastoreName);
            VirtualControllerManager vcm =
View Full Code Here

     * Get target disk id of the corresponding vmdk with the given vmdkInfo.
     */
    public int getTargetDiskId(VmdkInfo vmdkInfo)
    {
        assert currGen_ != null;
        ProfileGeneration profGen = currGen_;
       
        List<Integer> diskIdList = profGen.getDiskIdList();
        for (Integer diskIdI : diskIdList) {
            int diskId = diskIdI.intValue();

            /* Comparing key is enough, however,
               The following parameters should be the same. */
            int ckey = profGen.getControllerDeviceKey(diskId);
            if (vmdkInfo.key_ == profGen.getDiskDeviceKey(diskId) &&
                vmdkInfo.capacityInKB_ * 1024L == profGen.getCapacity(diskId) &&
                vmdkInfo.unitNumber_ == profGen.getUnitNumber(diskId) &&
                vmdkInfo.ckey_ == ckey &&
                vmdkInfo.busNumber_ == profGen.getBusNumber(ckey) &&
                vmdkInfo.type_ == profGen.getAdapterType(diskId)) {

                return diskId;
            }
        }
       
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.