Examples of ObjectInDataStoreVO


Examples of org.apache.cloudstack.storage.db.ObjectInDataStoreVO

    @Override
    public String getUri() {
        if (this.dataStore == null) {
            throw new CloudRuntimeException("datastore must be set before using this object");
        }
        ObjectInDataStoreVO obj = objectInStoreMgr.findObject(this.volumeVO.getId(), DataObjectType.VOLUME, this.dataStore.getId(), this.dataStore.getRole());
        if (obj.getState() != ObjectInDataStoreStateMachine.State.Ready) {
            return this.dataStore.getUri() +
                    "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME +
                    "&" + EncodingType.SIZE + "=" + this.volumeVO.getSize() +
                    "&" + EncodingType.NAME + "=" + this.volumeVO.getName();
        } else {
            return this.dataStore.getUri() +
                    "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME +
                    "&" + EncodingType.PATH + "=" + obj.getInstallPath();
        }
    }
View Full Code Here

Examples of org.apache.cloudstack.storage.db.ObjectInDataStoreVO

                this.getId(), this.getRole()) != null) ? true : false;
    }

    @Override
    public TemplateInfo getTemplate(long templateId) {
        ObjectInDataStoreVO obj = objectInStoreMgr.findObject(templateId, DataObjectType.TEMPLATE, this.getId(), this.getRole());
        if (obj == null) {
            return null;
        }
        return imageDataFactory.getTemplate(templateId, this);
    }
View Full Code Here

