Package org.apache.cloudstack.engine.subsystem.api.storage

Examples of org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore


        return findObject(obj.getId(), obj.getType(), store.getId(), store.getRole());
    }

    @Override
    public DataObjectInStore findObject(long objId, DataObjectType type, long dataStoreId, DataStoreRole role) {
        DataObjectInStore vo = null;
        if (role == DataStoreRole.Image || role == DataStoreRole.ImageCache) {
            switch (type) {
                case TEMPLATE:
                    vo = templateDataStoreDao.findByStoreTemplate(dataStoreId, objId);
                    break;
View Full Code Here


    @Override
    public DataStore findStore(long objId, DataObjectType type, DataStoreRole role) {
        DataStore store = null;
        if (role == DataStoreRole.Image) {
            DataObjectInStore vo = null;
            switch (type) {
                case TEMPLATE:
                    vo = templateDataStoreDao.findByTemplate(objId, role);
                    break;
                case SNAPSHOT:
                    vo = snapshotDataStoreDao.findBySnapshot(objId, role);
                    break;
                case VOLUME:
                    vo = volumeDataStoreDao.findByVolume(objId);
                    break;
            }
            if (vo != null) {
                store = this.storeMgr.getDataStore(vo.getDataStoreId(), role);
            }
        }
        return store;
    }
View Full Code Here

        }

        // if there are multiple cache stores, we give priority to the one where data is already there
        if (cacheStores.size() > 1) {
            for (DataStore store : cacheStores) {
                DataObjectInStore obj = objectInStoreMgr.findObject(data, store);
                if (obj != null && obj.getState() == ObjectInDataStoreStateMachine.State.Ready) {
                    s_logger.debug("pick the cache store " + store.getId() + " where data is already there");
                    return store;
                }
            }
View Full Code Here

    protected long waitingTime = 1800; // half an hour
    protected long waitingRetries = 10;

    protected DataObject waitingForCreated(DataObject dataObj, DataStore dataStore) {
        long retries = this.waitingRetries;
        DataObjectInStore 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, dataStore);
            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

    }

    @Override
    public void createAsync(DataObject data, DataStore store, AsyncCompletionCallback<CreateCmdResult> callback, boolean noCopy) {
        DataObjectInStore obj = objectInDataStoreMgr.findObject(data, store);
        DataObject objInStore = null;
        boolean freshNewTemplate = false;
        if (obj == null) {
            try {
                objInStore = objectInDataStoreMgr.create(data, store);
                freshNewTemplate = true;
            } catch (Throwable e) {
                obj = objectInDataStoreMgr.findObject(data, store);
                if (obj == null) {
                    CreateCmdResult result = new CreateCmdResult(null, null);
                    result.setSuccess(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);
                result.setSuccess(false);
View Full Code Here

        return null;
    }

    @Override
    public DataObject createInternalStateOnly(DataObject data, DataStore store) {
        DataObjectInStore obj = objectInDataStoreMgr.findObject(data, store);
        DataObject objInStore = null;
        if (obj == null) {
            objInStore = objectInDataStoreMgr.create(data, store);
        }
        try {
View Full Code Here

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

    @Override
    public String getPath() {
        if (dataStore.getRole() == DataStoreRole.Primary) {
            return volumeVO.getPath();
        } else {
            DataObjectInStore objInStore = objectInStoreMgr.findObject(this, dataStore);
            if (objInStore != null) {
                return objInStore.getInstallPath();
            } else {
                return null;
            }
        }
    }
View Full Code Here

            if (managed) {
                return null;
            }
        }

        DataObjectInStore obj = objectInStoreMgr.findObject(this, dataStore);
        return obj.getInstallPath();
    }
View Full Code Here

    @Override
    public String getPath() {
        if (installPath != null)
            return installPath;

        DataObjectInStore objectInStore = objectInStoreMgr.findObject(this, getDataStore());
        if (objectInStore != null) {
            return objectInStore.getInstallPath();
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore

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.