Examples of ObjectInDataStoreVO


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

    @Inject
    DataStoreManager storeMgr;
    @Override
    public SnapshotInfo getSnapshot(long snapshotId, DataStore store) {
        SnapshotVO snapshot = snapshotDao.findById(snapshotId);
        ObjectInDataStoreVO obj = objMap.findObject(snapshotId, DataObjectType.SNAPSHOT, store.getId(), store.getRole());
        SnapshotObject so = new SnapshotObject(snapshot, store);
        return so;
    }
View Full Code Here

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

    public String getUri() {
        ImageDataVO image = imageDao.findById(this.imageVO.getId());
        if (this.dataStore == null) {
            return image.getUrl();
        } else {
            ObjectInDataStoreVO obj = objectInStoreMgr.findObject(
                    this.imageVO.getId(), DataObjectType.TEMPLATE,
                    this.dataStore.getId(), this.dataStore.getRole());
            StringBuilder builder = new StringBuilder();
            if (obj.getState() == ObjectInDataStoreStateMachine.State.Ready
                    || obj.getState() == ObjectInDataStoreStateMachine.State.Copying) {
               
                builder.append(this.dataStore.getUri());
                builder.append("&" + EncodingType.OBJTYPE + "=" + DataObjectType.TEMPLATE);
                builder.append("&" + EncodingType.PATH + "=" + obj.getInstallPath());
                builder.append("&" + EncodingType.SIZE + "=" + image.getSize());
                return builder.toString();
            } else {
                builder.append(this.dataStore.getUri());
                builder.append("&" + EncodingType.OBJTYPE + "=" + DataObjectType.TEMPLATE);
View Full Code Here

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

    @Override
    public Long getSize() {
        if (this.dataStore == null) {
            return this.imageVO.getSize();
        }
        ObjectInDataStoreVO obj = objectInStoreMgr.findObject(
                this.imageVO.getId(), DataObjectType.TEMPLATE,
                this.dataStore.getId(), this.dataStore.getRole());
        return obj.getSize();
    }
View Full Code Here

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

    }

    @Override
    public DataObject create(DataObject obj, DataStore dataStore) {
       
        ObjectInDataStoreVO vo = new ObjectInDataStoreVO();
        vo.setDataStoreId(dataStore.getId());
        vo.setDataStoreRole(dataStore.getRole());
        vo.setObjectId(obj.getId());
        vo.setSize(obj.getSize());

        vo.setObjectType(obj.getType());
        vo = objectDataStoreDao.persist(vo);

        if (obj.getType() == DataObjectType.TEMPLATE) {
            return imageFactory.getTemplate(obj.getId(), dataStore);
        } else if (obj.getType() == DataObjectType.VOLUME) {
View Full Code Here

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

        throw new CloudRuntimeException("unknown type");
    }

    @Override
    public VolumeInfo create(VolumeInfo volume, DataStore dataStore) {
        ObjectInDataStoreVO vo = new ObjectInDataStoreVO();
        vo.setDataStoreId(dataStore.getId());
        vo.setDataStoreRole(dataStore.getRole());
        vo.setObjectId(volume.getId());
        vo.setObjectType(volume.getType());
        vo = objectDataStoreDao.persist(vo);

        return volumeFactory.getVolume(volume.getId(), dataStore);
    }
View Full Code Here

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

        sc.addAnd(sc.getEntity().getObjectType(), Op.EQ, type);
        sc.addAnd(sc.getEntity().getDataStoreRole(), Op.EQ, role);
        sc.addAnd(sc.getEntity().getState(), Op.NIN,
                ObjectInDataStoreStateMachine.State.Destroyed,
                ObjectInDataStoreStateMachine.State.Failed);
        ObjectInDataStoreVO objectStoreVO = sc.find();
        return objectStoreVO;

    }
View Full Code Here

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

    }

    @Override
    public boolean update(DataObject data, Event event)
            throws NoTransitionException {
        ObjectInDataStoreVO obj = this.findObject(data.getId(), data.getType(),
                data.getDataStore().getId(), data.getDataStore().getRole());
        if (obj == null) {
            throw new CloudRuntimeException(
                    "can't find mapping in ObjectInDataStore table for: "
                            + data);
View Full Code Here

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

    protected long waitingRetries = 10;
   
    protected DataObject waitingForCreated(DataObject dataObj,
            DataStore 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(dataObj.getId(),
                    dataObj.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 createAsync(DataObject data, DataStore store,
            AsyncCompletionCallback<CreateCmdResult> callback, boolean noCopy) {
        ObjectInDataStoreVO obj = objectInDataStoreMgr.findObject(
                data.getId(), data.getType(), store.getId(),
                store.getRole());
        DataObject objInStore = null;
        boolean freshNewTemplate = false;
        if (obj == null) {
            try {
                objInStore = objectInDataStoreMgr.create(
                        data, store);
                freshNewTemplate = true;
            } catch (Throwable e) {
                obj = objectInDataStoreMgr.findObject(data.getId(),
                        data.getType(), store.getId(), store.getRole());
                if (obj == null) {
                    CreateCmdResult result = new CreateCmdResult(
                            null, null);
                    result.setSucess(false);
                    result.setResult(e.toString());
                    callback.complete(result);
                    return;
                }
            }
        }

        if (!freshNewTemplate
                && obj.getState() != ObjectInDataStoreStateMachine.State.Ready) {
            try {
                objInStore = waitingForCreated(
                        data, store);
            } catch (Exception e) {
                CreateCmdResult result = new CreateCmdResult(null, 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(
                objInStrore.getId(), objInStrore
                        .getType(), objInStrore.getDataStore()
                        .getId(), objInStrore.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
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.