mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
move interfaces around
This commit is contained in:
parent
8eadeba37c
commit
2251d5bb40
@ -19,10 +19,13 @@
|
|||||||
package org.apache.cloudstack.engine.cloud.entity.api;
|
package org.apache.cloudstack.engine.cloud.entity.api;
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.entity.api.CloudStackEntity;
|
import org.apache.cloudstack.engine.entity.api.CloudStackEntity;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
|
|
||||||
import com.cloud.storage.Volume;
|
import com.cloud.storage.Volume;
|
||||||
|
|
||||||
public interface VolumeEntity extends CloudStackEntity, Volume {
|
public interface VolumeEntity extends CloudStackEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take a snapshot of the volume
|
* Take a snapshot of the volume
|
||||||
@ -71,4 +74,13 @@ public interface VolumeEntity extends CloudStackEntity, Volume {
|
|||||||
* Destroy the volume
|
* Destroy the volume
|
||||||
*/
|
*/
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
|
long getSize();
|
||||||
|
|
||||||
|
String getTemplatePath();
|
||||||
|
String getTemplateUuid();
|
||||||
|
VolumeDiskType getDiskType();
|
||||||
|
VolumeType getType();
|
||||||
|
PrimaryDataStore getDataStore();
|
||||||
|
void setUuid(String uuid);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package org.apache.cloudstack.storage;
|
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.Command;
|
import com.cloud.agent.api.Command;
|
||||||
@ -16,19 +16,19 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.datastore;
|
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.EndPoint;
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
import org.apache.cloudstack.storage.volume.Volume;
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
|
||||||
|
|
||||||
public interface PrimaryDataStore {
|
public interface PrimaryDataStore {
|
||||||
Volume getVolume(long id);
|
VolumeEntity getVolume(long id);
|
||||||
List<Volume> getVolumes();
|
List<VolumeEntity> getVolumes();
|
||||||
boolean deleteVolume(long id);
|
boolean deleteVolume(long id);
|
||||||
Volume createVolume(long id, VolumeDiskType diskType);
|
VolumeEntity createVolume(long id, VolumeDiskType diskType);
|
||||||
List<EndPoint> getEndPoints();
|
List<EndPoint> getEndPoints();
|
||||||
PrimaryDataStoreInfo getDataStoreInfo();
|
PrimaryDataStoreInfo getDataStoreInfo();
|
||||||
}
|
}
|
||||||
@ -16,9 +16,10 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.datastore;
|
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
|
|
||||||
@ -16,17 +16,19 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.volume;
|
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
|
||||||
import org.apache.cloudstack.storage.volume.type.VolumeType;
|
|
||||||
|
|
||||||
public interface VolumeService {
|
public interface VolumeService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Volume allocateVolumeInDb(long size, VolumeType type,String volName, Long templateId);
|
VolumeEntity allocateVolumeInDb(long size, VolumeType type,String volName, Long templateId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the volume based on the given criteria
|
* Creates the volume based on the given criteria
|
||||||
@ -35,7 +37,7 @@ public interface VolumeService {
|
|||||||
*
|
*
|
||||||
* @return the volume object
|
* @return the volume object
|
||||||
*/
|
*/
|
||||||
Volume createVolume(long volumeId, long dataStoreId, VolumeDiskType diskType);
|
VolumeEntity createVolume(long volumeId, long dataStoreId, VolumeDiskType diskType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete volume
|
* Delete volume
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.apache.cloudstack.storage.volume.disktype;
|
package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.apache.cloudstack.storage.volume.disktype;
|
package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
|
||||||
|
|
||||||
public class Unknown extends VolumeDiskTypeBase {
|
public class Unknown extends VolumeDiskTypeBase {
|
||||||
public Unknown() {
|
public Unknown() {
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.apache.cloudstack.storage.volume.disktype;
|
package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.apache.cloudstack.storage.volume.disktype;
|
package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
|
||||||
|
|
||||||
|
public interface VolumeDiskType {
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.apache.cloudstack.storage.volume.disktype;
|
package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
|
||||||
|
|
||||||
public class VolumeDiskTypeBase implements VolumeDiskType {
|
public class VolumeDiskTypeBase implements VolumeDiskType {
|
||||||
protected String type = "Unknown";
|
protected String type = "Unknown";
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.apache.cloudstack.storage.volume.disktype;
|
package org.apache.cloudstack.engine.subsystem.api.storage.disktype;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.apache.cloudstack.storage.volume.type;
|
package org.apache.cloudstack.engine.subsystem.api.storage.type;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.apache.cloudstack.storage.volume.type;
|
package org.apache.cloudstack.engine.subsystem.api.storage.type;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.apache.cloudstack.storage.volume.type;
|
package org.apache.cloudstack.engine.subsystem.api.storage.type;
|
||||||
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.apache.cloudstack.storage.volume.type;
|
package org.apache.cloudstack.engine.subsystem.api.storage.type;
|
||||||
|
|
||||||
public class Unknown extends VolumeTypeBase {
|
public class Unknown extends VolumeTypeBase {
|
||||||
public Unknown() {
|
public Unknown() {
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.volume.type;
|
package org.apache.cloudstack.engine.subsystem.api.storage.type;
|
||||||
|
|
||||||
public interface VolumeType {
|
public interface VolumeType {
|
||||||
}
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.apache.cloudstack.storage.volume.type;
|
package org.apache.cloudstack.engine.subsystem.api.storage.type;
|
||||||
|
|
||||||
public class VolumeTypeBase implements VolumeType {
|
public class VolumeTypeBase implements VolumeType {
|
||||||
protected String type = "Unknown";
|
protected String type = "Unknown";
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package org.apache.cloudstack.storage.volume.type;
|
package org.apache.cloudstack.engine.subsystem.api.storage.type;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -20,6 +20,7 @@ package org.apache.cloudstack.storage;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
import com.cloud.agent.AgentManager;
|
||||||
|
|||||||
@ -6,15 +6,20 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.EndPoint;
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
import org.apache.cloudstack.storage.HypervisorHostEndPoint;
|
import org.apache.cloudstack.storage.HypervisorHostEndPoint;
|
||||||
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
||||||
import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
|
import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
|
||||||
import org.apache.cloudstack.storage.volume.Volume;
|
|
||||||
|
import org.apache.cloudstack.storage.volume.VolumeEntityImpl;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeEvent;
|
import org.apache.cloudstack.storage.volume.VolumeEvent;
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeVO;
|
import org.apache.cloudstack.storage.volume.db.VolumeVO;
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.host.HostVO;
|
import com.cloud.host.HostVO;
|
||||||
@ -40,14 +45,14 @@ public class DefaultPrimaryDataStoreImpl implements PrimaryDataStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Volume getVolume(long id) {
|
public VolumeEntity getVolume(long id) {
|
||||||
VolumeVO volumeVO = volumeDao.findById(id);
|
VolumeVO volumeVO = volumeDao.findById(id);
|
||||||
Volume vol = new Volume(this, volumeVO);
|
VolumeEntity vol = new VolumeEntityImpl(this, volumeVO);
|
||||||
return vol;
|
return vol;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Volume> getVolumes() {
|
public List<VolumeEntity> getVolumes() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -59,8 +64,9 @@ public class DefaultPrimaryDataStoreImpl implements PrimaryDataStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Volume createVolume(long id, VolumeDiskType diskType) {
|
public VolumeEntity createVolume(long id, VolumeDiskType diskType) {
|
||||||
Volume vol = this.getVolume(id);
|
/*
|
||||||
|
VolumeEntity vol = this.getVolume(id);
|
||||||
if (vol == null) {
|
if (vol == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -89,8 +95,8 @@ public class DefaultPrimaryDataStoreImpl implements PrimaryDataStore {
|
|||||||
} else {
|
} else {
|
||||||
vol.stateTransit(VolumeEvent.OperationFailed);
|
vol.stateTransit(VolumeEvent.OperationFailed);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -20,8 +20,8 @@ package org.apache.cloudstack.storage.datastore;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
|
|
||||||
|
|||||||
@ -2,10 +2,10 @@ package org.apache.cloudstack.storage.datastore.driver;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.EndPoint;
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||||
import org.apache.cloudstack.storage.command.CreateVolumeAnswer;
|
import org.apache.cloudstack.storage.command.CreateVolumeAnswer;
|
||||||
import org.apache.cloudstack.storage.command.CreateVolumeCommand;
|
import org.apache.cloudstack.storage.command.CreateVolumeCommand;
|
||||||
import org.apache.cloudstack.storage.volume.Volume;
|
|
||||||
import org.apache.cloudstack.storage.volume.VolumeInfo;
|
import org.apache.cloudstack.storage.volume.VolumeInfo;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -17,7 +17,7 @@ public class DefaultPrimaryDataStoreDriverImpl implements
|
|||||||
PrimaryDataStoreDriver {
|
PrimaryDataStoreDriver {
|
||||||
private static final Logger s_logger = Logger.getLogger(DefaultPrimaryDataStoreDriverImpl.class);
|
private static final Logger s_logger = Logger.getLogger(DefaultPrimaryDataStoreDriverImpl.class);
|
||||||
@Override
|
@Override
|
||||||
public boolean createVolume(Volume vol) {
|
public boolean createVolume(VolumeEntity vol) {
|
||||||
//The default driver will send createvolume command to one of hosts which can access its datastore
|
//The default driver will send createvolume command to one of hosts which can access its datastore
|
||||||
List<EndPoint> endPoints = vol.getDataStore().getEndPoints();
|
List<EndPoint> endPoints = vol.getDataStore().getEndPoints();
|
||||||
int retries = 3;
|
int retries = 3;
|
||||||
@ -45,19 +45,19 @@ public class DefaultPrimaryDataStoreDriverImpl implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteVolume(Volume vo) {
|
public boolean deleteVolume(VolumeEntity vo) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String grantAccess(Volume vol, EndPoint ep) {
|
public String grantAccess(VolumeEntity vol, EndPoint ep) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean revokeAccess(Volume vol, EndPoint ep) {
|
public boolean revokeAccess(VolumeEntity vol, EndPoint ep) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
package org.apache.cloudstack.storage.datastore.driver;
|
package org.apache.cloudstack.storage.datastore.driver;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.EndPoint;
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
import org.apache.cloudstack.storage.volume.Volume;
|
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
|
||||||
|
|
||||||
|
|
||||||
public interface PrimaryDataStoreDriver {
|
public interface PrimaryDataStoreDriver {
|
||||||
boolean createVolume(Volume vol);
|
boolean createVolume(VolumeEntity vol);
|
||||||
boolean deleteVolume(Volume vo);
|
boolean deleteVolume(VolumeEntity vo);
|
||||||
String grantAccess(Volume vol, EndPoint ep);
|
String grantAccess(VolumeEntity vol, EndPoint ep);
|
||||||
boolean revokeAccess(Volume vol, EndPoint ep);
|
boolean revokeAccess(VolumeEntity vol, EndPoint ep);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ package org.apache.cloudstack.storage.datastore.manager;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||||
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
||||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderDao;
|
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreProviderDao;
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.datastore.manager;
|
package org.apache.cloudstack.storage.datastore.manager;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||||
import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
|
import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
|
||||||
|
|
||||||
public interface PrimaryDataStoreManager {
|
public interface PrimaryDataStoreManager {
|
||||||
|
|||||||
@ -2,9 +2,9 @@ package org.apache.cloudstack.storage.datastore.provider;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||||
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStoreImpl;
|
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStoreImpl;
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStoreInfo;
|
|
||||||
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
import org.apache.cloudstack.storage.datastore.db.DataStoreVO;
|
||||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||||
import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
|
import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package org.apache.cloudstack.storage.datastore.provider;
|
package org.apache.cloudstack.storage.datastore.provider;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStoreInfo;
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||||
|
|
||||||
public interface PrimaryDataStoreProvider {
|
public interface PrimaryDataStoreProvider {
|
||||||
public PrimaryDataStore getDataStore(long dataStoreId);
|
public PrimaryDataStore getDataStore(long dataStoreId);
|
||||||
|
|||||||
@ -18,8 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.image.db;
|
package org.apache.cloudstack.storage.image.db;
|
||||||
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
|
@Component
|
||||||
public class ImageDaoStoreDaoImpl extends GenericDaoBase<ImageDataStoreVO, Long> implements ImageDataStoreDao {
|
public class ImageDaoStoreDaoImpl extends GenericDaoBase<ImageDataStoreVO, Long> implements ImageDataStoreDao {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,9 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.image.db;
|
package org.apache.cloudstack.storage.image.db;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
import com.cloud.utils.db.GenericDaoBase;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class ImageDataStoreProviderDaoImpl extends GenericDaoBase<ImageDataStoreProviderVO, Long> implements ImageDataStoreProviderDao {
|
public class ImageDataStoreProviderDaoImpl extends GenericDaoBase<ImageDataStoreProviderVO, Long> implements ImageDataStoreProviderDao {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,5 +27,6 @@ public interface ImageDataStore {
|
|||||||
boolean revokeAccess(long templateId, long endPointId);
|
boolean revokeAccess(long templateId, long endPointId);
|
||||||
boolean deleteTemplate(long templateId);
|
boolean deleteTemplate(long templateId);
|
||||||
boolean needDownloadToCacheStorage();
|
boolean needDownloadToCacheStorage();
|
||||||
|
|
||||||
ImageDownloader getImageDownloader();
|
ImageDownloader getImageDownloader();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ package org.apache.cloudstack.storage.manager;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||||
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.storage.StoragePool;
|
import com.cloud.storage.StoragePool;
|
||||||
|
|||||||
@ -24,9 +24,9 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
|
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
|
import org.apache.cloudstack.engine.subsystem.api.storage.StorageProvider;
|
||||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore.StoreType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore.StoreType;
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
|
||||||
|
|
||||||
import com.cloud.dc.ClusterVO;
|
import com.cloud.dc.ClusterVO;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
|
|||||||
@ -1,101 +0,0 @@
|
|||||||
package org.apache.cloudstack.storage.volume;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStoreInfo;
|
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeVO;
|
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskTypeHelper;
|
|
||||||
import org.apache.cloudstack.storage.volume.type.VolumeType;
|
|
||||||
import org.apache.cloudstack.storage.volume.type.VolumeTypeHelper;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.utils.fsm.NoTransitionException;
|
|
||||||
import com.cloud.utils.fsm.StateMachine2;
|
|
||||||
|
|
||||||
public class Volume {
|
|
||||||
private static final Logger s_logger = Logger.getLogger(Volume.class);
|
|
||||||
protected VolumeVO volumeVO;
|
|
||||||
private StateMachine2<VolumeState, VolumeEvent, VolumeVO> _volStateMachine;
|
|
||||||
protected PrimaryDataStore dataStore;
|
|
||||||
@Inject
|
|
||||||
VolumeDiskTypeHelper diskTypeHelper;
|
|
||||||
@Inject
|
|
||||||
VolumeTypeHelper volumeTypeHelper;
|
|
||||||
@Inject
|
|
||||||
VolumeDao volumeDao;
|
|
||||||
|
|
||||||
public Volume(PrimaryDataStore dataStore, VolumeVO volumeVO) {
|
|
||||||
this.volumeVO = volumeVO;
|
|
||||||
this.dataStore = dataStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUuid() {
|
|
||||||
return volumeVO.getUuid();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUuid(String uuid) {
|
|
||||||
volumeVO.setUuid(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPath() {
|
|
||||||
return volumeVO.getPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTemplateUuid() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTemplatePath() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PrimaryDataStoreInfo getDataStoreInfo() {
|
|
||||||
return dataStore.getDataStoreInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public VolumeState getState() {
|
|
||||||
return volumeVO.getState();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PrimaryDataStore getDataStore() {
|
|
||||||
return dataStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getSize() {
|
|
||||||
return volumeVO.getSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public VolumeDiskType getDiskType() {
|
|
||||||
return diskTypeHelper.getDiskType(volumeVO.getDiskType());
|
|
||||||
}
|
|
||||||
|
|
||||||
public VolumeType getType() {
|
|
||||||
return volumeTypeHelper.getType(volumeVO.getVolumeType());
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getVolumeId() {
|
|
||||||
return volumeVO.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVolumeDiskType(VolumeDiskType type) {
|
|
||||||
volumeVO.setDiskType(type.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean stateTransit(VolumeEvent event) {
|
|
||||||
boolean result = false;
|
|
||||||
try {
|
|
||||||
result = _volStateMachine.transitTo(volumeVO, event, null, volumeDao);
|
|
||||||
} catch (NoTransitionException e) {
|
|
||||||
s_logger.debug("Failed to transit volume: " + this.getVolumeId() + ", due to: " + e.toString());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update() {
|
|
||||||
volumeDao.update(volumeVO.getId(), volumeVO);
|
|
||||||
volumeVO = volumeDao.findById(volumeVO.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -0,0 +1,236 @@
|
|||||||
|
package org.apache.cloudstack.storage.volume;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity;
|
||||||
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskTypeHelper;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeTypeHelper;
|
||||||
|
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
||||||
|
import org.apache.cloudstack.storage.volume.db.VolumeVO;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.storage.Volume;
|
||||||
|
import com.cloud.utils.fsm.NoTransitionException;
|
||||||
|
import com.cloud.utils.fsm.StateMachine2;
|
||||||
|
|
||||||
|
public class VolumeEntityImpl implements VolumeEntity {
|
||||||
|
private static final Logger s_logger = Logger.getLogger(VolumeEntityImpl.class);
|
||||||
|
protected VolumeVO volumeVO;
|
||||||
|
private StateMachine2<Volume.State, VolumeEvent, VolumeVO> _volStateMachine;
|
||||||
|
protected PrimaryDataStore dataStore;
|
||||||
|
@Inject
|
||||||
|
VolumeDiskTypeHelper diskTypeHelper;
|
||||||
|
@Inject
|
||||||
|
VolumeTypeHelper volumeTypeHelper;
|
||||||
|
@Inject
|
||||||
|
VolumeDao volumeDao;
|
||||||
|
|
||||||
|
public VolumeEntityImpl(PrimaryDataStore dataStore, VolumeVO volumeVO) {
|
||||||
|
this.volumeVO = volumeVO;
|
||||||
|
this.dataStore = dataStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUuid() {
|
||||||
|
return volumeVO.getUuid();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUuid(String uuid) {
|
||||||
|
volumeVO.setUuid(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return volumeVO.getPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTemplateUuid() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTemplatePath() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrimaryDataStoreInfo getDataStoreInfo() {
|
||||||
|
return dataStore.getDataStoreInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Volume.State getState() {
|
||||||
|
return volumeVO.getState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PrimaryDataStore getDataStore() {
|
||||||
|
return dataStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSize() {
|
||||||
|
return volumeVO.getSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public VolumeDiskType getDiskType() {
|
||||||
|
return diskTypeHelper.getDiskType(volumeVO.getDiskType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public VolumeType getType() {
|
||||||
|
return volumeTypeHelper.getType(volumeVO.getVolumeType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getVolumeId() {
|
||||||
|
return volumeVO.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVolumeDiskType(VolumeDiskType type) {
|
||||||
|
volumeVO.setDiskType(type.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean stateTransit(VolumeEvent event) {
|
||||||
|
boolean result = false;
|
||||||
|
try {
|
||||||
|
result = _volStateMachine.transitTo(volumeVO, event, null, volumeDao);
|
||||||
|
} catch (NoTransitionException e) {
|
||||||
|
s_logger.debug("Failed to transit volume: " + this.getVolumeId() + ", due to: " + e.toString());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
volumeDao.update(volumeVO.getId(), volumeVO);
|
||||||
|
volumeVO = volumeDao.findById(volumeVO.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getId() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExternalId() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCurrentState() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDesiredState() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getCreatedTime() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Date getLastUpdatedTime() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOwner() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getDetails(String source) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getDetailSources() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addDetail(String source, String name, String value) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delDetail(String source, String name, String value) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateDetail(String source, String name, String value) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Method> getApplicableActions() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SnapshotEntity takeSnapshotOf(boolean full) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String reserveForMigration(long expirationTime) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void migrate(String reservationToken) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public VolumeEntity setupForCopy() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void copy(VolumeEntity dest) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void attachTo(String vm, long deviceId) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void detachFrom() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -18,9 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cloudstack.storage.volume;
|
package org.apache.cloudstack.storage.volume;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStoreInfo;
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
|
||||||
import org.apache.cloudstack.storage.volume.type.VolumeType;
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
|
|
||||||
public class VolumeInfo {
|
public class VolumeInfo {
|
||||||
private long size;
|
private long size;
|
||||||
@ -32,12 +33,12 @@ public class VolumeInfo {
|
|||||||
private VolumeType type;
|
private VolumeType type;
|
||||||
private VolumeDiskType diskType;
|
private VolumeDiskType diskType;
|
||||||
|
|
||||||
public VolumeInfo(Volume volume) {
|
public VolumeInfo(VolumeEntity volume) {
|
||||||
this.size = volume.getSize();
|
this.size = volume.getSize();
|
||||||
this.uuid = volume.getUuid();
|
this.uuid = volume.getUuid();
|
||||||
this.baseTemplatePath = volume.getTemplatePath();
|
this.baseTemplatePath = volume.getTemplatePath();
|
||||||
this.baseTemplateUuid = volume.getTemplateUuid();
|
this.baseTemplateUuid = volume.getTemplateUuid();
|
||||||
this.dataStoreInfo = volume.getDataStoreInfo();
|
//this.dataStoreInfo = volume.getDataStoreInfo();
|
||||||
this.diskType = volume.getDiskType();
|
this.diskType = volume.getDiskType();
|
||||||
this.type = volume.getType();
|
this.type = volume.getType();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,11 +20,14 @@ package org.apache.cloudstack.storage.volume;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
import org.apache.cloudstack.storage.datastore.manager.PrimaryDataStoreManager;
|
import org.apache.cloudstack.storage.datastore.manager.PrimaryDataStoreManager;
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
|
||||||
import org.apache.cloudstack.storage.volume.type.VolumeType;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
@ -36,7 +39,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
@Inject
|
@Inject
|
||||||
PrimaryDataStoreManager dataStoreMgr;
|
PrimaryDataStoreManager dataStoreMgr;
|
||||||
@Override
|
@Override
|
||||||
public Volume createVolume(long volumeId, long dataStoreId, VolumeDiskType diskType) {
|
public VolumeEntity createVolume(long volumeId, long dataStoreId, VolumeDiskType diskType) {
|
||||||
PrimaryDataStore dataStore = dataStoreMgr.getPrimaryDataStore(dataStoreId);
|
PrimaryDataStore dataStore = dataStoreMgr.getPrimaryDataStore(dataStoreId);
|
||||||
return dataStore.createVolume(volumeId, diskType);
|
return dataStore.createVolume(volumeId, diskType);
|
||||||
}
|
}
|
||||||
@ -72,8 +75,9 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Volume allocateVolumeInDb(long size, VolumeType type, String volName, Long templateId) {
|
public VolumeEntity allocateVolumeInDb(long size, VolumeType type, String volName, Long templateId) {
|
||||||
volDao.allocVolume(size, type, volName, templateId);
|
volDao.allocVolume(size, type, volName, templateId);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.apache.cloudstack.storage.volume;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeVO;
|
|
||||||
|
|
||||||
import com.cloud.utils.fsm.StateMachine2;
|
|
||||||
|
|
||||||
public enum VolumeState {
|
|
||||||
Allocated("The volume is allocated but has not been created yet."),
|
|
||||||
Creating("The volume is being created. getPoolId() should reflect the pool where it is being created."),
|
|
||||||
Ready("The volume is ready to be used."),
|
|
||||||
Migrating("The volume is migrating to other storage pool"),
|
|
||||||
Snapshotting("There is a snapshot created on this volume, not backed up to secondary storage yet"),
|
|
||||||
Expunging("The volume is being expunging"),
|
|
||||||
Destroy("The volume is destroyed, and can't be recovered."),
|
|
||||||
UploadOp ("The volume upload operation is in progress or in short the volume is on secondary storage");
|
|
||||||
|
|
||||||
String _description;
|
|
||||||
|
|
||||||
private VolumeState(String description) {
|
|
||||||
_description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static StateMachine2<VolumeState, VolumeEvent, VolumeVO> getStateMachine() {
|
|
||||||
return s_fsm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return _description;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static StateMachine2<VolumeState, VolumeEvent, VolumeVO> s_fsm = new StateMachine2<VolumeState, VolumeEvent, VolumeVO>();
|
|
||||||
static {
|
|
||||||
s_fsm.addTransition(Allocated, VolumeEvent.CreateRequested, Creating);
|
|
||||||
s_fsm.addTransition(Allocated, VolumeEvent.DestroyRequested, Destroy);
|
|
||||||
s_fsm.addTransition(Creating, VolumeEvent.OperationRetry, Creating);
|
|
||||||
s_fsm.addTransition(Creating, VolumeEvent.OperationFailed, Allocated);
|
|
||||||
s_fsm.addTransition(Creating, VolumeEvent.OperationSucceeded, Ready);
|
|
||||||
s_fsm.addTransition(Creating, VolumeEvent.DestroyRequested, Destroy);
|
|
||||||
s_fsm.addTransition(Creating, VolumeEvent.CreateRequested, Creating);
|
|
||||||
s_fsm.addTransition(Allocated, VolumeEvent.UploadRequested, UploadOp);
|
|
||||||
s_fsm.addTransition(UploadOp, VolumeEvent.CopyRequested, Creating);// CopyRequested for volume from sec to primary storage
|
|
||||||
s_fsm.addTransition(Creating, VolumeEvent.CopySucceeded, Ready);
|
|
||||||
s_fsm.addTransition(Creating, VolumeEvent.CopyFailed, UploadOp);// Copying volume from sec to primary failed.
|
|
||||||
s_fsm.addTransition(UploadOp, VolumeEvent.DestroyRequested, Destroy);
|
|
||||||
s_fsm.addTransition(Ready, VolumeEvent.DestroyRequested, Destroy);
|
|
||||||
s_fsm.addTransition(Destroy, VolumeEvent.ExpungingRequested, Expunging);
|
|
||||||
s_fsm.addTransition(Ready, VolumeEvent.SnapshotRequested, Snapshotting);
|
|
||||||
s_fsm.addTransition(Snapshotting, VolumeEvent.OperationSucceeded, Ready);
|
|
||||||
s_fsm.addTransition(Snapshotting, VolumeEvent.OperationFailed, Ready);
|
|
||||||
s_fsm.addTransition(Ready, VolumeEvent.MigrationRequested, Migrating);
|
|
||||||
s_fsm.addTransition(Migrating, VolumeEvent.OperationSucceeded, Ready);
|
|
||||||
s_fsm.addTransition(Migrating, VolumeEvent.OperationFailed, Ready);
|
|
||||||
s_fsm.addTransition(Destroy, VolumeEvent.OperationSucceeded, Destroy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -18,19 +18,19 @@ package org.apache.cloudstack.storage.volume.db;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.volume.Volume;
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeEvent;
|
import org.apache.cloudstack.storage.volume.VolumeEvent;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeState;
|
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
|
||||||
import org.apache.cloudstack.storage.volume.type.VolumeType;
|
|
||||||
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
|
import com.cloud.storage.Volume;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
import com.cloud.utils.fsm.StateDao;
|
import com.cloud.utils.fsm.StateDao;
|
||||||
|
|
||||||
public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<VolumeState, VolumeEvent, VolumeVO> {
|
public interface VolumeDao extends GenericDao<VolumeVO, Long>, StateDao<Volume.State, VolumeEvent, VolumeVO> {
|
||||||
|
|
||||||
List<VolumeVO> findDetachedByAccount(long accountId);
|
List<VolumeVO> findDetachedByAccount(long accountId);
|
||||||
|
|
||||||
|
|||||||
@ -25,18 +25,17 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.volume.Volume;
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeEvent;
|
import org.apache.cloudstack.storage.volume.VolumeEvent;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeState;
|
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
|
||||||
import org.apache.cloudstack.storage.volume.type.RootDisk;
|
|
||||||
import org.apache.cloudstack.storage.volume.type.VolumeType;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||||
import com.cloud.storage.Storage.ImageFormat;
|
import com.cloud.storage.Storage.ImageFormat;
|
||||||
|
import com.cloud.storage.Volume;
|
||||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
import com.cloud.utils.component.ComponentLocator;
|
||||||
@ -75,7 +74,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
public List<VolumeVO> findDetachedByAccount(long accountId) {
|
public List<VolumeVO> findDetachedByAccount(long accountId) {
|
||||||
SearchCriteria<VolumeVO> sc = DetachedAccountIdSearch.create();
|
SearchCriteria<VolumeVO> sc = DetachedAccountIdSearch.create();
|
||||||
sc.setParameters("accountId", accountId);
|
sc.setParameters("accountId", accountId);
|
||||||
sc.setParameters("destroyed", VolumeState.Destroy);
|
sc.setParameters("destroyed", Volume.State.Destroy);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +82,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
public List<VolumeVO> findByAccount(long accountId) {
|
public List<VolumeVO> findByAccount(long accountId) {
|
||||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||||
sc.setParameters("accountId", accountId);
|
sc.setParameters("accountId", accountId);
|
||||||
sc.setParameters("state", VolumeState.Ready);
|
sc.setParameters("state", Volume.State.Ready);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +105,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
public List<VolumeVO> findByPoolId(long poolId) {
|
public List<VolumeVO> findByPoolId(long poolId) {
|
||||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||||
sc.setParameters("poolId", poolId);
|
sc.setParameters("poolId", poolId);
|
||||||
sc.setParameters("notDestroyed", VolumeState.Destroy);
|
sc.setParameters("notDestroyed", Volume.State.Destroy);
|
||||||
sc.setParameters("vType", new RootDisk().toString());
|
sc.setParameters("vType", new RootDisk().toString());
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
@ -115,7 +114,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
public List<VolumeVO> findCreatedByInstance(long id) {
|
public List<VolumeVO> findCreatedByInstance(long id) {
|
||||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||||
sc.setParameters("instanceId", id);
|
sc.setParameters("instanceId", id);
|
||||||
sc.setParameters("state", VolumeState.Ready);
|
sc.setParameters("state", Volume.State.Ready);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +122,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
public List<VolumeVO> findUsableVolumesForInstance(long instanceId) {
|
public List<VolumeVO> findUsableVolumesForInstance(long instanceId) {
|
||||||
SearchCriteria<VolumeVO> sc = InstanceStatesSearch.create();
|
SearchCriteria<VolumeVO> sc = InstanceStatesSearch.create();
|
||||||
sc.setParameters("instance", instanceId);
|
sc.setParameters("instance", instanceId);
|
||||||
sc.setParameters("states", VolumeState.Creating, VolumeState.Ready, VolumeState.Allocated);
|
sc.setParameters("states", Volume.State.Creating, Volume.State.Ready, Volume.State.Allocated);
|
||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
@ -140,7 +139,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
public List<VolumeVO> findByInstanceIdDestroyed(long vmId) {
|
public List<VolumeVO> findByInstanceIdDestroyed(long vmId) {
|
||||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||||
sc.setParameters("instanceId", vmId);
|
sc.setParameters("instanceId", vmId);
|
||||||
sc.setParameters("destroyed", VolumeState.Destroy);
|
sc.setParameters("destroyed", Volume.State.Destroy);
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +147,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
public List<VolumeVO> findReadyRootVolumesByInstance(long instanceId) {
|
public List<VolumeVO> findReadyRootVolumesByInstance(long instanceId) {
|
||||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||||
sc.setParameters("instanceId", instanceId);
|
sc.setParameters("instanceId", instanceId);
|
||||||
sc.setParameters("state", VolumeState.Ready);
|
sc.setParameters("state", Volume.State.Ready);
|
||||||
sc.setParameters("vType", new RootDisk().toString());
|
sc.setParameters("vType", new RootDisk().toString());
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
@ -158,7 +157,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||||
sc.setParameters("accountId", accountId);
|
sc.setParameters("accountId", accountId);
|
||||||
sc.setParameters("pod", podId);
|
sc.setParameters("pod", podId);
|
||||||
sc.setParameters("state", VolumeState.Ready);
|
sc.setParameters("state", Volume.State.Ready);
|
||||||
|
|
||||||
return listIncludingRemovedBy(sc);
|
return listIncludingRemovedBy(sc);
|
||||||
}
|
}
|
||||||
@ -315,7 +314,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
public Long countAllocatedVolumesForAccount(long accountId) {
|
public Long countAllocatedVolumesForAccount(long accountId) {
|
||||||
SearchCriteria<Long> sc = CountByAccount.create();
|
SearchCriteria<Long> sc = CountByAccount.create();
|
||||||
sc.setParameters("account", accountId);
|
sc.setParameters("account", accountId);
|
||||||
sc.setParameters("state", VolumeState.Destroy);
|
sc.setParameters("state", Volume.State.Destroy);
|
||||||
return customSearch(sc, null).get(0);
|
return customSearch(sc, null).get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,14 +328,14 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
@Override
|
@Override
|
||||||
public List<VolumeVO> listVolumesToBeDestroyed() {
|
public List<VolumeVO> listVolumesToBeDestroyed() {
|
||||||
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
SearchCriteria<VolumeVO> sc = AllFieldsSearch.create();
|
||||||
sc.setParameters("state", VolumeState.Destroy);
|
sc.setParameters("state", Volume.State.Destroy);
|
||||||
|
|
||||||
return listBy(sc);
|
return listBy(sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateState(VolumeState currentState,
|
public boolean updateState(Volume.State currentState,
|
||||||
VolumeEvent event, VolumeState nextState, VolumeVO vo,
|
VolumeEvent event, Volume.State nextState, VolumeVO vo,
|
||||||
Object data) {
|
Object data) {
|
||||||
|
|
||||||
Long oldUpdated = vo.getUpdatedCount();
|
Long oldUpdated = vo.getUpdatedCount();
|
||||||
@ -397,7 +396,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
|
|||||||
public Pair<Long, Long> getNonDestroyedCountAndTotalByPool(long poolId) {
|
public Pair<Long, Long> getNonDestroyedCountAndTotalByPool(long poolId) {
|
||||||
SearchCriteria<SumCount> sc = TotalSizeByPoolSearch.create();
|
SearchCriteria<SumCount> sc = TotalSizeByPoolSearch.create();
|
||||||
sc.setParameters("poolId", poolId);
|
sc.setParameters("poolId", poolId);
|
||||||
sc.setParameters("state", VolumeState.Destroy);
|
sc.setParameters("state", Volume.State.Destroy);
|
||||||
List<SumCount> results = customSearch(sc, null);
|
List<SumCount> results = customSearch(sc, null);
|
||||||
SumCount sumCount = results.get(0);
|
SumCount sumCount = results.get(0);
|
||||||
return new Pair<Long, Long>(sumCount.count, sumCount.sum);
|
return new Pair<Long, Long>(sumCount.count, sumCount.sum);
|
||||||
|
|||||||
@ -31,11 +31,12 @@ import javax.persistence.TableGenerator;
|
|||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.volume.VolumeState;
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.Unknown;
|
||||||
import org.apache.cloudstack.storage.volume.disktype.Unknown;
|
|
||||||
import org.apache.cloudstack.storage.volume.type.VolumeType;
|
|
||||||
|
|
||||||
import com.cloud.api.Identity;
|
import com.cloud.api.Identity;
|
||||||
|
import com.cloud.storage.Volume;
|
||||||
import com.cloud.storage.Storage.StoragePoolType;
|
import com.cloud.storage.Storage.StoragePoolType;
|
||||||
import com.cloud.utils.NumbersUtil;
|
import com.cloud.utils.NumbersUtil;
|
||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
@ -43,7 +44,7 @@ import com.cloud.utils.fsm.StateObject;
|
|||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "volumes")
|
@Table(name = "volumes")
|
||||||
public class VolumeVO implements Identity, StateObject<VolumeState>{
|
public class VolumeVO implements Identity, StateObject<Volume.State>{
|
||||||
@Id
|
@Id
|
||||||
@TableGenerator(name = "volume_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "volume_seq", allocationSize = 1)
|
@TableGenerator(name = "volume_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "volume_seq", allocationSize = 1)
|
||||||
@GeneratedValue(strategy = GenerationType.TABLE)
|
@GeneratedValue(strategy = GenerationType.TABLE)
|
||||||
@ -130,7 +131,7 @@ public class VolumeVO implements Identity, StateObject<VolumeState>{
|
|||||||
|
|
||||||
@Column(name = "state")
|
@Column(name = "state")
|
||||||
@Enumerated(value = EnumType.STRING)
|
@Enumerated(value = EnumType.STRING)
|
||||||
private VolumeState state;
|
private Volume.State state;
|
||||||
|
|
||||||
@Column(name = "chain_info")
|
@Column(name = "chain_info")
|
||||||
String chainInfo;
|
String chainInfo;
|
||||||
@ -346,7 +347,7 @@ public class VolumeVO implements Identity, StateObject<VolumeState>{
|
|||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VolumeState getState() {
|
public Volume.State getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +0,0 @@
|
|||||||
package org.apache.cloudstack.storage.volume.disktype;
|
|
||||||
|
|
||||||
public interface VolumeDiskType {
|
|
||||||
}
|
|
||||||
@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.cloudstack.storage.test;
|
||||||
|
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
|
||||||
|
public class Future2<T> {
|
||||||
|
|
||||||
|
private Callable<T> callable;
|
||||||
|
private Callable<T> success;
|
||||||
|
private Callable<T> failed;
|
||||||
|
private ExecutorService executor = Executors.newFixedThreadPool(2);
|
||||||
|
private Future<T> f;
|
||||||
|
|
||||||
|
public class Func<T> implements Callable<T> {
|
||||||
|
private Callable<T> f;
|
||||||
|
private Callable<T> fs;
|
||||||
|
public T func() throws Exception {
|
||||||
|
return f.call();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T success() throws Exception {
|
||||||
|
return fs.call();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Func (Callable<T> f, Callable<T> s) {
|
||||||
|
this.f = f;
|
||||||
|
this.fs = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T call() throws Exception {
|
||||||
|
func();
|
||||||
|
success();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public Future2 (Callable<T> callable) {
|
||||||
|
this.callable = callable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(Callable<T> s) {
|
||||||
|
this.success = s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void go() {
|
||||||
|
Func<T> ft = new Func<T>(this.callable, this.success);
|
||||||
|
f = executor.submit(ft);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T get() {
|
||||||
|
try {
|
||||||
|
return this.f.get();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
return null;
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void shutdown() {
|
||||||
|
this.executor.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Callable<String> fun = new Callable<String> () {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String call() throws Exception {
|
||||||
|
System.out.println("execing");
|
||||||
|
return "test";
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
Future2<String> f2 = new Future2<String>(fun);
|
||||||
|
f2.onSuccess(new Callable<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String call() throws Exception {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
System.out.println("success");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
f2.go();
|
||||||
|
//f2.get();
|
||||||
|
f2.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -22,9 +22,18 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
import java.awt.List;
|
import java.awt.List;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.QCOW2;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VHD;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VMDK;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskTypeHelper;
|
||||||
|
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeTypeHelper;
|
||||||
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStoreImpl;
|
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStoreImpl;
|
||||||
import org.apache.cloudstack.storage.datastore.provider.DefaultPrimaryDatastoreProviderImpl;
|
import org.apache.cloudstack.storage.datastore.provider.DefaultPrimaryDatastoreProviderImpl;
|
||||||
import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProvider;
|
import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProvider;
|
||||||
@ -34,15 +43,8 @@ import org.apache.cloudstack.storage.image.format.ImageFormatHelper;
|
|||||||
import org.apache.cloudstack.storage.image.format.OVA;
|
import org.apache.cloudstack.storage.image.format.OVA;
|
||||||
import org.apache.cloudstack.storage.image.format.Unknown;
|
import org.apache.cloudstack.storage.image.format.Unknown;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeMotionService;
|
import org.apache.cloudstack.storage.volume.VolumeMotionService;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeService;
|
|
||||||
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
import org.apache.cloudstack.storage.volume.db.VolumeDao;
|
||||||
import org.apache.cloudstack.storage.volume.disktype.QCOW2;
|
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VHD;
|
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VMDK;
|
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskType;
|
|
||||||
import org.apache.cloudstack.storage.volume.disktype.VolumeDiskTypeHelper;
|
|
||||||
import org.apache.cloudstack.storage.volume.type.Iso;
|
|
||||||
import org.apache.cloudstack.storage.volume.type.VolumeTypeHelper;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -58,7 +60,6 @@ import org.mockito.Mockito.*;
|
|||||||
import com.cloud.utils.component.ComponentInject;
|
import com.cloud.utils.component.ComponentInject;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(locations="storageContext.xml")
|
@ContextConfiguration(locations="storageContext.xml")
|
||||||
public class volumeServiceTest {
|
public class volumeServiceTest {
|
||||||
@ -93,7 +94,7 @@ public class volumeServiceTest {
|
|||||||
fail("Not yet implemented");
|
fail("Not yet implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
//@Test
|
||||||
public void test1() {
|
public void test1() {
|
||||||
System.out.println(VolumeTypeHelper.getType("Root"));
|
System.out.println(VolumeTypeHelper.getType("Root"));
|
||||||
System.out.println(VolumeDiskTypeHelper.getDiskType("vmdk"));
|
System.out.println(VolumeDiskTypeHelper.getDiskType("vmdk"));
|
||||||
@ -125,4 +126,5 @@ public class volumeServiceTest {
|
|||||||
ComponentInject.inject(dpdsi);
|
ComponentInject.inject(dpdsi);
|
||||||
//assertNotNull(dpdsi.volumeDao);
|
//assertNotNull(dpdsi.volumeDao);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user