Package com.cybozu.vmbkp.control

Examples of com.cybozu.vmbkp.control.VmArchiveManager


        for (String vmMoref: targetVmMorefList_) {
           
            /* Target virtual machine */
            VirtualMachineManager vmm = gm_.searchVmWithMoref(vmMoref);
            VmInfo vmInfo = vmm.getVmInfo();
            VmArchiveManager vmArcMgr =
                new VmArchiveManager(cfgGlobal_, vmInfo);

            boolean ret = false;
            try {
                int timeoutSec = 60;
                if (backupInfo.isDryRun) {timeoutSec = 0;}
               
                vmArcMgr.lock(timeoutSec);
                vmArcMgr.reload();
                ret = backupVm(vmm, vmArcMgr, backupInfo);
               
            } catch (Exception e) {
                logException
                    (e, String.format
                     ("backupVm of %s failed.", vmMoref));
            } finally {
                vmArcMgr.unlock();
            }

            System.out.printf("BACKUP %s %s\n",
                              (ret ? "OK" : "NG"), vmInfo.toString());
        }
View Full Code Here


            new RestoreInfo(cmdLine_);

        VmInfo vmInfo = profAllVm_.makeVmInfoWithMoref(targetVmMoref);
        assert vmInfo != null;

        VmArchiveManager vmArcMgr =
            new VmArchiveManager(cfgGlobal_, vmInfo);
       
        try {
            int timeoutSec = 60;
            if (restoreInfo.isDryRun) {timeoutSec = 0;}
           
            vmArcMgr.lock(timeoutSec);
            vmArcMgr.reload();
            restoreVm(vmArcMgr, restoreInfo);

        } catch (BackupFailedException e) {
            System.out.printf("The generation is marked FAILED.");
           
        } catch (Exception e) {
            logException
                (e, String.format
                 ("restoreVm of %s failed.", targetVmMoref));
        } finally {
            vmArcMgr.unlock();
        }
    }
View Full Code Here

        for (String targetVmMoref: targetVmMorefList_) {

            VmInfo vmInfo = profAllVm_.makeVmInfoWithMoref(targetVmMoref);
            assert vmInfo != null;

            VmArchiveManager vmArcMgr =
                new VmArchiveManager(cfgGlobal_, vmInfo);

            boolean isClean = false;
            try {
                int timeoutSec = 60;
                if (checkInfo.isDryRun) {timeoutSec = 0;}
           
                vmArcMgr.lock(timeoutSec);
                vmArcMgr.reload();
                isClean = checkGeneration(vmArcMgr, checkInfo);
           
            } catch (Exception e) {
                logException
                    (e, String.format
                     ("checkGeneration of %s failed.", targetVmMoref));
            } finally {
                vmArcMgr.unlock();
            }

            System.out.printf("CHECK %s %s: %d\n",
                              (isClean ? "OK" : "NG"),
                              vmInfo.toString(),
View Full Code Here

                    logException(e, msg);
                    System.err.println(msg);
                }
            } else {

                VmArchiveManager vmArcMgr =
                    new VmArchiveManager(cfgGlobal_, vmInfo);
                try {
                    int timeoutSec = 1;
                    if (cleanInfo.isDryRun) { timeoutSec = 0; }

                    vmArcMgr.lock(timeoutSec);
                    vmArcMgr.reload();
                    deleteFailedGenerations(vmArcMgr, cleanInfo);
                    isSucceeded = true;

                } catch(Exception e) {
                    String msg = String.format
                        ("Clean %s failed.", targetVmMoref);
                    logException(e, msg);
                    System.err.println(msg);
                } finally {
                    vmArcMgr.unlock();
                }
            }
            System.out.printf("CLEAN %s %s.\n",
                              vmInfo.toString(),
                              (isSucceeded ? "succeeded" : "failed"));
View Full Code Here

            tlist = new LinkedList<String>();
           
            for (String moref: morefs) {
                VmInfo vmInfo = profAllVm_.makeVmInfoWithMoref(moref);
                if (VmArchiveManager.isExistSucceededGeneration(cfgGlobal_, vmInfo)) {
                    VmArchiveManager vmArcMgr =
                        new VmArchiveManager(cfgGlobal_, vmInfo);

                    long tsGen = vmArcMgr.getTimestampMsOfLatestGeneration();
                    long tsNow = Calendar.getInstance().getTimeInMillis();
                   
                    if (listInfo.isSatisfyTime(tsGen, tsNow)) {
                        tlist.add(moref);
                    }
View Full Code Here

                                  vmInfo.getMoref(), vmInfo.getName());
                continue;
            }

            /* Try to load archive metadata. */
            VmArchiveManager vmArcMgr;
            try {
                vmArcMgr = new VmArchiveManager(cfgGlobal_, vmInfo);
            } catch (Exception e) {
                logException(e);
                System.out.printf("[%s][%s] ##########_ERROR_##########\n",
                                  vmInfo.getMoref(), vmInfo.getName());
                continue;
            }

            /* Get status information from the metadata. */
            try {
                vmArcMgr.lock(0);
                vmArcMgr.reload();

                boolean isAvailable = profAllVm_.isAvailableWithMoref(vmMoref);
                System.out.println
                    (vmArcMgr.getStatusString(statusInfo, isAvailable));
               
            } catch (LockTimeoutException e) {
                logException(e, "lock timeout" + vmInfo.toString());
                System.out.printf("[%s][%s] ##########_LOCKED_##########\n",
                                  vmInfo.getMoref(), vmInfo.getName());
            } catch (Exception e) {
                logException
                    (e, String.format
                     ("Reload profile of %s failed.", vmInfo.toString()));
            } finally {
                vmArcMgr.unlock();
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.cybozu.vmbkp.control.VmArchiveManager

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.