Examples of org.apache.cloudstack.storage.db.ObjectInDataStoreVO

    protected long waitingRetries = 10;

    protected TemplateInfo waitingForTemplateDownload(TemplateInfo template,
            PrimaryDataStore dataStore) {
        long retries = this.waitingRetries;
        ObjectInDataStoreVO obj = null;
        do {
            try {
                Thread.sleep(waitingTime);
            } catch (InterruptedException e) {
                s_logger.debug("sleep interrupted", e);
                throw new CloudRuntimeException("sleep interrupted", e);
            }

            obj = objectInDataStoreMgr.findObject(template.getId(),
                    template.getType(), dataStore.getId(), dataStore.getRole());
            if (obj == null) {
                s_logger.debug("can't find object in db, maybe it's cleaned up already, exit waiting");
                break;
            }
            if (obj.getState() == ObjectInDataStoreStateMachine.State.Ready) {
                break;
            }
            retries--;
        } while (retries > 0);
View Full Code Here

Examples of org.apache.cloudstack.storage.db.ObjectInDataStoreVO

    }

    @Override
    public Void installAsync(TemplateInfo template, PrimaryDataStore store,
            AsyncCompletionCallback<CreateBaseImageResult> callback) {
        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
                template.getId(), template.getType(), store.getId(),
                store.getRole());
        TemplateInfo templateOnPrimaryStoreObj = null;
        boolean freshNewTemplate = false;
        if (obj == null) {
            try {
                /*templateOnPrimaryStoreObj = objectInDataStoreMgr.create(
                        template, store);*/
                freshNewTemplate = true;
            } catch (Throwable e) {
                obj = objectInDataStoreMgr.findObject(template.getId(),
                        template.getType(), store.getId(), store.getRole());
                if (obj == null) {
                    CreateBaseImageResult result = new CreateBaseImageResult(
                            null);
                    result.setSucess(false);
                    result.setResult(e.toString());
                    callback.complete(result);
                    return null;
                }
            }
        }

        if (!freshNewTemplate
                && obj.getState() != ObjectInDataStoreStateMachine.State.Ready) {
            try {
                templateOnPrimaryStoreObj = waitingForTemplateDownload(
                        template, store);
            } catch (Exception e) {
                CreateBaseImageResult result = new CreateBaseImageResult(null);
View Full Code Here

Examples of org.apache.cloudstack.storage.db.ObjectInDataStoreVO

            upResult.setResult(result.getResult());
            context.getParentCallback().complete(upResult);
            return null;
        }

        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
                templateOnPrimaryStoreObj.getId(), templateOnPrimaryStoreObj
                        .getType(), templateOnPrimaryStoreObj.getDataStore()
                        .getId(), templateOnPrimaryStoreObj.getDataStore()
                        .getRole());

        obj.setInstallPath(result.getPath());
        obj.setSize(result.getSize());
        try {
            objectInDataStoreMgr.update(obj,
                    ObjectInDataStoreStateMachine.Event.OperationSuccessed);
        } catch (NoTransitionException e) {
            try {
View Full Code Here

Examples of org.apache.cloudstack.storage.db.ObjectInDataStoreVO

            CreateBaseImageResult res = new CreateBaseImageResult(
                    templateOnPrimaryStoreObj);
            res.setResult(result.getResult());
            context.getParentCallback().complete(res);
        }
        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
                templateOnPrimaryStoreObj.getId(), templateOnPrimaryStoreObj
                        .getType(), templateOnPrimaryStoreObj.getDataStore()
                        .getId(), templateOnPrimaryStoreObj.getDataStore()
                        .getRole());

        obj.setInstallPath(result.getPath());
        CreateBaseImageResult res = new CreateBaseImageResult(
                templateOnPrimaryStoreObj);
        try {
            objectInDataStoreMgr.update(obj,
                    ObjectInDataStoreStateMachine.Event.OperationSuccessed);
View Full Code Here

Examples of org.apache.cloudstack.storage.db.ObjectInDataStoreVO

    @Inject
    DataStoreManager storeMgr;
    @Override
    public VolumeInfo getVolume(long volumeId, DataStore store) {
        VolumeVO volumeVO = volumeDao.findById(volumeId);
        ObjectInDataStoreVO obj = objMap.findObject(volumeId, DataObjectType.VOLUME, store.getId(), store.getRole());
        if (obj == null) {
            VolumeObject vol = VolumeObject.getVolumeObject(null, volumeVO);
            return vol;
        }
        VolumeObject vol = VolumeObject.getVolumeObject(store, volumeVO);
View Full Code Here

Examples of org.apache.cloudstack.storage.db.ObjectInDataStoreVO

            result.setResult(e.toString());
            future.complete(result);
            return future;
        }
       
        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(template.getId(), template.getType(), store.getId(), store.getRole());
        TemplateInfo templateOnStore = null;
        if (obj == null) {
            templateOnStore = (TemplateInfo)objectInDataStoreMgr.create(template, store);
            obj = objectInDataStoreMgr.findObject(template.getId(), template.getType(), store.getId(), store.getRole());
        } else {
View Full Code Here

Examples of org.apache.cloudstack.storage.db.ObjectInDataStoreVO

            }
            result.setResult(callbackResult.getResult());
            future.complete(result);
            return null;
        }
        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(templateOnStore.getId(), templateOnStore.getType(), templateOnStore.getDataStore().getId(), templateOnStore.getDataStore().getRole());
        obj.setInstallPath(callbackResult.getPath());
       
        if (callbackResult.getSize() != null) {
            obj.setSize(callbackResult.getSize());
        }
       
        try {
            objectInDataStoreMgr.update(obj, Event.OperationSuccessed);
        } catch (NoTransitionException e) {
View Full Code Here

Examples of org.apache.cloudstack.storage.db.ObjectInDataStoreVO

        ImageDataVO templ = imageDataDao.findById(templateId);
        if (store == null) {
            TemplateObject tmpl =  TemplateObject.getTemplate(templ, null);
            return tmpl;
        }
        ObjectInDataStoreVO obj = objMap.findObject(templateId, DataObjectType.TEMPLATE, store.getId(), store.getRole());
        if (obj == null) {
            TemplateObject tmpl =  TemplateObject.getTemplate(templ, null);
            return tmpl;
        }
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.