clean up storage related code, and add lru replacement algorithm for cache storage

This commit is contained in:
Edison Su 2013-06-14 15:55:44 -07:00
parent 0acce2c518
commit a715eb8121
109 changed files with 1219 additions and 2246 deletions

View File

@ -82,6 +82,7 @@ public class AgentShell implements IAgentShell, Daemon {
private int _pingRetries; private int _pingRetries;
private final List<Agent> _agents = new ArrayList<Agent>(); private final List<Agent> _agents = new ArrayList<Agent>();
public AgentShell() { public AgentShell() {
} }

View File

@ -58,7 +58,7 @@ public interface StoragePool extends Identity, InternalIdentity {
/** /**
* @return available storage in bytes * @return available storage in bytes
*/ */
long getAvailableBytes(); long getUsedBytes();
Long getClusterId(); Long getClusterId();

View File

@ -815,6 +815,7 @@
<bean id="swiftImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.SwiftImageStoreProviderImpl" /> <bean id="swiftImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.SwiftImageStoreProviderImpl" />
<bean id="ApplicationLoadBalancerService" class="org.apache.cloudstack.network.lb.ApplicationLoadBalancerManagerImpl" /> <bean id="ApplicationLoadBalancerService" class="org.apache.cloudstack.network.lb.ApplicationLoadBalancerManagerImpl" />
<bean id="InternalLoadBalancerVMManager" class="org.apache.cloudstack.network.lb.InternalLoadBalancerVMManagerImpl" /> <bean id="InternalLoadBalancerVMManager" class="org.apache.cloudstack.network.lb.InternalLoadBalancerVMManagerImpl" />
<bean id="StorageCacheReplacementAlgorithm" class="org.apache.cloudstack.storage.cache.manager.StorageCacheReplacementAlgorithmLRU" />
<!--=======================================================================================================--> <!--=======================================================================================================-->

View File

@ -132,6 +132,10 @@ under the License.
<priority value="INFO"/> <priority value="INFO"/>
</category> </category>
<category name="org.apache.cloudstack">
<priority value="DEBUG"/>
</category>
<category name="org.apache.cloudstack.api.command"> <category name="org.apache.cloudstack.api.command">
<priority value="TRACE"/> <priority value="TRACE"/>
</category> </category>

View File

@ -83,7 +83,7 @@ public class BackupSnapshotCommandTest {
}; };
@Override @Override
public long getAvailableBytes() { public long getUsedBytes() {
return 0L; return 0L;
}; };

View File

@ -16,9 +16,15 @@
// under the License. // under the License.
package org.apache.cloudstack.api.agent.test; package org.apache.cloudstack.api.agent.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import com.cloud.agent.api.storage.ResizeVolumeCommand;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.storage.Storage;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolStatus;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
@ -26,6 +32,10 @@ import org.mockito.Mockito;
import com.cloud.agent.api.CheckNetworkAnswer; import com.cloud.agent.api.CheckNetworkAnswer;
import com.cloud.agent.api.CheckNetworkCommand; import com.cloud.agent.api.CheckNetworkCommand;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class CheckNetworkAnswerTest { public class CheckNetworkAnswerTest {
CheckNetworkCommand cnc; CheckNetworkCommand cnc;
CheckNetworkAnswer cna; CheckNetworkAnswer cna;
@ -59,4 +69,199 @@ public class CheckNetworkAnswerTest {
boolean b = cna.executeInSequence(); boolean b = cna.executeInSequence();
assertFalse(b); assertFalse(b);
} }
public static class ResizeVolumeCommandTest {
public StoragePool dummypool = new StoragePool() {
@Override
public long getId() {
return 1L;
};
@Override
public String getName() {
return "name";
};
@Override
public String getUuid() {
return "bed9f83e-cac3-11e1-ac8a-0050568b007e";
};
@Override
public Storage.StoragePoolType getPoolType() {
return Storage.StoragePoolType.Filesystem;
};
@Override
public Date getCreated() {
Date date = null;
try {
date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
.parse("01/01/1970 12:12:12");
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
@Override
public Date getUpdateTime() {
return new Date();
};
@Override
public long getDataCenterId() {
return 0L;
};
@Override
public long getCapacityBytes() {
return 0L;
};
@Override
public long getUsedBytes() {
return 0L;
};
@Override
public Long getClusterId() {
return 0L;
};
@Override
public String getHostAddress() {
return "hostAddress";
};
@Override
public String getPath() {
return "path";
};
@Override
public String getUserInfo() {
return "userInfo";
};
@Override
public boolean isShared() {
return false;
};
@Override
public boolean isLocal() {
return false;
};
@Override
public StoragePoolStatus getStatus() {
return StoragePoolStatus.Up;
};
@Override
public int getPort() {
return 25;
};
@Override
public Long getPodId() {
return 0L;
}
@Override
public String getStorageProviderName() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isInMaintenance() {
// TODO Auto-generated method stub
return false;
};
};
Long newSize = 4194304L;
Long currentSize = 1048576L;
ResizeVolumeCommand rv = new ResizeVolumeCommand("dummydiskpath",
new StorageFilerTO(dummypool), currentSize, newSize, false,
"vmName");
@Test
public void testExecuteInSequence() {
boolean b = rv.executeInSequence();
assertFalse(b);
}
@Test
public void testGetPath() {
String path = rv.getPath();
assertTrue(path.equals("dummydiskpath"));
}
@Test
public void testGetPoolUuid() {
String poolUuid = rv.getPoolUuid();
assertTrue(poolUuid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
}
@Test
public void testGetPool() {
StorageFilerTO pool = rv.getPool();
Long id = pool.getId();
Long expectedL = 1L;
assertEquals(expectedL, id);
String uuid = pool.getUuid();
assertTrue(uuid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
String host = pool.getHost();
assertTrue(host.equals("hostAddress"));
String path = pool.getPath();
assertTrue(path.equals("path"));
String userInfo = pool.getUserInfo();
assertTrue(userInfo.equals("userInfo"));
Integer port = pool.getPort();
Integer expectedI = 25;
assertEquals(expectedI, port);
Storage.StoragePoolType type = pool.getType();
assertEquals(Storage.StoragePoolType.Filesystem, type);
String str = pool.toString();
assertTrue(str.equals("Pool[" + id.toString() + "|" + host + ":"
+ port.toString() + "|" + path + "]"));
}
@Test
public void testGetNewSize() {
long newSize = rv.getNewSize();
assertTrue(newSize == 4194304L);
}
@Test
public void testGetCurrentSize() {
long currentSize = rv.getCurrentSize();
assertTrue(currentSize == 1048576L);
}
@Test
public void testGetShrinkOk() {
assertFalse(rv.getShrinkOk());
}
@Test
public void testGetInstanceName() {
String vmName = rv.getInstanceName();
assertTrue(vmName.equals("vmName"));
}
}
} }

View File

@ -74,7 +74,7 @@ public class SnapshotCommandTest {
return 0L; return 0L;
}; };
public long getAvailableBytes() { public long getUsedBytes() {
return 0L; return 0L;
}; };

View File

@ -1,229 +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 src.com.cloud.agent.api.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.junit.Test;
import com.cloud.agent.api.storage.ResizeVolumeCommand;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolStatus;
public class ResizeVolumeCommandTest {
public StoragePool dummypool = new StoragePool() {
@Override
public long getId() {
return 1L;
};
@Override
public String getName() {
return "name";
};
@Override
public String getUuid() {
return "bed9f83e-cac3-11e1-ac8a-0050568b007e";
};
@Override
public StoragePoolType getPoolType() {
return StoragePoolType.Filesystem;
};
@Override
public Date getCreated() {
Date date = null;
try {
date = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss")
.parse("01/01/1970 12:12:12");
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
@Override
public Date getUpdateTime() {
return new Date();
};
@Override
public long getDataCenterId() {
return 0L;
};
@Override
public long getCapacityBytes() {
return 0L;
};
@Override
public long getAvailableBytes() {
return 0L;
};
@Override
public Long getClusterId() {
return 0L;
};
@Override
public String getHostAddress() {
return "hostAddress";
};
@Override
public String getPath() {
return "path";
};
@Override
public String getUserInfo() {
return "userInfo";
};
@Override
public boolean isShared() {
return false;
};
@Override
public boolean isLocal() {
return false;
};
@Override
public StoragePoolStatus getStatus() {
return StoragePoolStatus.Up;
};
@Override
public int getPort() {
return 25;
};
@Override
public Long getPodId() {
return 0L;
}
@Override
public String getStorageProviderName() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isInMaintenance() {
// TODO Auto-generated method stub
return false;
};
};
Long newSize = 4194304L;
Long currentSize = 1048576L;
ResizeVolumeCommand rv = new ResizeVolumeCommand("dummydiskpath",
new StorageFilerTO(dummypool), currentSize, newSize, false,
"vmName");
@Test
public void testExecuteInSequence() {
boolean b = rv.executeInSequence();
assertFalse(b);
}
@Test
public void testGetPath() {
String path = rv.getPath();
assertTrue(path.equals("dummydiskpath"));
}
@Test
public void testGetPoolUuid() {
String poolUuid = rv.getPoolUuid();
assertTrue(poolUuid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
}
@Test
public void testGetPool() {
StorageFilerTO pool = rv.getPool();
Long id = pool.getId();
Long expectedL = 1L;
assertEquals(expectedL, id);
String uuid = pool.getUuid();
assertTrue(uuid.equals("bed9f83e-cac3-11e1-ac8a-0050568b007e"));
String host = pool.getHost();
assertTrue(host.equals("hostAddress"));
String path = pool.getPath();
assertTrue(path.equals("path"));
String userInfo = pool.getUserInfo();
assertTrue(userInfo.equals("userInfo"));
Integer port = pool.getPort();
Integer expectedI = 25;
assertEquals(expectedI, port);
StoragePoolType type = pool.getType();
assertEquals(StoragePoolType.Filesystem, type);
String str = pool.toString();
assertTrue(str.equals("Pool[" + id.toString() + "|" + host + ":"
+ port.toString() + "|" + path + "]"));
}
@Test
public void testGetNewSize() {
long newSize = rv.getNewSize();
assertTrue(newSize == 4194304L);
}
@Test
public void testGetCurrentSize() {
long currentSize = rv.getCurrentSize();
assertTrue(currentSize == 1048576L);
}
@Test
public void testGetShrinkOk() {
assertFalse(rv.getShrinkOk());
}
@Test
public void testGetInstanceName() {
String vmName = rv.getInstanceName();
assertTrue(vmName.equals("vmName"));
}
}

View File

@ -27,6 +27,7 @@ public class ClusterScope extends AbstractScope {
private Long zoneId; private Long zoneId;
public ClusterScope(Long clusterId, Long podId, Long zoneId) { public ClusterScope(Long clusterId, Long podId, Long zoneId) {
super();
this.clusterId = clusterId; this.clusterId = clusterId;
this.podId = podId; this.podId = podId;
this.zoneId = zoneId; this.zoneId = zoneId;

View File

@ -1,30 +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.engine.subsystem.api.storage;
import java.net.URI;
import com.cloud.org.Grouping;
public interface DataMigrationSubSystem {
Class<? extends Grouping> getScopeCoverage();
void migrate(URI source, URI dest, String reservationId);
}

View File

@ -26,9 +26,9 @@ import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.host.Host; import com.cloud.host.Host;
public interface DataMotionService { public interface DataMotionService {
public void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback); void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
public void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost,
AsyncCompletionCallback<CopyCommandResult> callback); AsyncCompletionCallback<CopyCommandResult> callback);
} }

View File

@ -26,13 +26,13 @@ import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.host.Host; import com.cloud.host.Host;
public interface DataMotionStrategy { public interface DataMotionStrategy {
public boolean canHandle(DataObject srcData, DataObject destData); boolean canHandle(DataObject srcData, DataObject destData);
public boolean canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost); boolean canHandle(Map<VolumeInfo, DataStore> volumeMap, Host srcHost, Host destHost);
public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback); Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
public Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost, Void copyAsync(Map<VolumeInfo, DataStore> volumeMap, VirtualMachineTO vmTo, Host srcHost, Host destHost,
AsyncCompletionCallback<CopyCommandResult> callback); AsyncCompletionCallback<CopyCommandResult> callback);
} }

View File

@ -23,24 +23,29 @@ import com.cloud.agent.api.to.DataObjectType;
import com.cloud.agent.api.to.DataTO; import com.cloud.agent.api.to.DataTO;
public interface DataObject { public interface DataObject {
public long getId(); long getId();
public String getUri(); String getUri();
public DataTO getTO(); DataTO getTO();
public DataStore getDataStore(); DataStore getDataStore();
public Long getSize(); Long getSize();
public DataObjectType getType(); DataObjectType getType();
// public DiskFormat getFormat(); String getUuid();
public String getUuid();
boolean delete(); boolean delete();
public void processEvent(ObjectInDataStoreStateMachine.Event event); void processEvent(ObjectInDataStoreStateMachine.Event event);
public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer); void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer);
void incRefCount();
void decRefCount();
Long getRefCount();
} }

View File

@ -21,13 +21,13 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
import com.cloud.utils.fsm.StateObject; import com.cloud.utils.fsm.StateObject;
public interface DataObjectInStore extends StateObject<ObjectInDataStoreStateMachine.State> { public interface DataObjectInStore extends StateObject<ObjectInDataStoreStateMachine.State> {
public String getInstallPath(); String getInstallPath();
public void setInstallPath(String path); void setInstallPath(String path);
public long getObjectId(); long getObjectId();
public long getDataStoreId(); long getDataStoreId();
public ObjectInDataStoreStateMachine.State getObjectInStoreState(); ObjectInDataStoreStateMachine.State getObjectInStoreState();
} }

View File

@ -18,32 +18,23 @@
*/ */
package org.apache.cloudstack.engine.subsystem.api.storage; package org.apache.cloudstack.engine.subsystem.api.storage;
import java.util.Set; import com.cloud.agent.api.to.DataStoreTO;
import com.cloud.agent.api.to.DataTO;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.command.CommandResult; import org.apache.cloudstack.storage.command.CommandResult;
import com.cloud.agent.api.to.DataStoreTO;
import com.cloud.agent.api.to.DataTO;
public interface DataStoreDriver { public interface DataStoreDriver {
public String grantAccess(DataObject data, EndPoint ep); void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
public boolean revokeAccess(DataObject data, EndPoint ep); void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback);
public Set<DataObject> listObjects(DataStore store); void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback); boolean canCopy(DataObject srcData, DataObject destData);
public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback); void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback); DataTO getTO(DataObject data);
public boolean canCopy(DataObject srcData, DataObject destData); DataStoreTO getStoreTO(DataStore store);
public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
public DataTO getTO(DataObject data);
public DataStoreTO getStoreTO(DataStore store);
} }

View File

@ -24,21 +24,17 @@ import com.cloud.agent.api.StoragePoolInfo;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
public interface DataStoreLifeCycle { public interface DataStoreLifeCycle {
public DataStore initialize(Map<String, Object> dsInfos); DataStore initialize(Map<String, Object> dsInfos);
public boolean attachCluster(DataStore store, ClusterScope scope); boolean attachCluster(DataStore store, ClusterScope scope);
public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo); boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo);
boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType); boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType);
public boolean dettach(); boolean maintain(DataStore store);
public boolean unmanaged(); boolean cancelMaintain(DataStore store);
public boolean maintain(DataStore store); boolean deleteDataStore(DataStore store);
public boolean cancelMaintain(DataStore store);
public boolean deleteDataStore(DataStore store);
} }

View File

@ -24,21 +24,17 @@ import java.util.Map;
import com.cloud.storage.DataStoreRole; import com.cloud.storage.DataStoreRole;
public interface DataStoreManager { public interface DataStoreManager {
public DataStore getDataStore(long storeId, DataStoreRole role); DataStore getDataStore(long storeId, DataStoreRole role);
public DataStore getPrimaryDataStore(long storeId); DataStore getPrimaryDataStore(long storeId);
public DataStore getDataStore(String uuid, DataStoreRole role); DataStore getDataStore(String uuid, DataStoreRole role);
public List<DataStore> getImageStoresByScope(ZoneScope scope); List<DataStore> getImageStoresByScope(ZoneScope scope);
public DataStore getImageStore(long zoneId); DataStore getImageStore(long zoneId);
public List<DataStore> getImageStoresByProvider(String provider); List<DataStore> getImageCacheStores(Scope scope);
public List<DataStore> getImageCacheStores(Scope scope); List<DataStore> listImageStores();
public DataStore registerDataStore(Map<String, String> params, String providerUuid);
public List<DataStore> listImageStores();
} }

View File

@ -23,27 +23,26 @@ import java.util.Set;
public interface DataStoreProvider { public interface DataStoreProvider {
// constants for provider names // constants for provider names
public static final String NFS_IMAGE = "NFS"; static final String NFS_IMAGE = "NFS";
public static final String S3_IMAGE = "S3"; static final String S3_IMAGE = "S3";
public static final String SWIFT_IMAGE = "Swift"; static final String SWIFT_IMAGE = "Swift";
public static final String SAMPLE_IMAGE = "Sample"; static final String SAMPLE_IMAGE = "Sample";
public static final String DEFAULT_PRIMARY = "DefaultPrimary"; static final String DEFAULT_PRIMARY = "DefaultPrimary";
public static enum DataStoreProviderType { static enum DataStoreProviderType {
PRIMARY, IMAGE, ImageCache PRIMARY, IMAGE, ImageCache
} }
public DataStoreLifeCycle getDataStoreLifeCycle(); DataStoreLifeCycle getDataStoreLifeCycle();
public DataStoreDriver getDataStoreDriver(); DataStoreDriver getDataStoreDriver();
public HypervisorHostListener getHostListener(); HypervisorHostListener getHostListener();
public String getName(); String getName();
public boolean configure(Map<String, Object> params); boolean configure(Map<String, Object> params);
public Set<DataStoreProviderType> getTypes();
Set<DataStoreProviderType> getTypes();
} }

View File

@ -24,14 +24,11 @@ import com.cloud.storage.DataStoreProviderApiService;
import com.cloud.utils.component.Manager; import com.cloud.utils.component.Manager;
public interface DataStoreProviderManager extends Manager, DataStoreProviderApiService { public interface DataStoreProviderManager extends Manager, DataStoreProviderApiService {
public DataStoreProvider getDataStoreProvider(String name); DataStoreProvider getDataStoreProvider(String name);
public DataStoreProvider getDefaultPrimaryDataStoreProvider(); DataStoreProvider getDefaultPrimaryDataStoreProvider();
public DataStoreProvider getDefaultImageDataStoreProvider(); DataStoreProvider getDefaultImageDataStoreProvider();
public DataStoreProvider getDefaultCacheDataStoreProvider();
public List<DataStoreProvider> getDataStoreProviders();
DataStoreProvider getDefaultCacheDataStoreProvider();
} }

View File

@ -22,13 +22,13 @@ import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command; import com.cloud.agent.api.Command;
public interface EndPoint { public interface EndPoint {
public long getId(); long getId();
public String getHostAddr(); String getHostAddr();
public String getPublicAddr(); String getPublicAddr();
public Answer sendMessage(Command cmd); Answer sendMessage(Command cmd);
public void sendMessageAsync(Command cmd, AsyncCompletionCallback<Answer> callback); void sendMessageAsync(Command cmd, AsyncCompletionCallback<Answer> callback);
} }

View File

@ -21,19 +21,11 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
import java.util.List; import java.util.List;
public interface EndPointSelector { public interface EndPointSelector {
public EndPoint select(DataObject srcData, DataObject destData); EndPoint select(DataObject srcData, DataObject destData);
/**
* @param object
* @return
*/
EndPoint select(DataObject object); EndPoint select(DataObject object);
EndPoint select(DataStore store); EndPoint select(DataStore store);
/**
* @param store
* @return
*/
List<EndPoint> selectAll(DataStore store); List<EndPoint> selectAll(DataStore store);
} }

View File

@ -25,6 +25,7 @@ public class HostScope extends AbstractScope {
private Long zoneId; private Long zoneId;
public HostScope(Long hostId, Long zoneId) { public HostScope(Long hostId, Long zoneId) {
super();
this.hostId = hostId; this.hostId = hostId;
this.zoneId = zoneId; this.zoneId = zoneId;
} }

View File

@ -22,7 +22,7 @@ import com.cloud.storage.ScopeType;
public interface ImageStoreProvider extends DataStoreProvider { public interface ImageStoreProvider extends DataStoreProvider {
public boolean isScopeSupported(ScopeType scope); boolean isScopeSupported(ScopeType scope);
public boolean needDownloadSysTemplate(); boolean needDownloadSysTemplate();
} }

View File

@ -22,7 +22,7 @@ import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.command.CommandResult; import org.apache.cloudstack.storage.command.CommandResult;
public interface PrimaryDataStoreDriver extends DataStoreDriver { public interface PrimaryDataStoreDriver extends DataStoreDriver {
public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback); void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCmdResult> callback);
public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback); void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback);
} }

View File

@ -25,15 +25,15 @@ import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePool;
public interface PrimaryDataStoreInfo extends StoragePool { public interface PrimaryDataStoreInfo extends StoragePool {
public boolean isHypervisorSupported(HypervisorType hypervisor); boolean isHypervisorSupported(HypervisorType hypervisor);
public boolean isLocalStorageSupported(); boolean isLocalStorageSupported();
public boolean isVolumeDiskTypeSupported(DiskFormat diskType); boolean isVolumeDiskTypeSupported(DiskFormat diskType);
public String getUuid(); String getUuid();
public StoragePoolType getPoolType(); StoragePoolType getPoolType();
public PrimaryDataStoreLifeCycle getLifeCycle(); PrimaryDataStoreLifeCycle getLifeCycle();
} }

View File

@ -21,9 +21,9 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
import com.cloud.storage.ScopeType; import com.cloud.storage.ScopeType;
public interface Scope { public interface Scope {
public ScopeType getScopeType(); ScopeType getScopeType();
public boolean isSameScope(Scope scope); boolean isSameScope(Scope scope);
public Long getScopeId(); Long getScopeId();
} }

View File

@ -21,9 +21,9 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
import com.cloud.storage.DataStoreRole; import com.cloud.storage.DataStoreRole;
public interface SnapshotDataFactory { public interface SnapshotDataFactory {
public SnapshotInfo getSnapshot(long snapshotId, DataStore store); SnapshotInfo getSnapshot(long snapshotId, DataStore store);
public SnapshotInfo getSnapshot(DataObject obj, DataStore store); SnapshotInfo getSnapshot(DataObject obj, DataStore store);
public SnapshotInfo getSnapshot(long snapshotId, DataStoreRole role); SnapshotInfo getSnapshot(long snapshotId, DataStoreRole role);
} }

View File

@ -19,15 +19,15 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
import com.cloud.storage.Snapshot; import com.cloud.storage.Snapshot;
public interface SnapshotInfo extends DataObject, Snapshot { public interface SnapshotInfo extends DataObject, Snapshot {
public SnapshotInfo getParent(); SnapshotInfo getParent();
public String getPath(); String getPath();
public SnapshotInfo getChild(); SnapshotInfo getChild();
public VolumeInfo getBaseVolume(); VolumeInfo getBaseVolume();
public void addPayload(Object data); void addPayload(Object data);
Long getDataCenterId(); Long getDataCenterId();

View File

@ -18,11 +18,11 @@
package org.apache.cloudstack.engine.subsystem.api.storage; package org.apache.cloudstack.engine.subsystem.api.storage;
public interface SnapshotService { public interface SnapshotService {
public SnapshotResult takeSnapshot(SnapshotInfo snapshot); SnapshotResult takeSnapshot(SnapshotInfo snapshot);
public SnapshotInfo backupSnapshot(SnapshotInfo snapshot); SnapshotInfo backupSnapshot(SnapshotInfo snapshot);
public boolean deleteSnapshot(SnapshotInfo snapshot); boolean deleteSnapshot(SnapshotInfo snapshot);
public boolean revertSnapshot(SnapshotInfo snapshot); boolean revertSnapshot(SnapshotInfo snapshot);
} }

View File

@ -19,15 +19,11 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
import com.cloud.storage.Snapshot; import com.cloud.storage.Snapshot;
public interface SnapshotStrategy { public interface SnapshotStrategy {
public SnapshotInfo takeSnapshot(SnapshotInfo snapshot); SnapshotInfo takeSnapshot(SnapshotInfo snapshot);
public SnapshotInfo backupSnapshot(SnapshotInfo snapshot); SnapshotInfo backupSnapshot(SnapshotInfo snapshot);
public boolean deleteSnapshot(Long snapshotId); boolean deleteSnapshot(Long snapshotId);
/**
* @param snapshot
* @return
*/
boolean canHandle(Snapshot snapshot); boolean canHandle(Snapshot snapshot);
} }

View File

@ -19,9 +19,9 @@
package org.apache.cloudstack.engine.subsystem.api.storage; package org.apache.cloudstack.engine.subsystem.api.storage;
public interface StorageCacheManager { public interface StorageCacheManager {
public DataStore getCacheStorage(Scope scope); DataStore getCacheStorage(Scope scope);
public DataObject createCacheObject(DataObject data, Scope scope); DataObject createCacheObject(DataObject data, Scope scope);
/** /**
* only create cache object in db * only create cache object in db
@ -33,4 +33,8 @@ public interface StorageCacheManager {
DataObject getCacheObject(DataObject data, Scope scope); DataObject getCacheObject(DataObject data, Scope scope);
boolean deleteCacheObject(DataObject data); boolean deleteCacheObject(DataObject data);
boolean releaseCacheObject(DataObject data);
DataObject createCacheObject(DataObject data, DataStore store);
} }

View File

@ -1,76 +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.engine.subsystem.api.storage;
import java.util.List;
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
import com.cloud.deploy.DeploymentPlan;
public interface StorageOrchestrator {
/**
* Prepares all storage ready for a VM to start
*
* @param vm
* @param reservationId
*/
void prepare(long vmId, DeploymentPlan plan, String reservationId);
/**
* Releases all storage that were used for a VM shutdown
*
* @param vm
* @param disks
* @param reservationId
*/
void release(long vmId, String reservationId);
/**
* Destroy all disks
*
* @param disks
* @param reservationId
*/
void destroy(List<Long> disks, String reservationId);
/**
* Cancel a reservation
*
* @param reservationId
* reservation to
*/
void cancel(String reservationId);
/**
* If attaching a volume in allocated state to a running vm, need to create
* this volume
*/
void prepareAttachDiskToVM(long diskId, long vmId, String reservationId);
boolean createVolume(VolumeEntity volume, long dataStoreId, DiskFormat diskType);
boolean createVolumeFromTemplate(VolumeEntity volume, long dataStoreId, DiskFormat dis, TemplateEntity template);
VolumeEntity allocateVolumeInDb(long size, VolumeType type, String volName, Long templateId);
}

View File

@ -47,5 +47,5 @@ public interface StoragePoolAllocator extends Adapter {
List<StoragePool> allocateToPool(DiskProfile dskCh, VirtualMachineProfile<? extends VirtualMachine> vmProfile, List<StoragePool> allocateToPool(DiskProfile dskCh, VirtualMachineProfile<? extends VirtualMachine> vmProfile,
DeploymentPlan plan, ExcludeList avoid, int returnUpTo); DeploymentPlan plan, ExcludeList avoid, int returnUpTo);
public static int RETURN_UPTO_ALL = -1; static int RETURN_UPTO_ALL = -1;
} }

View File

@ -1,31 +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.engine.subsystem.api.storage;
import java.net.URI;
import com.cloud.org.Grouping;
public interface StorageSubSystem {
String getType();
Class<? extends Grouping> getScope();
URI grantAccess(String vol, String reservationId);
URI RemoveAccess(String vol, String reservationId);
}

View File

@ -21,7 +21,7 @@ package org.apache.cloudstack.engine.subsystem.api.storage;
import com.cloud.template.VirtualMachineTemplate; import com.cloud.template.VirtualMachineTemplate;
public interface TemplateInfo extends DataObject, VirtualMachineTemplate { public interface TemplateInfo extends DataObject, VirtualMachineTemplate {
public String getUniqueName(); String getUniqueName();
public String getInstallPath(); String getInstallPath();
} }

View File

@ -1,312 +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.engine.subsystem.api.storage;
import java.util.Map;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.template.VirtualMachineTemplate;
public class TemplateProfile {
Long userId;
String name;
String displayText;
Integer bits;
Boolean passwordEnabled;
Boolean sshKeyEnbaled;
Boolean requiresHvm;
String url;
Boolean isPublic;
Boolean featured;
Boolean isExtractable;
ImageFormat format;
Long guestOsId;
Long zoneId;
HypervisorType hypervisorType;
String accountName;
Long domainId;
Long accountId;
String chksum;
Boolean bootable;
Long templateId;
VirtualMachineTemplate template;
String templateTag;
Map details;
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits,
Boolean passwordEnabled, Boolean requiresHvm, String url, Boolean isPublic, Boolean featured,
Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId, HypervisorType hypervisorType,
String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, Map details,
Boolean sshKeyEnabled) {
this.templateId = templateId;
this.userId = userId;
this.name = name;
this.displayText = displayText;
this.bits = bits;
this.passwordEnabled = passwordEnabled;
this.requiresHvm = requiresHvm;
this.url = url;
this.isPublic = isPublic;
this.featured = featured;
this.isExtractable = isExtractable;
this.format = format;
this.guestOsId = guestOsId;
this.zoneId = zoneId;
this.hypervisorType = hypervisorType;
this.accountName = accountName;
this.domainId = domainId;
this.accountId = accountId;
this.chksum = chksum;
this.bootable = bootable;
this.details = details;
this.sshKeyEnbaled = sshKeyEnabled;
}
public TemplateProfile(Long userId, VirtualMachineTemplate template, Long zoneId) {
this.userId = userId;
this.template = template;
this.zoneId = zoneId;
}
public TemplateProfile(Long templateId, Long userId, String name, String displayText, Integer bits,
Boolean passwordEnabled, Boolean requiresHvm, String url, Boolean isPublic, Boolean featured,
Boolean isExtractable, ImageFormat format, Long guestOsId, Long zoneId, HypervisorType hypervisorType,
String accountName, Long domainId, Long accountId, String chksum, Boolean bootable, String templateTag,
Map details, Boolean sshKeyEnabled) {
this(templateId, userId, name, displayText, bits, passwordEnabled, requiresHvm, url, isPublic, featured,
isExtractable, format, guestOsId, zoneId, hypervisorType, accountName, domainId, accountId, chksum,
bootable, details, sshKeyEnabled);
this.templateTag = templateTag;
}
public Long getTemplateId() {
return templateId;
}
public void setTemplateId(Long id) {
this.templateId = id;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDisplayText() {
return displayText;
}
public void setDisplayText(String text) {
this.displayText = text;
}
public Integer getBits() {
return bits;
}
public void setBits(Integer bits) {
this.bits = bits;
}
public Boolean getPasswordEnabled() {
return passwordEnabled;
}
public void setPasswordEnabled(Boolean enabled) {
this.passwordEnabled = enabled;
}
public Boolean getRequiresHVM() {
return requiresHvm;
}
public void setRequiresHVM(Boolean hvm) {
this.requiresHvm = hvm;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Boolean getIsPublic() {
return isPublic;
}
public void setIsPublic(Boolean is) {
this.isPublic = is;
}
public Boolean getFeatured() {
return featured;
}
public void setFeatured(Boolean featured) {
this.featured = featured;
}
public Boolean getIsExtractable() {
return isExtractable;
}
public void setIsExtractable(Boolean is) {
this.isExtractable = is;
}
public ImageFormat getFormat() {
return format;
}
public void setFormat(ImageFormat format) {
this.format = format;
}
public Long getGuestOsId() {
return guestOsId;
}
public void setGuestOsId(Long id) {
this.guestOsId = id;
}
public Long getZoneId() {
return zoneId;
}
public void setZoneId(Long id) {
this.zoneId = id;
}
public HypervisorType getHypervisorType() {
return hypervisorType;
}
public void setHypervisorType(HypervisorType type) {
this.hypervisorType = type;
}
public Long getDomainId() {
return domainId;
}
public void setDomainId(Long id) {
this.domainId = id;
}
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long id) {
this.accountId = id;
}
public String getCheckSum() {
return chksum;
}
public void setCheckSum(String chksum) {
this.chksum = chksum;
}
public Boolean getBootable() {
return this.bootable;
}
public void setBootable(Boolean bootable) {
this.bootable = bootable;
}
public VirtualMachineTemplate getTemplate() {
return template;
}
public void setTemplate(VirtualMachineTemplate template) {
this.template = template;
}
public String getTemplateTag() {
return templateTag;
}
public void setTemplateTag(String templateTag) {
this.templateTag = templateTag;
}
public Map getDetails() {
return this.details;
}
public void setDetails(Map details) {
this.details = details;
}
public void setSshKeyEnabled(Boolean enabled) {
this.sshKeyEnbaled = enabled;
}
public Boolean getSshKeyEnabled() {
return this.sshKeyEnbaled;
}
public String getImageStorageUri() {
return null;
}
public void setLocalPath(String path) {
}
public String getLocalPath() {
return null;
}
public String getJobId() {
return null;
}
public void setTemplatePoolRefId(long id) {
}
public long getId() {
return 0;
}
public long getTemplatePoolRefId() {
return 0;
}
public long getSize() {
return 0;
}
}

View File

@ -27,7 +27,7 @@ import com.cloud.storage.StoragePool;
public interface TemplateService { public interface TemplateService {
public class TemplateApiResult extends CommandResult { class TemplateApiResult extends CommandResult {
private final TemplateInfo template; private final TemplateInfo template;
public TemplateApiResult(TemplateInfo template) { public TemplateApiResult(TemplateInfo template) {

View File

@ -23,21 +23,21 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.Volume; import com.cloud.storage.Volume;
public interface VolumeInfo extends DataObject, Volume { public interface VolumeInfo extends DataObject, Volume {
public boolean isAttachedVM(); boolean isAttachedVM();
public void addPayload(Object data); void addPayload(Object data);
public Object getpayload(); Object getpayload();
public HypervisorType getHypervisorType(); HypervisorType getHypervisorType();
public Long getLastPoolId(); Long getLastPoolId();
public String getAttachedVmName(); String getAttachedVmName();
public void processEventOnly(ObjectInDataStoreStateMachine.Event event); void processEventOnly(ObjectInDataStoreStateMachine.Event event);
public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer answer); void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer answer);
public boolean stateTransit(Volume.Event event); boolean stateTransit(Volume.Event event);
} }

View File

@ -1,35 +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.engine.subsystem.api.storage;
public class VolumeProfile {
private String _uri;
public String getURI() {
return _uri;
}
public String getPath() {
return null;
}
public long getSize() {
return 0;
}
}

View File

@ -29,8 +29,7 @@ import com.cloud.exception.ConcurrentOperationException;
import com.cloud.host.Host; import com.cloud.host.Host;
public interface VolumeService { public interface VolumeService {
class VolumeApiResult extends CommandResult {
public class VolumeApiResult extends CommandResult {
private final VolumeInfo volume; private final VolumeInfo volume;
public VolumeApiResult(VolumeInfo volume) { public VolumeApiResult(VolumeInfo volume) {

View File

@ -25,6 +25,7 @@ public class ZoneScope extends AbstractScope {
private Long zoneId; private Long zoneId;
public ZoneScope(Long zoneId) { public ZoneScope(Long zoneId) {
super();
this.zoneId = zoneId; this.zoneId = zoneId;
} }

View File

@ -35,7 +35,6 @@ public final class CreateObjectCommand extends Command implements StorageSubSyst
@Override @Override
public boolean executeInSequence() { public boolean executeInSequence() {
// TODO Auto-generated method stub
return false; return false;
} }

View File

@ -25,13 +25,13 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
public interface ImageStoreDao extends GenericDao<ImageStoreVO, Long> { public interface ImageStoreDao extends GenericDao<ImageStoreVO, Long> {
public ImageStoreVO findByName(String name); ImageStoreVO findByName(String name);
public List<ImageStoreVO> findByProvider(String provider); List<ImageStoreVO> findByProvider(String provider);
public List<ImageStoreVO> findByScope(ZoneScope scope); List<ImageStoreVO> findByScope(ZoneScope scope);
public List<ImageStoreVO> findImageCacheByScope(ZoneScope scope); List<ImageStoreVO> findImageCacheByScope(ZoneScope scope);
public List<ImageStoreVO> listImageStores(); List<ImageStoreVO> listImageStores();
} }

View File

@ -80,6 +80,9 @@ public class ImageStoreVO implements ImageStore {
@Column(name = "total_size") @Column(name = "total_size")
private Long totalSize; private Long totalSize;
@Column(name = "used_bytes")
private Long usedBytes;
public DataStoreRole getRole() { public DataStoreRole getRole() {
return role; return role;
} }
@ -180,4 +183,11 @@ public class ImageStoreVO implements ImageStore {
this.totalSize = totalSize; this.totalSize = totalSize;
} }
public Long getUsedBytes() {
return usedBytes;
}
public void setUsedBytes(Long usedBytes) {
this.usedBytes = usedBytes;
}
} }

View File

@ -147,7 +147,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long>
@Override @Override
public void updateAvailable(long id, long available) { public void updateAvailable(long id, long available) {
StoragePoolVO pool = createForUpdate(id); StoragePoolVO pool = createForUpdate(id);
pool.setAvailableBytes(available); pool.setUsedBytes(available);
update(id, pool); update(id, pool);
} }

View File

@ -28,13 +28,13 @@ import com.cloud.utils.fsm.StateDao;
public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO, Long>, public interface SnapshotDataStoreDao extends GenericDao<SnapshotDataStoreVO, Long>,
StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> { StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
public List<SnapshotDataStoreVO> listByStoreId(long id, DataStoreRole role); List<SnapshotDataStoreVO> listByStoreId(long id, DataStoreRole role);
public void deletePrimaryRecordsForStore(long id); void deletePrimaryRecordsForStore(long id);
public SnapshotDataStoreVO findByStoreSnapshot(DataStoreRole role, long storeId, long snapshotId); SnapshotDataStoreVO findByStoreSnapshot(DataStoreRole role, long storeId, long snapshotId);
public SnapshotDataStoreVO findBySnapshot(long snapshotId, DataStoreRole role); SnapshotDataStoreVO findBySnapshot(long snapshotId, DataStoreRole role);
public List<SnapshotDataStoreVO> listDestroyed(long storeId); List<SnapshotDataStoreVO> listDestroyed(long storeId);
} }

View File

@ -92,6 +92,9 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
ObjectInDataStoreStateMachine.State state; ObjectInDataStoreStateMachine.State state;
@Column(name = "ref_cnt")
Long refCnt;
public String getInstallPath() { public String getInstallPath() {
return installPath; return installPath;
} }
@ -242,4 +245,16 @@ public class SnapshotDataStoreVO implements StateObject<ObjectInDataStoreStateMa
public void setParentSnapshotId(long parentSnapshotId) { public void setParentSnapshotId(long parentSnapshotId) {
this.parentSnapshotId = parentSnapshotId; this.parentSnapshotId = parentSnapshotId;
} }
public Long getRefCnt() {
return refCnt;
}
public void incrRefCnt() {
this.refCnt++;
}
public void decrRefCnt() {
this.refCnt--;
}
} }

View File

@ -71,8 +71,8 @@ public class StoragePoolVO implements StoragePool {
@Column(name = "pod_id", updatable = true) @Column(name = "pod_id", updatable = true)
private Long podId; private Long podId;
@Column(name = "available_bytes", updatable = true, nullable = true) @Column(name = "used_bytes", updatable = true, nullable = true)
private long availableBytes; private long usedBytes;
@Column(name = "capacity_bytes", updatable = true, nullable = true) @Column(name = "capacity_bytes", updatable = true, nullable = true)
private long capacityBytes; private long capacityBytes;
@ -126,7 +126,7 @@ public class StoragePoolVO implements StoragePool {
this.uuid = uuid; this.uuid = uuid;
this.poolType = type; this.poolType = type;
this.dataCenterId = dataCenterId; this.dataCenterId = dataCenterId;
this.availableBytes = availableBytes; this.usedBytes = availableBytes;
this.capacityBytes = capacityBytes; this.capacityBytes = capacityBytes;
this.hostAddress = hostAddress; this.hostAddress = hostAddress;
this.path = hostPath; this.path = hostPath;
@ -136,7 +136,7 @@ public class StoragePoolVO implements StoragePool {
} }
public StoragePoolVO(StoragePoolVO that) { public StoragePoolVO(StoragePoolVO that) {
this(that.id, that.name, that.uuid, that.poolType, that.dataCenterId, that.podId, that.availableBytes, this(that.id, that.name, that.uuid, that.poolType, that.dataCenterId, that.podId, that.usedBytes,
that.capacityBytes, that.hostAddress, that.port, that.path); that.capacityBytes, that.hostAddress, that.port, that.path);
} }
@ -181,8 +181,8 @@ public class StoragePoolVO implements StoragePool {
return dataCenterId; return dataCenterId;
} }
public long getAvailableBytes() { public long getUsedBytes() {
return availableBytes; return usedBytes;
} }
public String getStorageProviderName() { public String getStorageProviderName() {
@ -197,8 +197,8 @@ public class StoragePoolVO implements StoragePool {
return capacityBytes; return capacityBytes;
} }
public void setAvailableBytes(long available) { public void setUsedBytes(long available) {
availableBytes = available; usedBytes = available;
} }
public void setCapacityBytes(long capacity) { public void setCapacityBytes(long capacity) {

View File

@ -30,13 +30,13 @@ import com.cloud.utils.fsm.StateDao;
public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Long>, public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Long>,
StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> { StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
public List<TemplateDataStoreVO> listByStoreId(long id); List<TemplateDataStoreVO> listByStoreId(long id);
public List<TemplateDataStoreVO> listDestroyed(long storeId); List<TemplateDataStoreVO> listDestroyed(long storeId);
public void deletePrimaryRecordsForStore(long id); void deletePrimaryRecordsForStore(long id);
public void deletePrimaryRecordsForTemplate(long templateId); void deletePrimaryRecordsForTemplate(long templateId);
List<TemplateDataStoreVO> listByTemplateStore(long templateId, long storeId); List<TemplateDataStoreVO> listByTemplateStore(long templateId, long storeId);

View File

@ -71,7 +71,7 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
private int downloadPercent; private int downloadPercent;
@Column(name = "size") @Column(name = "size")
private long size; private Long size;
@Column(name = "physical_size") @Column(name = "physical_size")
private long physicalSize; private long physicalSize;
@ -112,11 +112,15 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
ObjectInDataStoreStateMachine.State state; ObjectInDataStoreStateMachine.State state;
@Column(name = "ref_cnt")
Long refCnt;
public TemplateDataStoreVO(Long hostId, long templateId) { public TemplateDataStoreVO(Long hostId, long templateId) {
super(); super();
this.dataStoreId = hostId; this.dataStoreId = hostId;
this.templateId = templateId; this.templateId = templateId;
this.state = ObjectInDataStoreStateMachine.State.Allocated; this.state = ObjectInDataStoreStateMachine.State.Allocated;
this.refCnt = 0L;
} }
public TemplateDataStoreVO(Long hostId, long templateId, Date lastUpdated, int downloadPercent, public TemplateDataStoreVO(Long hostId, long templateId, Date lastUpdated, int downloadPercent,
@ -131,6 +135,7 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
this.localDownloadPath = localDownloadPath; this.localDownloadPath = localDownloadPath;
this.errorString = errorString; this.errorString = errorString;
this.jobId = jobId; this.jobId = jobId;
this.refCnt = 0L;
this.installPath = installPath; this.installPath = installPath;
this.setDownloadUrl(downloadUrl); this.setDownloadUrl(downloadUrl);
switch (downloadState) { switch (downloadState) {
@ -156,7 +161,7 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
} }
public TemplateDataStoreVO() { public TemplateDataStoreVO() {
this.refCnt = 0L;
} }
@Override @Override
@ -352,4 +357,16 @@ public class TemplateDataStoreVO implements StateObject<ObjectInDataStoreStateMa
this.dataStoreRole = dataStoreRole; this.dataStoreRole = dataStoreRole;
} }
public Long getRefCnt() {
return refCnt;
}
public void incrRefCnt() {
this.refCnt++;
}
public void decrRefCnt() {
this.refCnt--;
}
} }

View File

@ -27,15 +27,15 @@ import com.cloud.utils.fsm.StateDao;
public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>, public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>,
StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> { StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Event, DataObjectInStore> {
public List<VolumeDataStoreVO> listByStoreId(long id); List<VolumeDataStoreVO> listByStoreId(long id);
public void deletePrimaryRecordsForStore(long id); void deletePrimaryRecordsForStore(long id);
public VolumeDataStoreVO findByVolume(long volumeId); VolumeDataStoreVO findByVolume(long volumeId);
public VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId); VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId);
public VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId, boolean lock); VolumeDataStoreVO findByStoreVolume(long storeId, long volumeId, boolean lock);
public List<VolumeDataStoreVO> listDestroyed(long storeId); List<VolumeDataStoreVO> listDestroyed(long storeId);
} }

View File

@ -111,6 +111,9 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
ObjectInDataStoreStateMachine.State state; ObjectInDataStoreStateMachine.State state;
@Column(name = "ref_cnt")
Long refCnt;
public String getInstallPath() { public String getInstallPath() {
return installPath; return installPath;
} }
@ -189,6 +192,7 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
this.dataStoreId = hostId; this.dataStoreId = hostId;
this.volumeId = volumeId; this.volumeId = volumeId;
this.state = ObjectInDataStoreStateMachine.State.Allocated; this.state = ObjectInDataStoreStateMachine.State.Allocated;
this.refCnt = 0L;
} }
public VolumeDataStoreVO(long hostId, long volumeId, Date lastUpdated, int downloadPercent, Status downloadState, public VolumeDataStoreVO(long hostId, long volumeId, Date lastUpdated, int downloadPercent, Status downloadState,
@ -207,10 +211,11 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
this.installPath = installPath; this.installPath = installPath;
this.setDownloadUrl(downloadUrl); this.setDownloadUrl(downloadUrl);
this.checksum = checksum; this.checksum = checksum;
this.refCnt = 0L;
} }
public VolumeDataStoreVO() { public VolumeDataStoreVO() {
this.refCnt = 0L;
} }
public void setLocalDownloadPath(String localPath) { public void setLocalDownloadPath(String localPath) {
@ -328,4 +333,16 @@ public class VolumeDataStoreVO implements StateObject<ObjectInDataStoreStateMach
return this.state; return this.state;
} }
public Long getRefCnt() {
return refCnt;
}
public void incrRefCnt() {
this.refCnt++;
}
public void decrRefCnt() {
this.refCnt--;
}
} }

View File

@ -21,7 +21,7 @@ package org.apache.cloudstack.storage.image.datastore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
public interface ImageStoreInfo extends DataStore { public interface ImageStoreInfo extends DataStore {
public long getImageStoreId(); long getImageStoreId();
public String getType(); String getType();
} }

View File

@ -46,9 +46,6 @@ public class ImageStoreTO implements DataStoreTO {
return this.uri; return this.uri;
} }
/**
* @return the providerName
*/
public String getProviderName() { public String getProviderName() {
return providerName; return providerName;
} }
@ -73,4 +70,10 @@ public class ImageStoreTO implements DataStoreTO {
public DataStoreRole getRole() { public DataStoreRole getRole() {
return this.role; return this.role;
} }
@Override
public String toString() {
return new StringBuilder("ImageStoreTO[type=").append(type).append("|provider=").append(providerName)
.append("|role=").append(role).append("|uri=").append(uri).append("]").toString();
}
} }

View File

@ -94,4 +94,10 @@ public class PrimaryDataStoreTO implements DataStoreTO {
public void setPort(int port) { public void setPort(int port) {
this.port = port; this.port = port;
} }
@Override
public String toString() {
return new StringBuilder("PrimaryDataStoreTO[uuid=").append(uuid).append("|name=").append(name)
.append("|id=").append(id).append("|pooltype=").append(poolType).append("]").toString();
}
} }

View File

@ -117,4 +117,10 @@ public class SnapshotObjectTO implements DataTO {
public void setHypervisorType(HypervisorType hypervisorType) { public void setHypervisorType(HypervisorType hypervisorType) {
this.hypervisorType = hypervisorType; this.hypervisorType = hypervisorType;
} }
@Override
public String toString() {
return new StringBuilder("SnapshotTO[datastore=").append(dataStore).append("|volume=").append(volume).append("|path")
.append(path).append("]").toString();
}
} }

View File

@ -190,4 +190,10 @@ public class TemplateObjectTO implements DataTO {
public void setSize(Long size) { public void setSize(Long size) {
this.size = size; this.size = size;
} }
@Override
public String toString() {
return new StringBuilder("TemplateTO[id=").append(id).append("|origUrl=").append(origUrl)
.append("|name").append(name).append("]").toString();
}
} }

View File

@ -166,4 +166,10 @@ public class VolumeObjectTO implements DataTO {
this.format = format; this.format = format;
} }
@Override
public String toString() {
return new StringBuilder("volumeTO[uuid=").append(uuid).append("|path=").append(path)
.append("|datastore=").append(dataStore).append("]").toString();
}
} }

View File

@ -18,32 +18,32 @@
*/ */
package org.apache.cloudstack.storage.cache.manager; package org.apache.cloudstack.storage.cache.manager;
import java.util.List; import com.cloud.configuration.Config;
import java.util.Map; import com.cloud.configuration.dao.ConfigurationDao;
import java.util.concurrent.ExecutionException; import com.cloud.storage.DataStoreRole;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.component.Manager;
import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.db.GlobalLock;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.SearchCriteria2;
import com.cloud.utils.db.SearchCriteriaService;
import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.cloudstack.engine.subsystem.api.storage.*;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.storage.cache.allocator.StorageCacheAllocator;
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
import org.apache.log4j.Logger;
import javax.inject.Inject; import javax.inject.Inject;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import java.util.*;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import java.util.concurrent.ExecutionException;
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService; import java.util.concurrent.Executors;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import java.util.concurrent.ScheduledExecutorService;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; import java.util.concurrent.TimeUnit;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
import org.apache.cloudstack.engine.subsystem.api.storage.StorageCacheManager;
import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext;
import org.apache.cloudstack.storage.cache.allocator.StorageCacheAllocator;
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
import org.apache.log4j.Logger;
import com.cloud.utils.component.Manager;
import com.cloud.utils.exception.CloudRuntimeException;
public class StorageCacheManagerImpl implements StorageCacheManager, Manager { public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
private static final Logger s_logger = Logger.getLogger(StorageCacheManagerImpl.class); private static final Logger s_logger = Logger.getLogger(StorageCacheManagerImpl.class);
@ -53,6 +53,16 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
DataMotionService dataMotionSvr; DataMotionService dataMotionSvr;
@Inject @Inject
ObjectInDataStoreManager objectInStoreMgr; ObjectInDataStoreManager objectInStoreMgr;
@Inject
DataStoreManager dataStoreManager;
@Inject
StorageCacheReplacementAlgorithm cacheReplacementAlgorithm;
@Inject
ConfigurationDao configDao;
Boolean cacheReplacementEnabled = Boolean.TRUE;
int workers;
ScheduledExecutorService executors;
int cacheReplaceMentInterval;
@Override @Override
public DataStore getCacheStorage(Scope scope) { public DataStore getCacheStorage(Scope scope) {
@ -65,6 +75,17 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
return null; return null;
} }
protected List<DataStore> getCacheStores() {
SearchCriteriaService<ImageStoreVO, ImageStoreVO> sc = SearchCriteria2.create(ImageStoreVO.class);
sc.addAnd(sc.getEntity().getRole(), SearchCriteria.Op.EQ, DataStoreRole.ImageCache);
List<ImageStoreVO> imageStoreVOs = sc.list();
List<DataStore> stores = new ArrayList<DataStore>();
for (ImageStoreVO vo : imageStoreVOs) {
stores.add(dataStoreManager.getDataStore(vo.getId(), vo.getRole()));
}
return stores;
}
@Override @Override
public String getName() { public String getName() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -103,12 +124,59 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
@Override @Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
// TODO Auto-generated method stub cacheReplacementEnabled = Boolean.parseBoolean(configDao.getValue(Config.StorageCacheReplacementEnabled.key()));
cacheReplaceMentInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementInterval.key()), 86400);
workers = NumbersUtil.parseInt(configDao.getValue(Config.ExpungeWorkers.key()), 10);
executors = Executors.newScheduledThreadPool(workers, new NamedThreadFactory("StorageCacheManager-cache-replacement"));
return true; return true;
} }
protected class CacheReplacementRunner implements Runnable {
@Override
public void run() {
GlobalLock replacementLock = null;
try {
replacementLock = GlobalLock.getInternLock("storageCacheMgr.replacement");
if (replacementLock.lock(3)) {
List<DataStore> stores = getCacheStores();
Collections.shuffle(stores);
DataObject object = null;
DataStore findAStore = null;
for (DataStore store : stores) {
object = cacheReplacementAlgorithm.chooseOneToBeReplaced(store);
findAStore = store;
if (object != null) {
break;
}
}
if (object == null) {
return;
}
while(object != null) {
object.delete();
object = cacheReplacementAlgorithm.chooseOneToBeReplaced(findAStore);
}
}
} catch (Exception e) {
s_logger.debug("Failed to execute CacheReplacementRunner: " + e.toString());
} finally {
if (replacementLock != null) {
replacementLock.unlock();
}
}
}
}
@Override @Override
public boolean start() { public boolean start() {
if (cacheReplacementEnabled) {
Random generator = new Random();
int initalDelay = generator.nextInt(cacheReplaceMentInterval);
executors.scheduleWithFixedDelay(new CacheReplacementRunner(), initalDelay, cacheReplaceMentInterval, TimeUnit.SECONDS);
}
return true; return true;
} }
@ -118,29 +186,17 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
return true; return true;
} }
private class CreateCacheObjectContext<T> extends AsyncRpcConext<T> {
final AsyncCallFuture<CopyCommandResult> future;
/**
* @param callback
*/
public CreateCacheObjectContext(AsyncCompletionCallback<T> callback, AsyncCallFuture<CopyCommandResult> future) {
super(callback);
this.future = future;
}
}
@Override @Override
public DataObject createCacheObject(DataObject data, Scope scope) { public DataObject createCacheObject(DataObject data, DataStore store) {
DataStore cacheStore = this.getCacheStorage(scope); DataObjectInStore obj = objectInStoreMgr.findObject(data, store);
DataObjectInStore obj = objectInStoreMgr.findObject(data, cacheStore);
if (obj != null && obj.getState() == ObjectInDataStoreStateMachine.State.Ready) { if (obj != null && obj.getState() == ObjectInDataStoreStateMachine.State.Ready) {
s_logger.debug("there is already one in the cache store"); s_logger.debug("there is already one in the cache store");
return objectInStoreMgr.get(data, cacheStore); DataObject dataObj = objectInStoreMgr.get(data, store);
dataObj.incRefCount();
return dataObj;
} }
DataObject objOnCacheStore = cacheStore.create(data); DataObject objOnCacheStore = store.create(data);
AsyncCallFuture<CopyCommandResult> future = new AsyncCallFuture<CopyCommandResult>(); AsyncCallFuture<CopyCommandResult> future = new AsyncCallFuture<CopyCommandResult>();
CopyCommandResult result = null; CopyCommandResult result = null;
@ -154,6 +210,7 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
objOnCacheStore.processEvent(Event.OperationFailed); objOnCacheStore.processEvent(Event.OperationFailed);
} else { } else {
objOnCacheStore.processEvent(Event.OperationSuccessed, result.getAnswer()); objOnCacheStore.processEvent(Event.OperationSuccessed, result.getAnswer());
objOnCacheStore.incRefCount();
return objOnCacheStore; return objOnCacheStore;
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -167,28 +224,31 @@ public class StorageCacheManagerImpl implements StorageCacheManager, Manager {
objOnCacheStore.processEvent(Event.OperationFailed); objOnCacheStore.processEvent(Event.OperationFailed);
} }
} }
return null; return null;
} }
@Override
public DataObject createCacheObject(DataObject data, Scope scope) {
DataStore cacheStore = this.getCacheStorage(scope);
return this.createCacheObject(data, cacheStore);
}
@Override @Override
public DataObject getCacheObject(DataObject data, Scope scope) { public DataObject getCacheObject(DataObject data, Scope scope) {
DataStore cacheStore = this.getCacheStorage(scope); DataStore cacheStore = this.getCacheStorage(scope);
DataObject objOnCacheStore = cacheStore.create(data); DataObject objOnCacheStore = cacheStore.create(data);
objOnCacheStore.incRefCount();
return objOnCacheStore; return objOnCacheStore;
} }
protected Void createCacheObjectCallBack( @Override
AsyncCallbackDispatcher<StorageCacheManagerImpl, CopyCommandResult> callback, public boolean releaseCacheObject(DataObject data) {
CreateCacheObjectContext<CopyCommandResult> context) { data.decRefCount();
AsyncCallFuture<CopyCommandResult> future = context.future; return true;
future.complete(callback.getResult());
return null;
} }
@Override @Override
public boolean deleteCacheObject(DataObject data) { public boolean deleteCacheObject(DataObject data) {
return objectInStoreMgr.delete(data); return data.getDataStore().delete(data);
} }
} }

View File

@ -16,10 +16,11 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.apache.cloudstack.storage.motion; package org.apache.cloudstack.storage.cache.manager;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
public interface DataMotionDriver { public interface StorageCacheReplacementAlgorithm {
public void copy(DataObject srcObj, DataObject destObj); DataObject chooseOneToBeReplaced(DataStore store);
} }

View File

@ -0,0 +1,106 @@
/*
* 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.cache.manager;
import com.cloud.configuration.Config;
import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.utils.DateUtil;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.SearchCriteria2;
import com.cloud.utils.db.SearchCriteriaService;
import org.apache.cloudstack.engine.subsystem.api.storage.*;
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
import org.apache.commons.lang.math.NumberUtils;
import java.util.Calendar;
import java.util.Date;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
public class StorageCacheReplacementAlgorithmLRU implements StorageCacheReplacementAlgorithm {
@Inject
ConfigurationDao configDao;
@Inject
TemplateDataFactory templateFactory;
@Inject
VolumeDataFactory volumeFactory;
@Inject
SnapshotDataFactory snapshotFactory;
Integer unusedTimeInterval;
public StorageCacheReplacementAlgorithmLRU() {
}
@PostConstruct
public void initialize() {
unusedTimeInterval = NumbersUtil.parseInt(configDao.getValue(Config.StorageCacheReplacementLRUTimeInterval.key()), 30);
}
public void setUnusedTimeInterval(Integer interval) {
unusedTimeInterval = interval;
}
@Override
public DataObject chooseOneToBeReplaced(DataStore store) {
Calendar cal = Calendar.getInstance();
cal.setTime(DateUtil.now());
cal.add(Calendar.DAY_OF_MONTH, -unusedTimeInterval.intValue());
Date bef = cal.getTime();
SearchCriteriaService<TemplateDataStoreVO, TemplateDataStoreVO> sc = SearchCriteria2.create(TemplateDataStoreVO.class);
sc.addAnd(sc.getEntity().getLastUpdated(), SearchCriteria.Op.LT, bef);
sc.addAnd(sc.getEntity().getState(), SearchCriteria.Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
sc.addAnd(sc.getEntity().getDataStoreId(), SearchCriteria.Op.EQ, store.getId());
sc.addAnd(sc.getEntity().getDataStoreRole(), SearchCriteria.Op.EQ, store.getRole());
sc.addAnd(sc.getEntity().getRefCnt(), SearchCriteria.Op.EQ, 0);
TemplateDataStoreVO template = sc.find();
if (template != null) {
return templateFactory.getTemplate(template.getTemplateId(), store);
}
SearchCriteriaService<VolumeDataStoreVO, VolumeDataStoreVO> volSc = SearchCriteria2.create(VolumeDataStoreVO.class);
volSc.addAnd(volSc.getEntity().getLastUpdated(), SearchCriteria.Op.LT, bef);
volSc.addAnd(volSc.getEntity().getState(), SearchCriteria.Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
volSc.addAnd(volSc.getEntity().getDataStoreId(), SearchCriteria.Op.EQ, store.getId());
volSc.addAnd(volSc.getEntity().getRefCnt(), SearchCriteria.Op.EQ, 0);
VolumeDataStoreVO volume = volSc.find();
if (volume != null) {
return volumeFactory.getVolume(volume.getVolumeId(), store);
}
SearchCriteriaService<SnapshotDataStoreVO, SnapshotDataStoreVO> snapshotSc = SearchCriteria2.create(SnapshotDataStoreVO.class);
snapshotSc.addAnd(snapshotSc.getEntity().getLastUpdated(), SearchCriteria.Op.LT, bef);
snapshotSc.addAnd(snapshotSc.getEntity().getState(), SearchCriteria.Op.EQ, ObjectInDataStoreStateMachine.State.Ready);
snapshotSc.addAnd(snapshotSc.getEntity().getDataStoreId(), SearchCriteria.Op.EQ, store.getId());
snapshotSc.addAnd(snapshotSc.getEntity().getRole(), SearchCriteria.Op.EQ, store.getRole());
snapshotSc.addAnd(snapshotSc.getEntity().getRefCnt(), SearchCriteria.Op.EQ, 0);
SnapshotDataStoreVO snapshot = snapshotSc.find();
if (snapshot != null) {
return snapshotFactory.getSnapshot(snapshot.getSnapshotId(), store);
}
return null;
}
}

View File

@ -172,10 +172,11 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
EndPoint ep = selector.select(srcData, destData); EndPoint ep = selector.select(srcData, destData);
answer = ep.sendMessage(cmd); answer = ep.sendMessage(cmd);
} }
// clean up cache entry in case of failure if (cacheData != null) {
if (answer == null || !answer.getResult()) { if (answer == null || !answer.getResult()) {
if (cacheData != null) {
cacheMgr.deleteCacheObject(cacheData); cacheMgr.deleteCacheObject(cacheData);
} else {
cacheMgr.releaseCacheObject(cacheData);
} }
} }
return answer; return answer;
@ -191,8 +192,9 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
protected DataObject cacheSnapshotChain(SnapshotInfo snapshot) { protected DataObject cacheSnapshotChain(SnapshotInfo snapshot) {
DataObject leafData = null; DataObject leafData = null;
DataStore store = cacheMgr.getCacheStorage(snapshot.getDataStore().getScope());
while (snapshot != null) { while (snapshot != null) {
DataObject cacheData = cacheMgr.createCacheObject(snapshot, snapshot.getDataStore().getScope()); DataObject cacheData = cacheMgr.createCacheObject(snapshot, store);
if (leafData == null) { if (leafData == null) {
leafData = cacheData; leafData = cacheData;
} }
@ -202,7 +204,10 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
} }
protected void deleteSnapshotCacheChain(SnapshotInfo snapshot) { protected void deleteSnapshotCacheChain(SnapshotInfo snapshot) {
while (snapshot != null) {
cacheMgr.deleteCacheObject(snapshot);
snapshot = snapshot.getParent();
}
} }
protected Answer copyVolumeFromSnapshot(DataObject snapObj, DataObject volObj) { protected Answer copyVolumeFromSnapshot(DataObject snapObj, DataObject volObj) {

View File

@ -1,29 +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.image;
public interface ImageOrchestrator {
void registerTemplate(long templateId);
void registerSnapshot(long snapshotId);
void registerVolume(long volumeId);
void registerIso(long isoId);
}

View File

@ -576,8 +576,6 @@ public class TemplateServiceImpl implements TemplateService {
if (result.isFailed()) { if (result.isFailed()) {
res.setResult(result.getResult()); res.setResult(result.getResult());
destTemplate.processEvent(Event.OperationFailed); destTemplate.processEvent(Event.OperationFailed);
// remove entry from template_store_ref
destTemplate.getDataStore().delete(destTemplate);
} else { } else {
destTemplate.processEvent(Event.OperationSuccessed, result.getAnswer()); destTemplate.processEvent(Event.OperationSuccessed, result.getAnswer());
} }

View File

@ -1,25 +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.image.downloader;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
public interface ImageDownloader {
public void downloadImage(TemplateInfo template);
}

View File

@ -66,7 +66,6 @@ public class ImageStoreProviderManagerImpl implements ImageStoreProviderManager
ImageStoreProvider provider = (ImageStoreProvider) providerManager.getDataStoreProvider(providerName); ImageStoreProvider provider = (ImageStoreProvider) providerManager.getDataStoreProvider(providerName);
ImageStoreEntity imgStore = ImageStoreImpl ImageStoreEntity imgStore = ImageStoreImpl
.getDataStore(dataStore, driverMaps.get(provider.getName()), provider); .getDataStore(dataStore, driverMaps.get(provider.getName()), provider);
// TODO Auto-generated method stub
return imgStore; return imgStore;
} }

View File

@ -24,6 +24,7 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject; import javax.inject.Inject;
import com.cloud.capacity.dao.CapacityDao;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider; import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider;
@ -52,10 +53,11 @@ public class ImageStoreImpl implements ImageStoreEntity {
VMTemplateDao imageDao; VMTemplateDao imageDao;
@Inject @Inject
private ObjectInDataStoreManager objectInStoreMgr; private ObjectInDataStoreManager objectInStoreMgr;
@Inject
private CapacityDao capacityDao;
protected ImageStoreDriver driver; protected ImageStoreDriver driver;
protected ImageStoreVO imageDataStoreVO; protected ImageStoreVO imageDataStoreVO;
protected ImageStoreProvider provider; protected ImageStoreProvider provider;
boolean needDownloadToCacheStorage = false;
public ImageStoreImpl() { public ImageStoreImpl() {
super(); super();
@ -77,13 +79,11 @@ public class ImageStoreImpl implements ImageStoreEntity {
@Override @Override
public Set<TemplateInfo> listTemplates() { public Set<TemplateInfo> listTemplates() {
// TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public DataStoreDriver getDriver() { public DataStoreDriver getDriver() {
// TODO Auto-generated method stub
return this.driver; return this.driver;
} }
@ -94,7 +94,6 @@ public class ImageStoreImpl implements ImageStoreEntity {
@Override @Override
public long getId() { public long getId() {
// TODO Auto-generated method stub
return this.imageDataStoreVO.getId(); return this.imageDataStoreVO.getId();
} }
@ -110,19 +109,16 @@ public class ImageStoreImpl implements ImageStoreEntity {
@Override @Override
public TemplateInfo getTemplate(long templateId) { public TemplateInfo getTemplate(long templateId) {
// TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public VolumeInfo getVolume(long volumeId) { public VolumeInfo getVolume(long volumeId) {
// TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public SnapshotInfo getSnapshot(long snapshotId) { public SnapshotInfo getSnapshot(long snapshotId) {
// TODO Auto-generated method stub
return null; return null;
} }

View File

@ -258,6 +258,48 @@ public class TemplateObject implements TemplateInfo {
} }
} }
@Override
public void incRefCount() {
if (this.dataStore == null) {
return;
}
if (this.dataStore.getRole() == DataStoreRole.Image ||
this.dataStore.getRole() == DataStoreRole.ImageCache) {
TemplateDataStoreVO store = templateStoreDao.findById(this.dataStore.getId());
store.incrRefCnt();
store.setLastUpdated(new Date());
templateStoreDao.update(store.getId(), store);
}
}
@Override
public void decRefCount() {
if (this.dataStore == null) {
return;
}
if (this.dataStore.getRole() == DataStoreRole.Image ||
this.dataStore.getRole() == DataStoreRole.ImageCache) {
TemplateDataStoreVO store = templateStoreDao.findById(this.dataStore.getId());
store.decrRefCnt();
store.setLastUpdated(new Date());
templateStoreDao.update(store.getId(), store);
}
}
@Override
public Long getRefCount() {
if (this.dataStore == null) {
return null;
}
if (this.dataStore.getRole() == DataStoreRole.Image ||
this.dataStore.getRole() == DataStoreRole.ImageCache) {
TemplateDataStoreVO store = templateStoreDao.findById(this.dataStore.getId());
return store.getRefCnt();
}
return null;
}
@Override @Override
public DataTO getTO() { public DataTO getTO() {
DataTO to = null; DataTO to = null;

View File

@ -128,7 +128,7 @@ public class StorageAllocatorTest {
storage.setClusterId(clusterId); storage.setClusterId(clusterId);
storage.setStatus(StoragePoolStatus.Up); storage.setStatus(StoragePoolStatus.Up);
storage.setScope(ScopeType.CLUSTER); storage.setScope(ScopeType.CLUSTER);
storage.setAvailableBytes(1000); storage.setUsedBytes(1000);
storage.setCapacityBytes(20000); storage.setCapacityBytes(20000);
storage.setHostAddress(UUID.randomUUID().toString()); storage.setHostAddress(UUID.randomUUID().toString());
storage.setPath(UUID.randomUUID().toString()); storage.setPath(UUID.randomUUID().toString());
@ -170,7 +170,7 @@ public class StorageAllocatorTest {
storage.setClusterId(clusterId); storage.setClusterId(clusterId);
storage.setStatus(StoragePoolStatus.Up); storage.setStatus(StoragePoolStatus.Up);
storage.setScope(ScopeType.CLUSTER); storage.setScope(ScopeType.CLUSTER);
storage.setAvailableBytes(1000); storage.setUsedBytes(1000);
storage.setCapacityBytes(20000); storage.setCapacityBytes(20000);
storage.setHostAddress(UUID.randomUUID().toString()); storage.setHostAddress(UUID.randomUUID().toString());
storage.setPath(UUID.randomUUID().toString()); storage.setPath(UUID.randomUUID().toString());

View File

@ -0,0 +1,226 @@
/*
* 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.cache.manager;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.Storage;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.utils.DateUtil;
import com.cloud.utils.component.ComponentContext;
import junit.framework.Assert;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
import org.apache.cloudstack.storage.datastore.db.ImageStoreDao;
import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import javax.inject.Inject;
import java.util.Calendar;
import java.util.Date;
import java.util.UUID;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:/storageContext.xml")
public class StorageCacheReplacementAlgorithmLRUTest {
@Inject
VMTemplateDao templateDao;
@Inject
ImageStoreDao imageStoreDao;
@Inject
TemplateDataStoreDao templateDataStoreDao;
@Inject
StorageCacheReplacementAlgorithmLRU cacheReplacementAlgorithm;
@Inject
DataStoreManager dataStoreManager;
@Before
public void setup() throws Exception {
ComponentContext.initComponentsLifeCycle();
}
@Test
public void testSelectObject() {
cacheReplacementAlgorithm.setUnusedTimeInterval(1);
try {
VMTemplateVO template = new VMTemplateVO();
template.setTemplateType(Storage.TemplateType.USER);
template.setUrl(UUID.randomUUID().toString());
template.setUniqueName(UUID.randomUUID().toString());
template.setName(UUID.randomUUID().toString());
template.setPublicTemplate(true);
template.setFeatured(true);
template.setRequiresHvm(true);
template.setBits(64);
template.setFormat(Storage.ImageFormat.VHD);
template.setEnablePassword(true);
template.setEnableSshKey(true);
template.setGuestOSId(1);
template.setBootable(true);
template.setPrepopulate(true);
template.setCrossZones(true);
template.setExtractable(true);
template = templateDao.persist(template);
VMTemplateVO template2 = new VMTemplateVO();
template2.setTemplateType(Storage.TemplateType.USER);
template2.setUrl(UUID.randomUUID().toString());
template2.setUniqueName(UUID.randomUUID().toString());
template2.setName(UUID.randomUUID().toString());
template2.setPublicTemplate(true);
template2.setFeatured(true);
template2.setRequiresHvm(true);
template2.setBits(64);
template2.setFormat(Storage.ImageFormat.VHD);
template2.setEnablePassword(true);
template2.setEnableSshKey(true);
template2.setGuestOSId(1);
template2.setBootable(true);
template2.setPrepopulate(true);
template2.setCrossZones(true);
template2.setExtractable(true);
template2 = templateDao.persist(template2);
ImageStoreVO imageStoreVO = new ImageStoreVO();
imageStoreVO.setRole(DataStoreRole.ImageCache);
imageStoreVO.setName(UUID.randomUUID().toString());
imageStoreVO.setProviderName(DataStoreProvider.NFS_IMAGE);
imageStoreVO.setProtocol("nfs");
imageStoreVO.setUrl(UUID.randomUUID().toString());
imageStoreVO = imageStoreDao.persist(imageStoreVO);
Calendar cal = Calendar.getInstance();
cal.setTime(DateUtil.now());
cal.add(Calendar.DAY_OF_MONTH, -2);
Date date = cal.getTime();
TemplateDataStoreVO templateStoreVO1 = new TemplateDataStoreVO();
templateStoreVO1.setLastUpdated(date);
templateStoreVO1.setDataStoreRole(DataStoreRole.ImageCache);
templateStoreVO1.setDataStoreId(imageStoreVO.getId());
templateStoreVO1.setState(ObjectInDataStoreStateMachine.State.Ready);
templateStoreVO1.setCopy(true);
templateStoreVO1.setTemplateId(template.getId());
templateDataStoreDao.persist(templateStoreVO1);
TemplateDataStoreVO templateStoreVO2 = new TemplateDataStoreVO();
templateStoreVO2.setLastUpdated(date);
templateStoreVO2.setDataStoreRole(DataStoreRole.ImageCache);
templateStoreVO2.setDataStoreId(imageStoreVO.getId());
templateStoreVO2.setState(ObjectInDataStoreStateMachine.State.Ready);
templateStoreVO2.setCopy(true);
templateStoreVO2.setTemplateId(template2.getId());
templateDataStoreDao.persist(templateStoreVO2);
DataStore store = dataStoreManager.getDataStore(imageStoreVO.getId(), DataStoreRole.ImageCache);
Assert.assertNotNull(cacheReplacementAlgorithm.chooseOneToBeReplaced(store));
} catch (Exception e) {
Assert.fail();
}
}
@Test
public void testSelectObjectFailed() {
cacheReplacementAlgorithm.setUnusedTimeInterval(1);
try {
VMTemplateVO template = new VMTemplateVO();
template.setTemplateType(Storage.TemplateType.USER);
template.setUrl(UUID.randomUUID().toString());
template.setUniqueName(UUID.randomUUID().toString());
template.setName(UUID.randomUUID().toString());
template.setPublicTemplate(true);
template.setFeatured(true);
template.setRequiresHvm(true);
template.setBits(64);
template.setFormat(Storage.ImageFormat.VHD);
template.setEnablePassword(true);
template.setEnableSshKey(true);
template.setGuestOSId(1);
template.setBootable(true);
template.setPrepopulate(true);
template.setCrossZones(true);
template.setExtractable(true);
template = templateDao.persist(template);
VMTemplateVO template2 = new VMTemplateVO();
template2.setTemplateType(Storage.TemplateType.USER);
template2.setUrl(UUID.randomUUID().toString());
template2.setUniqueName(UUID.randomUUID().toString());
template2.setName(UUID.randomUUID().toString());
template2.setPublicTemplate(true);
template2.setFeatured(true);
template2.setRequiresHvm(true);
template2.setBits(64);
template2.setFormat(Storage.ImageFormat.VHD);
template2.setEnablePassword(true);
template2.setEnableSshKey(true);
template2.setGuestOSId(1);
template2.setBootable(true);
template2.setPrepopulate(true);
template2.setCrossZones(true);
template2.setExtractable(true);
template2 = templateDao.persist(template2);
ImageStoreVO imageStoreVO = new ImageStoreVO();
imageStoreVO.setRole(DataStoreRole.ImageCache);
imageStoreVO.setName(UUID.randomUUID().toString());
imageStoreVO.setProviderName(DataStoreProvider.NFS_IMAGE);
imageStoreVO.setProtocol("nfs");
imageStoreVO.setUrl(UUID.randomUUID().toString());
imageStoreVO = imageStoreDao.persist(imageStoreVO);
Date date = DateUtil.now();
TemplateDataStoreVO templateStoreVO1 = new TemplateDataStoreVO();
templateStoreVO1.setLastUpdated(date);
templateStoreVO1.setDataStoreRole(DataStoreRole.ImageCache);
templateStoreVO1.setDataStoreId(imageStoreVO.getId());
templateStoreVO1.setState(ObjectInDataStoreStateMachine.State.Ready);
templateStoreVO1.setCopy(true);
templateStoreVO1.setTemplateId(template.getId());
templateDataStoreDao.persist(templateStoreVO1);
TemplateDataStoreVO templateStoreVO2 = new TemplateDataStoreVO();
templateStoreVO2.setLastUpdated(date);
templateStoreVO2.setDataStoreRole(DataStoreRole.ImageCache);
templateStoreVO2.setDataStoreId(imageStoreVO.getId());
templateStoreVO2.setState(ObjectInDataStoreStateMachine.State.Ready);
templateStoreVO2.setCopy(true);
templateStoreVO2.setTemplateId(template2.getId());
templateDataStoreDao.persist(templateStoreVO2);
DataStore store = dataStoreManager.getDataStore(imageStoreVO.getId(), DataStoreRole.ImageCache);
Assert.assertNull(cacheReplacementAlgorithm.chooseOneToBeReplaced(store));
} catch (Exception e) {
Assert.fail();
}
}
}

View File

@ -26,6 +26,8 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject; import javax.inject.Inject;
import junit.framework.Assert;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
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.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@ -43,6 +45,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
import org.apache.cloudstack.framework.async.AsyncCallFuture; import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.storage.LocalHostEndpoint; import org.apache.cloudstack.storage.LocalHostEndpoint;
@ -351,7 +354,7 @@ public class SnapshotTest extends CloudStackTestNGBase {
return volume; return volume;
} }
public VolumeInfo createCopyBaseImage() { public VolumeInfo createCopyBaseImage() throws InterruptedException, ExecutionException {
DataStore primaryStore = createPrimaryDataStore(); DataStore primaryStore = createPrimaryDataStore();
primaryStoreId = primaryStore.getId(); primaryStoreId = primaryStore.getId();
primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId); primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
@ -361,45 +364,13 @@ public class SnapshotTest extends CloudStackTestNGBase {
this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image)); this.primaryStoreId, this.templateFactory.getTemplate(this.image.getId(), DataStoreRole.Image));
VolumeApiResult result; VolumeApiResult result;
try { result = future.get();
result = future.get(); Assert.assertTrue(result.isSuccess());
return result.getVolume(); return result.getVolume();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
} }
@Test
public void createSnapshot() {
VolumeInfo vol = createCopyBaseImage();
SnapshotVO snapshotVO = createSnapshotInDb(vol);
SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
SnapshotInfo newSnapshot = null;
for (SnapshotStrategy strategy : this.snapshotStrategies) {
if (strategy.canHandle(snapshot)) {
newSnapshot = strategy.takeSnapshot(snapshot);
}
}
AssertJUnit.assertNotNull(newSnapshot);
LocalHostEndpoint ep = new MockLocalHostEndPoint();
ep.setResource(new MockLocalNfsSecondaryStorageResource());
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(ep);
// delete snapshot
for (SnapshotStrategy strategy : this.snapshotStrategies) {
if (strategy.canHandle(snapshot)) {
strategy.deleteSnapshot(newSnapshot.getId());
}
}
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(remoteEp);
}
private VMTemplateVO createTemplateInDb() { private VMTemplateVO createTemplateInDb() {
VMTemplateVO image = new VMTemplateVO(); VMTemplateVO image = new VMTemplateVO();
@ -424,7 +395,7 @@ public class SnapshotTest extends CloudStackTestNGBase {
} }
@Test @Test
public void createVolumeFromSnapshot() { public void createVolumeFromSnapshot() throws InterruptedException, ExecutionException {
VolumeInfo vol = createCopyBaseImage(); VolumeInfo vol = createCopyBaseImage();
SnapshotVO snapshotVO = createSnapshotInDb(vol); SnapshotVO snapshotVO = createSnapshotInDb(vol);
SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore()); SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
@ -440,11 +411,13 @@ public class SnapshotTest extends CloudStackTestNGBase {
VolumeVO volVO = createVolume(vol.getTemplateId(), vol.getPoolId()); VolumeVO volVO = createVolume(vol.getTemplateId(), vol.getPoolId());
VolumeInfo newVol = this.volFactory.getVolume(volVO.getId()); VolumeInfo newVol = this.volFactory.getVolume(volVO.getId());
this.volumeService.createVolumeFromSnapshot(newVol, newVol.getDataStore(), snapshot); AsyncCallFuture<VolumeApiResult> volFuture = this.volumeService.createVolumeFromSnapshot(newVol, newVol.getDataStore(), snapshot);
VolumeApiResult apiResult = volFuture.get();
Assert.assertTrue(apiResult.isSuccess());
} }
@Test @Test
public void deleteSnapshot() { public void deleteSnapshot() throws InterruptedException, ExecutionException {
VolumeInfo vol = createCopyBaseImage(); VolumeInfo vol = createCopyBaseImage();
SnapshotVO snapshotVO = createSnapshotInDb(vol); SnapshotVO snapshotVO = createSnapshotInDb(vol);
SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore()); SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
@ -466,7 +439,7 @@ public class SnapshotTest extends CloudStackTestNGBase {
} }
@Test @Test
public void createTemplateFromSnapshot() { public void createTemplateFromSnapshot() throws InterruptedException, ExecutionException {
VolumeInfo vol = createCopyBaseImage(); VolumeInfo vol = createCopyBaseImage();
SnapshotVO snapshotVO = createSnapshotInDb(vol); SnapshotVO snapshotVO = createSnapshotInDb(vol);
SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore()); SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
@ -482,10 +455,46 @@ public class SnapshotTest extends CloudStackTestNGBase {
LocalHostEndpoint ep = new LocalHostEndpoint(); LocalHostEndpoint ep = new LocalHostEndpoint();
ep.setResource(new MockLocalNfsSecondaryStorageResource()); ep.setResource(new MockLocalNfsSecondaryStorageResource());
Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(ep); Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(ep);
VMTemplateVO templateVO = createTemplateInDb();
TemplateInfo tmpl = this.templateFactory.getTemplate(templateVO.getId(), DataStoreRole.Image); try {
DataStore imageStore = this.dataStoreMgr.getImageStore(this.dcId); VMTemplateVO templateVO = createTemplateInDb();
this.imageService.createTemplateFromSnapshotAsync(snapshot, tmpl, imageStore); TemplateInfo tmpl = this.templateFactory.getTemplate(templateVO.getId(), DataStoreRole.Image);
DataStore imageStore = this.dataStoreMgr.getImageStore(this.dcId);
AsyncCallFuture<TemplateApiResult> templateFuture = this.imageService.createTemplateFromSnapshotAsync(snapshot, tmpl, imageStore);
TemplateApiResult apiResult = templateFuture.get();
Assert.assertTrue(apiResult.isSuccess());
} finally {
Mockito.when(epSelector.select(Matchers.any(DataObject.class), Matchers.any(DataObject.class))).thenReturn(remoteEp);
}
}
@Test
public void createSnapshot() throws InterruptedException, ExecutionException {
VolumeInfo vol = createCopyBaseImage();
SnapshotVO snapshotVO = createSnapshotInDb(vol);
SnapshotInfo snapshot = this.snapshotFactory.getSnapshot(snapshotVO.getId(), vol.getDataStore());
SnapshotInfo newSnapshot = null;
for (SnapshotStrategy strategy : this.snapshotStrategies) {
if (strategy.canHandle(snapshot)) {
newSnapshot = strategy.takeSnapshot(snapshot);
}
}
AssertJUnit.assertNotNull(newSnapshot);
LocalHostEndpoint ep = new MockLocalHostEndPoint();
ep.setResource(new MockLocalNfsSecondaryStorageResource());
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(ep);
try {
for (SnapshotStrategy strategy : this.snapshotStrategies) {
if (strategy.canHandle(snapshot)) {
boolean res = strategy.deleteSnapshot(newSnapshot.getId());
Assert.assertTrue(res);
}
}
} finally {
Mockito.when(epSelector.select(Matchers.any(DataStore.class))).thenReturn(remoteEp);
}
} }
} }

View File

@ -26,6 +26,8 @@ import java.util.concurrent.ExecutionException;
import javax.inject.Inject; import javax.inject.Inject;
import junit.framework.Assert;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject; import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
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.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
@ -39,6 +41,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateService.TemplateApiResult;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
import org.apache.cloudstack.framework.async.AsyncCallFuture; import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.storage.RemoteHostEndPoint; import org.apache.cloudstack.storage.RemoteHostEndPoint;
@ -237,6 +240,7 @@ public class VolumeTest extends CloudStackTestNGBase {
TemplateObjectTO to = new TemplateObjectTO(); TemplateObjectTO to = new TemplateObjectTO();
to.setPath(this.getImageInstallPath()); to.setPath(this.getImageInstallPath());
to.setFormat(ImageFormat.VHD); to.setFormat(ImageFormat.VHD);
to.setSize(100L);
CopyCmdAnswer answer = new CopyCmdAnswer(to); CopyCmdAnswer answer = new CopyCmdAnswer(to);
templateOnStore.processEvent(Event.CreateOnlyRequested); templateOnStore.processEvent(Event.CreateOnlyRequested);
templateOnStore.processEvent(Event.OperationSuccessed, answer); templateOnStore.processEvent(Event.OperationSuccessed, answer);
@ -335,57 +339,52 @@ public class VolumeTest extends CloudStackTestNGBase {
AssertJUnit.assertTrue(result.isSuccess()); AssertJUnit.assertTrue(result.isSuccess());
VolumeInfo newVol = result.getVolume(); VolumeInfo newVol = result.getVolume();
this.volumeService.destroyVolume(newVol.getId()); boolean res = this.volumeService.destroyVolume(newVol.getId());
Assert.assertTrue(res);
VolumeInfo vol = this.volFactory.getVolume(volume.getId()); VolumeInfo vol = this.volFactory.getVolume(volume.getId());
this.volumeService.expungeVolumeAsync(vol); future = this.volumeService.expungeVolumeAsync(vol);
result = future.get();
Assert.assertTrue(result.isSuccess());
} catch (InterruptedException e) { } catch (InterruptedException e) {
// TODO Auto-generated catch block Assert.fail(e.toString());
e.printStackTrace();
} catch (ExecutionException e) { } catch (ExecutionException e) {
// TODO Auto-generated catch block Assert.fail(e.toString());
e.printStackTrace();
} catch (ConcurrentOperationException e) { } catch (ConcurrentOperationException e) {
// TODO Auto-generated catch block Assert.fail(e.toString());
e.printStackTrace();
} }
} }
@Test @Test
public void testCreateDataDisk() { public void testCreateDataDisk() throws InterruptedException, ExecutionException {
DataStore primaryStore = createPrimaryDataStore();
primaryStoreId = primaryStore.getId();
primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
VolumeVO volume = createVolume(null, primaryStore.getId());
VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
this.volumeService.createVolumeAsync(volInfo, primaryStore);
}
@Test
public void testDeleteDisk() {
DataStore primaryStore = createPrimaryDataStore(); DataStore primaryStore = createPrimaryDataStore();
primaryStoreId = primaryStore.getId(); primaryStoreId = primaryStore.getId();
primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId); primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
VolumeVO volume = createVolume(null, primaryStore.getId()); VolumeVO volume = createVolume(null, primaryStore.getId());
VolumeInfo volInfo = this.volFactory.getVolume(volume.getId()); VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeAsync(volInfo, primaryStore); AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeAsync(volInfo, primaryStore);
try { VolumeApiResult result = future.get();
VolumeApiResult result = future.get(); Assert.assertTrue(result.isSuccess());
VolumeInfo vol = result.getVolume(); }
this.volumeService.destroyVolume(volInfo.getId()); @Test
volInfo = this.volFactory.getVolume(vol.getId()); public void testDeleteDisk() throws InterruptedException, ExecutionException, ConcurrentOperationException {
this.volumeService.expungeVolumeAsync(volInfo); DataStore primaryStore = createPrimaryDataStore();
} catch (InterruptedException e) { primaryStoreId = primaryStore.getId();
// TODO Auto-generated catch block primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
e.printStackTrace(); VolumeVO volume = createVolume(null, primaryStore.getId());
} catch (ExecutionException e) { VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
// TODO Auto-generated catch block AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeAsync(volInfo, primaryStore);
e.printStackTrace();
} catch (ConcurrentOperationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
VolumeApiResult result = future.get();
Assert.assertTrue(result.isSuccess());
VolumeInfo vol = result.getVolume();
boolean res = this.volumeService.destroyVolume(volInfo.getId());
Assert.assertTrue(res);
volInfo = this.volFactory.getVolume(vol.getId());
future = this.volumeService.expungeVolumeAsync(volInfo);
result = future.get();
Assert.assertTrue(result.isSuccess());
} }
private VMTemplateVO createTemplateInDb() { private VMTemplateVO createTemplateInDb() {
@ -411,30 +410,24 @@ public class VolumeTest extends CloudStackTestNGBase {
} }
@Test @Test
public void testCreateTemplateFromVolume() { public void testCreateTemplateFromVolume() throws InterruptedException, ExecutionException {
DataStore primaryStore = createPrimaryDataStore(); DataStore primaryStore = createPrimaryDataStore();
primaryStoreId = primaryStore.getId(); primaryStoreId = primaryStore.getId();
primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId); primaryStore = this.dataStoreMgr.getPrimaryDataStore(primaryStoreId);
VolumeVO volume = createVolume(null, primaryStore.getId()); VolumeVO volume = createVolume(null, primaryStore.getId());
VolumeInfo volInfo = this.volFactory.getVolume(volume.getId()); VolumeInfo volInfo = this.volFactory.getVolume(volume.getId());
AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeAsync(volInfo, primaryStore); AsyncCallFuture<VolumeApiResult> future = this.volumeService.createVolumeAsync(volInfo, primaryStore);
try {
VolumeApiResult result = future.get();
AssertJUnit.assertTrue(result.isSuccess()); VolumeApiResult result = future.get();
volInfo = result.getVolume();
VMTemplateVO templateVO = createTemplateInDb();
TemplateInfo tmpl = this.templateFactory.getTemplate(templateVO.getId(), DataStoreRole.Image);
DataStore imageStore = this.dataStoreMgr.getImageStore(this.dcId);
this.imageService.createTemplateFromVolumeAsync(volInfo, tmpl, imageStore); AssertJUnit.assertTrue(result.isSuccess());
} catch (InterruptedException e) { volInfo = result.getVolume();
// TODO Auto-generated catch block VMTemplateVO templateVO = createTemplateInDb();
e.printStackTrace(); TemplateInfo tmpl = this.templateFactory.getTemplate(templateVO.getId(), DataStoreRole.Image);
} catch (ExecutionException e) { DataStore imageStore = this.dataStoreMgr.getImageStore(this.dcId);
// TODO Auto-generated catch block
e.printStackTrace();
}
AsyncCallFuture<TemplateApiResult> templateResult = this.imageService.createTemplateFromVolumeAsync(volInfo, tmpl, imageStore);
TemplateApiResult templateApiResult = templateResult.get();
Assert.assertTrue(templateApiResult.isSuccess());
} }
} }

View File

@ -43,9 +43,7 @@
<bean id="objectInDataStoreDaoImpl" class="org.apache.cloudstack.storage.db.ObjectInDataStoreDaoImpl" /> <bean id="objectInDataStoreDaoImpl" class="org.apache.cloudstack.storage.db.ObjectInDataStoreDaoImpl" />
<bean id="primaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl" /> <bean id="primaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl" />
<bean id="primaryDataStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.volume.db.PrimaryDataStoreDetailsDaoImpl" /> <bean id="primaryDataStoreDetailsDaoImpl" class="org.apache.cloudstack.storage.volume.db.PrimaryDataStoreDetailsDaoImpl" />
<bean id="snapshotDao2Impl" class="org.apache.cloudstack.storage.snapshot.db.SnapshotDao2Impl" />
<bean id="templatePrimaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreDaoImpl" /> <bean id="templatePrimaryDataStoreDaoImpl" class="org.apache.cloudstack.storage.volume.db.TemplatePrimaryDataStoreDaoImpl" />
<bean id="volumeDao2Impl" class="org.apache.cloudstack.storage.volume.db.VolumeDao2Impl" />
<bean id="LocalStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.LocalStoragePoolAllocator"/> <bean id="LocalStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.LocalStoragePoolAllocator"/>
<bean id="clusterScopeStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ClusterScopeStoragePoolAllocator" /> <bean id="clusterScopeStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ClusterScopeStoragePoolAllocator" />
<bean id="zoneWideStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ZoneWideStoragePoolAllocator" /> <bean id="zoneWideStoragePoolAllocator" class="org.apache.cloudstack.storage.allocator.ZoneWideStoragePoolAllocator" />
@ -76,7 +74,6 @@
<bean id="snapshotDataFactoryImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotDataFactoryImpl" /> <bean id="snapshotDataFactoryImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotDataFactoryImpl" />
<bean id="snapshotServiceImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotServiceImpl" /> <bean id="snapshotServiceImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotServiceImpl" />
<bean id="snapshotStateMachineManagerImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotStateMachineManagerImpl" /> <bean id="snapshotStateMachineManagerImpl" class="org.apache.cloudstack.storage.snapshot.SnapshotStateMachineManagerImpl" />
<bean id="templateInstallStrategyImpl" class="org.apache.cloudstack.storage.volume.TemplateInstallStrategyImpl" />
<bean id="unknown" class="org.apache.cloudstack.storage.image.format.Unknown" /> <bean id="unknown" class="org.apache.cloudstack.storage.image.format.Unknown" />
<bean id="VHD" class="org.apache.cloudstack.storage.image.format.VHD" /> <bean id="VHD" class="org.apache.cloudstack.storage.image.format.VHD" />
<bean id="volumeDataFactoryImpl" class="org.apache.cloudstack.storage.volume.VolumeDataFactoryImpl" /> <bean id="volumeDataFactoryImpl" class="org.apache.cloudstack.storage.volume.VolumeDataFactoryImpl" />
@ -88,4 +85,6 @@
<bean id="BAREMETAL" class="org.apache.cloudstack.storage.image.format.BAREMETAL" /> <bean id="BAREMETAL" class="org.apache.cloudstack.storage.image.format.BAREMETAL" />
<bean id="storagePoolAutomationImpl" class="com.cloud.storage.StoragePoolAutomationImpl" /> <bean id="storagePoolAutomationImpl" class="com.cloud.storage.StoragePoolAutomationImpl" />
<bean id="AccountGuestVlanMapDaoImpl" class="com.cloud.network.dao.AccountGuestVlanMapDaoImpl" /> <bean id="AccountGuestVlanMapDaoImpl" class="com.cloud.network.dao.AccountGuestVlanMapDaoImpl" />
<bean id="StorageCacheReplacementAlgorithm" class="org.apache.cloudstack.storage.cache.manager.StorageCacheReplacementAlgorithmLRU" />
<bean id="ServiceOfferingDetailsDao" class="com.cloud.service.dao.ServiceOfferingDetailsDaoImpl" />
</beans> </beans>

View File

@ -22,6 +22,7 @@ import java.util.Date;
import javax.inject.Inject; import javax.inject.Inject;
import com.cloud.storage.DataStoreRole;
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.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
@ -273,6 +274,47 @@ public class SnapshotObject implements SnapshotInfo {
this.processEvent(event); this.processEvent(event);
} }
public void incRefCount() {
if (this.store == null) {
return;
}
if (this.store.getRole() == DataStoreRole.Image ||
this.store.getRole() == DataStoreRole.ImageCache) {
SnapshotDataStoreVO store = snapshotStoreDao.findById(this.store.getId());
store.incrRefCnt();
store.setLastUpdated(new Date());
snapshotStoreDao.update(store.getId(), store);
}
}
@Override
public void decRefCount() {
if (this.store == null) {
return;
}
if (this.store.getRole() == DataStoreRole.Image ||
this.store.getRole() == DataStoreRole.ImageCache) {
SnapshotDataStoreVO store = snapshotStoreDao.findById(this.store.getId());
store.decrRefCnt();
store.setLastUpdated(new Date());
snapshotStoreDao.update(store.getId(), store);
}
}
@Override
public Long getRefCount() {
if (this.store == null) {
return null;
}
if (this.store.getRole() == DataStoreRole.Image ||
this.store.getRole() == DataStoreRole.ImageCache) {
SnapshotDataStoreVO store = snapshotStoreDao.findById(this.store.getId());
return store.getRefCnt();
}
return null;
}
@Override @Override
public ObjectInDataStoreStateMachine.State getStatus() { public ObjectInDataStoreStateMachine.State getStatus() {
return this.objectInStoreMgr.findObject(this, store).getObjectInStoreState(); return this.objectInStoreMgr.findObject(this, store).getObjectInStoreState();
@ -280,8 +322,6 @@ public class SnapshotObject implements SnapshotInfo {
@Override @Override
public void addPayload(Object data) { public void addPayload(Object data) {
// TODO Auto-generated method stub
} }
@Override @Override

View File

@ -17,23 +17,19 @@
package org.apache.cloudstack.storage.snapshot; package org.apache.cloudstack.storage.snapshot;
import java.util.concurrent.ExecutionException; import com.cloud.dc.dao.ClusterDao;
import com.cloud.storage.DataStoreRole;
import javax.inject.Inject; import com.cloud.storage.Snapshot;
import com.cloud.storage.VolumeManager;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult; import com.cloud.storage.dao.SnapshotDao;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult; import com.cloud.storage.dao.VolumeDao;
import org.apache.cloudstack.engine.subsystem.api.storage.DataMotionService; import com.cloud.storage.snapshot.SnapshotManager;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import com.cloud.utils.fsm.NoTransitionException;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.snapshot.dao.VMSnapshotDao;
import org.apache.cloudstack.engine.subsystem.api.storage.*;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotResult;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotService;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.framework.async.AsyncCallFuture; import org.apache.cloudstack.framework.async.AsyncCallFuture;
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher; import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback; import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
@ -47,19 +43,8 @@ import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.cloud.dc.dao.ClusterDao; import javax.inject.Inject;
import com.cloud.storage.DataStoreRole; import java.util.concurrent.ExecutionException;
import com.cloud.storage.Snapshot;
import com.cloud.storage.SnapshotVO;
import com.cloud.storage.VolumeManager;
import com.cloud.storage.dao.SnapshotDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.utils.db.DB;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.fsm.NoTransitionException;
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.snapshot.dao.VMSnapshotDao;
@Component @Component
public class SnapshotServiceImpl implements SnapshotService { public class SnapshotServiceImpl implements SnapshotService {
@ -391,7 +376,6 @@ public class SnapshotServiceImpl implements SnapshotService {
@Override @Override
public boolean revertSnapshot(SnapshotInfo snapshot) { public boolean revertSnapshot(SnapshotInfo snapshot) {
// TODO Auto-generated method stub
return false; return false;
} }

View File

@ -22,5 +22,5 @@ import com.cloud.storage.SnapshotVO;
import com.cloud.utils.fsm.NoTransitionException; import com.cloud.utils.fsm.NoTransitionException;
public interface SnapshotStateMachineManager { public interface SnapshotStateMachineManager {
public void processEvent(SnapshotVO snapshot, Event event) throws NoTransitionException; void processEvent(SnapshotVO snapshot, Event event) throws NoTransitionException;
} }

View File

@ -194,7 +194,6 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase {
@Override @Override
public SnapshotInfo takeSnapshot(SnapshotInfo snapshot) { public SnapshotInfo takeSnapshot(SnapshotInfo snapshot) {
snapshot = snapshotSvr.takeSnapshot(snapshot).getSnashot(); snapshot = snapshotSvr.takeSnapshot(snapshot).getSnashot();
// TODO: add async
return this.backupSnapshot(snapshot); return this.backupSnapshot(snapshot);
} }

View File

@ -1,25 +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.snapshot.db;
import com.cloud.utils.db.GenericDao;
public interface SnapshotDao2 extends GenericDao<SnapshotVO, Long> {
}

View File

@ -1,28 +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.snapshot.db;
import org.springframework.stereotype.Component;
import com.cloud.utils.db.GenericDaoBase;
@Component
public class SnapshotDao2Impl extends GenericDaoBase<SnapshotVO, Long> implements SnapshotDao2 {
}

View File

@ -1,296 +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.snapshot.db;
import java.util.Date;
import java.util.UUID;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.Snapshot.State;
import com.cloud.storage.Snapshot.Type;
import com.cloud.utils.db.GenericDao;
import com.google.gson.annotations.Expose;
@Entity
@Table(name = "snapshots")
public class SnapshotVO {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private final long id = -1;
@Column(name = "data_center_id")
long dataCenterId;
@Column(name = "account_id")
long accountId;
@Column(name = "domain_id")
long domainId;
@Column(name = "volume_id")
Long volumeId;
@Column(name = "disk_offering_id")
Long diskOfferingId;
@Expose
@Column(name = "path")
String path;
@Expose
@Column(name = "name")
String name;
@Expose
@Column(name = "status", updatable = true, nullable = false)
@Enumerated(value = EnumType.STRING)
private State status;
@Column(name = "snapshot_type")
short snapshotType;
@Column(name = "type_description")
String typeDescription;
@Column(name = "size")
long size;
@Column(name = GenericDao.CREATED_COLUMN)
Date created;
@Column(name = GenericDao.REMOVED_COLUMN)
Date removed;
@Column(name = "backup_snap_id")
String backupSnapshotId;
@Column(name = "swift_id")
Long swiftId;
@Column(name = "s3_id")
Long s3Id;
@Column(name = "sechost_id")
Long secHostId;
@Column(name = "prev_snap_id")
long prevSnapshotId;
@Column(name = "hypervisor_type")
@Enumerated(value = EnumType.STRING)
HypervisorType hypervisorType;
@Expose
@Column(name = "version")
String version;
@Column(name = "uuid")
String uuid;
public SnapshotVO() {
this.uuid = UUID.randomUUID().toString();
}
public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, Long diskOfferingId, String path,
String name, short snapshotType, String typeDescription, long size, HypervisorType hypervisorType) {
this.dataCenterId = dcId;
this.accountId = accountId;
this.domainId = domainId;
this.volumeId = volumeId;
this.diskOfferingId = diskOfferingId;
this.path = path;
this.name = name;
this.snapshotType = snapshotType;
this.typeDescription = typeDescription;
this.size = size;
this.status = State.Creating;
this.prevSnapshotId = 0;
this.hypervisorType = hypervisorType;
this.version = "2.2";
this.uuid = UUID.randomUUID().toString();
}
public long getId() {
return id;
}
public long getDataCenterId() {
return dataCenterId;
}
public long getAccountId() {
return accountId;
}
public long getDomainId() {
return domainId;
}
public long getVolumeId() {
return volumeId;
}
public long getDiskOfferingId() {
return diskOfferingId;
}
public void setVolumeId(Long volumeId) {
this.volumeId = volumeId;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getName() {
return name;
}
public short getsnapshotType() {
return snapshotType;
}
public Type getType() {
if (snapshotType < 0 || snapshotType >= Type.values().length) {
return null;
}
return Type.values()[snapshotType];
}
public Long getSwiftId() {
return swiftId;
}
public void setSwiftId(Long swiftId) {
this.swiftId = swiftId;
}
public Long getSecHostId() {
return secHostId;
}
public void setSecHostId(Long secHostId) {
this.secHostId = secHostId;
}
public HypervisorType getHypervisorType() {
return hypervisorType;
}
public void setSnapshotType(short snapshotType) {
this.snapshotType = snapshotType;
}
public boolean isRecursive() {
if (snapshotType >= Type.HOURLY.ordinal() && snapshotType <= Type.MONTHLY.ordinal()) {
return true;
}
return false;
}
public long getSize() {
return size;
}
public String getTypeDescription() {
return typeDescription;
}
public void setTypeDescription(String typeDescription) {
this.typeDescription = typeDescription;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Date getCreated() {
return created;
}
public Date getRemoved() {
return removed;
}
public State getStatus() {
return status;
}
public void setStatus(State status) {
this.status = status;
}
public String getBackupSnapshotId() {
return backupSnapshotId;
}
public long getPrevSnapshotId() {
return prevSnapshotId;
}
public void setBackupSnapshotId(String backUpSnapshotId) {
this.backupSnapshotId = backUpSnapshotId;
}
public void setPrevSnapshotId(long prevSnapshotId) {
this.prevSnapshotId = prevSnapshotId;
}
public static Type getSnapshotType(String snapshotType) {
for (Type type : Type.values()) {
if (type.equals(snapshotType)) {
return type;
}
}
return null;
}
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public Long getS3Id() {
return s3Id;
}
public void setS3Id(Long s3Id) {
this.s3Id = s3Id;
}
}

View File

@ -54,11 +54,6 @@ public class DataStoreManagerImpl implements DataStoreManager {
throw new CloudRuntimeException("un recognized type" + role); throw new CloudRuntimeException("un recognized type" + role);
} }
@Override
public DataStore registerDataStore(Map<String, String> params, String providerUuid) {
return null;
}
@Override @Override
public DataStore getDataStore(String uuid, DataStoreRole role) { public DataStore getDataStore(String uuid, DataStoreRole role) {
if (role == DataStoreRole.Primary) { if (role == DataStoreRole.Primary) {
@ -84,11 +79,6 @@ public class DataStoreManagerImpl implements DataStoreManager {
return stores.get(0); return stores.get(0);
} }
@Override
public List<DataStore> getImageStoresByProvider(String provider) {
return imageDataStoreMgr.listImageStoreByProvider(provider);
}
@Override @Override
public DataStore getPrimaryDataStore(long storeId) { public DataStore getPrimaryDataStore(long storeId) {
return primaryStorMgr.getPrimaryDataStore(storeId); return primaryStorMgr.getPrimaryDataStore(storeId);

View File

@ -170,7 +170,7 @@ public class PrimaryDataStoreEntityImpl implements StorageEntity {
} }
@Override @Override
public long getAvailableBytes() { public long getUsedBytes() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return 0; return 0;
} }

View File

@ -57,12 +57,6 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
return providerMap.get(name); return providerMap.get(name);
} }
@Override
public List<DataStoreProvider> getDataStoreProviders() {
// TODO Auto-generated method stub
return null;
}
public List<StorageProviderResponse> getPrimaryDataStoreProviders() { public List<StorageProviderResponse> getPrimaryDataStoreProviders() {
List<StorageProviderResponse> providers = new ArrayList<StorageProviderResponse>(); List<StorageProviderResponse> providers = new ArrayList<StorageProviderResponse>();
for (DataStoreProvider provider : providerMap.values()) { for (DataStoreProvider provider : providerMap.values()) {

View File

@ -66,30 +66,11 @@ public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver {
@Inject @Inject
EndPointSelector _epSelector; EndPointSelector _epSelector;
@Override
public String grantAccess(DataObject data, EndPoint ep) {
// TODO Auto-generated method stub
return null;
}
@Override @Override
public DataTO getTO(DataObject data) { public DataTO getTO(DataObject data) {
return null; return null;
} }
@Override
public boolean revokeAccess(DataObject data, EndPoint ep) {
// TODO Auto-generated method stub
return false;
}
@Override
public Set<DataObject> listObjects(DataStore store) {
// TODO Auto-generated method stub
return null;
}
class CreateContext<T> extends AsyncRpcConext<T> { class CreateContext<T> extends AsyncRpcConext<T> {
final DataObject data; final DataObject data;
@ -202,8 +183,6 @@ public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver {
return null; return null;
} }
@Override @Override
public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback) { public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
DeleteCommand cmd = new DeleteCommand(data.getTO()); DeleteCommand cmd = new DeleteCommand(data.getTO());
@ -224,21 +203,14 @@ public abstract class BaseImageStoreDriverImpl implements ImageStoreDriver {
@Override @Override
public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) { public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
// TODO Auto-generated method stub
} }
@Override @Override
public boolean canCopy(DataObject srcData, DataObject destData) { public boolean canCopy(DataObject srcData, DataObject destData) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) { public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
// TODO Auto-generated method stub
} }
} }

View File

@ -108,12 +108,12 @@ public class PrimaryDataStoreHelper {
StoragePoolVO pool = this.dataStoreDao.findById(store.getId()); StoragePoolVO pool = this.dataStoreDao.findById(store.getId());
pool.setScope(scope.getScopeType()); pool.setScope(scope.getScopeType());
pool.setAvailableBytes(existingInfo.getAvailableBytes()); pool.setUsedBytes(existingInfo.getAvailableBytes());
pool.setCapacityBytes(existingInfo.getCapacityBytes()); pool.setCapacityBytes(existingInfo.getCapacityBytes());
pool.setStatus(StoragePoolStatus.Up); pool.setStatus(StoragePoolStatus.Up);
this.dataStoreDao.update(pool.getId(), pool); this.dataStoreDao.update(pool.getId(), pool);
this.storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE, this.storageMgr.createCapacityEntry(pool, Capacity.CAPACITY_TYPE_LOCAL_STORAGE,
pool.getCapacityBytes() - pool.getAvailableBytes()); pool.getUsedBytes());
return dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary); return dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
} }

View File

@ -168,19 +168,16 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
@Override @Override
public boolean isHypervisorSupported(HypervisorType hypervisor) { public boolean isHypervisorSupported(HypervisorType hypervisor) {
// TODO Auto-generated method stub
return true; return true;
} }
@Override @Override
public boolean isLocalStorageSupported() { public boolean isLocalStorageSupported() {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean isVolumeDiskTypeSupported(DiskFormat diskType) { public boolean isVolumeDiskTypeSupported(DiskFormat diskType) {
// TODO Auto-generated method stub
return false; return false;
} }
@ -216,13 +213,11 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
@Override @Override
public SnapshotInfo getSnapshot(long snapshotId) { public SnapshotInfo getSnapshot(long snapshotId) {
// TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public DiskFormat getDefaultDiskType() { public DiskFormat getDefaultDiskType() {
// TODO Auto-generated method stub
return null; return null;
} }
@ -288,8 +283,8 @@ public class PrimaryDataStoreImpl implements PrimaryDataStore {
} }
@Override @Override
public long getAvailableBytes() { public long getUsedBytes() {
return this.pdsv.getAvailableBytes(); return this.pdsv.getUsedBytes();
} }
@Override @Override

View File

@ -1,16 +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.

View File

@ -81,7 +81,7 @@ public class DefaultHostListener implements HypervisorHostListener {
} }
StoragePoolVO poolVO = this.primaryStoreDao.findById(poolId); StoragePoolVO poolVO = this.primaryStoreDao.findById(poolId);
poolVO.setAvailableBytes(mspAnswer.getPoolInfo().getAvailableBytes()); poolVO.setUsedBytes(mspAnswer.getPoolInfo().getAvailableBytes());
poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes()); poolVO.setCapacityBytes(mspAnswer.getPoolInfo().getCapacityBytes());
primaryStoreDao.update(pool.getId(), poolVO); primaryStoreDao.update(pool.getId(), poolVO);

View File

@ -1,201 +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 java.lang.reflect.Method;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity;
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity;
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
import org.apache.cloudstack.storage.datastore.PrimaryDataStoreEntityImpl;
public class VolumeEntityImpl implements VolumeEntity {
private VolumeInfo volumeInfo;
private final VolumeService vs;
private VolumeApiResult result;
public VolumeEntityImpl() {
this.vs = null;
}
public VolumeEntityImpl(VolumeInfo volumeObject, VolumeService vs) {
this.volumeInfo = volumeObject;
this.vs = vs;
}
public VolumeInfo getVolumeInfo() {
return volumeInfo;
}
@Override
public String getUuid() {
return volumeInfo.getUuid();
}
@Override
public long getId() {
return volumeInfo.getId();
}
public String getExternalId() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getCurrentState() {
return null;
}
@Override
public String getDesiredState() {
return null;
}
@Override
public Date getCreatedTime() {
return null;
}
@Override
public Date getLastUpdatedTime() {
return null;
}
@Override
public String getOwner() {
return null;
}
@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 long getSize() {
return volumeInfo.getSize();
}
@Override
public DiskFormat getDiskType() {
return null;
}
@Override
public VolumeType getType() {
return null;
}
@Override
public StorageEntity getDataStore() {
return new PrimaryDataStoreEntityImpl((PrimaryDataStoreInfo) volumeInfo.getDataStore());
}
@Override
public void destroy() {
/*
* AsyncCallFuture<VolumeApiResult> future =
* vs.deleteVolumeAsync(volumeInfo); try { result = future.get(); if
* (!result.isSuccess()) { throw new
* CloudRuntimeException("Failed to create volume:" +
* result.getResult()); } } catch (InterruptedException e) { throw new
* CloudRuntimeException("wait to delete volume info failed", e); }
* catch (ExecutionException e) { throw new
* CloudRuntimeException("wait to delete volume failed", e); }
*/
}
@Override
public Map<String, String> getDetails() {
// TODO Auto-generated method stub
return null;
}
@Override
public void addDetail(String name, String value) {
// TODO Auto-generated method stub
}
@Override
public void delDetail(String name, String value) {
// TODO Auto-generated method stub
}
@Override
public void updateDetail(String name, String value) {
// TODO Auto-generated method stub
}
}

View File

@ -451,6 +451,47 @@ public class VolumeObject implements VolumeInfo {
} }
public void incRefCount() {
if (this.dataStore == null) {
return;
}
if (this.dataStore.getRole() == DataStoreRole.Image ||
this.dataStore.getRole() == DataStoreRole.ImageCache) {
VolumeDataStoreVO store = volumeStoreDao.findById(this.dataStore.getId());
store.incrRefCnt();
store.setLastUpdated(new Date());
volumeStoreDao.update(store.getId(), store);
}
}
@Override
public void decRefCount() {
if (this.dataStore == null) {
return;
}
if (this.dataStore.getRole() == DataStoreRole.Image ||
this.dataStore.getRole() == DataStoreRole.ImageCache) {
VolumeDataStoreVO store = volumeStoreDao.findById(this.dataStore.getId());
store.decrRefCnt();
store.setLastUpdated(new Date());
volumeStoreDao.update(store.getId(), store);
}
}
@Override
public Long getRefCount() {
if (this.dataStore == null) {
return null;
}
if (this.dataStore.getRole() == DataStoreRole.Image ||
this.dataStore.getRole() == DataStoreRole.ImageCache) {
VolumeDataStoreVO store = volumeStoreDao.findById(this.dataStore.getId());
return store.getRefCnt();
}
return null;
}
@Override @Override
public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer answer) { public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer answer) {
try { try {

View File

@ -120,9 +120,6 @@ public class VolumeServiceImpl implements VolumeService {
private final DataObject volume; private final DataObject volume;
private final AsyncCallFuture<VolumeApiResult> future; private final AsyncCallFuture<VolumeApiResult> future;
/**
* @param callback
*/
public CreateVolumeContext(AsyncCompletionCallback<T> callback, DataObject volume, public CreateVolumeContext(AsyncCompletionCallback<T> callback, DataObject volume,
AsyncCallFuture<VolumeApiResult> future) { AsyncCallFuture<VolumeApiResult> future) {
super(callback); super(callback);
@ -178,9 +175,6 @@ public class VolumeServiceImpl implements VolumeService {
private final VolumeObject volume; private final VolumeObject volume;
private final AsyncCallFuture<VolumeApiResult> future; private final AsyncCallFuture<VolumeApiResult> future;
/**
* @param callback
*/
public DeleteVolumeContext(AsyncCompletionCallback<T> callback, VolumeObject volume, public DeleteVolumeContext(AsyncCompletionCallback<T> callback, VolumeObject volume,
AsyncCallFuture<VolumeApiResult> future) { AsyncCallFuture<VolumeApiResult> future) {
super(callback); super(callback);
@ -266,17 +260,7 @@ public class VolumeServiceImpl implements VolumeService {
@Override @Override
public VolumeEntity getVolumeEntity(long volumeId) { public VolumeEntity getVolumeEntity(long volumeId) {
VolumeVO vo = volDao.findById(volumeId); return null;
if (vo == null) {
return null;
}
if (vo.getPoolId() == null) {
return new VolumeEntityImpl(VolumeObject.getVolumeObject(null, vo), this);
} else {
PrimaryDataStore dataStore = dataStoreMgr.getPrimaryDataStore(vo.getPoolId());
return new VolumeEntityImpl(dataStore.getVolume(volumeId), this);
}
} }
class CreateBaseImageContext<T> extends AsyncRpcConext<T> { class CreateBaseImageContext<T> extends AsyncRpcConext<T> {
@ -315,15 +299,6 @@ public class VolumeServiceImpl implements VolumeService {
} }
static class CreateBaseImageResult extends CommandResult {
final TemplateInfo template;
public CreateBaseImageResult(TemplateInfo template) {
super();
this.template = template;
}
}
private TemplateInfo waitForTemplateDownloaded(PrimaryDataStore store, TemplateInfo template) { private TemplateInfo waitForTemplateDownloaded(PrimaryDataStore store, TemplateInfo template) {
int storagePoolMaxWaitSeconds = NumbersUtil.parseInt( int storagePoolMaxWaitSeconds = NumbersUtil.parseInt(
configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600); configDao.getValue(Config.StoragePoolMaxWaitSeconds.key()), 3600);
@ -571,9 +546,6 @@ public class VolumeServiceImpl implements VolumeService {
final VolumeInfo destVolume; final VolumeInfo destVolume;
final AsyncCallFuture<VolumeApiResult> future; final AsyncCallFuture<VolumeApiResult> future;
/**
* @param callback
*/
public CopyVolumeContext(AsyncCompletionCallback<T> callback, AsyncCallFuture<VolumeApiResult> future, public CopyVolumeContext(AsyncCompletionCallback<T> callback, AsyncCallFuture<VolumeApiResult> future,
VolumeInfo srcVolume, VolumeInfo destVolume, DataStore destStore) { VolumeInfo srcVolume, VolumeInfo destVolume, DataStore destStore) {
super(callback); super(callback);
@ -845,9 +817,6 @@ public class VolumeServiceImpl implements VolumeService {
final Map<VolumeInfo, DataStore> volumeToPool; final Map<VolumeInfo, DataStore> volumeToPool;
final AsyncCallFuture<CommandResult> future; final AsyncCallFuture<CommandResult> future;
/**
* @param callback
*/
public MigrateVmWithVolumesContext(AsyncCompletionCallback<T> callback, AsyncCallFuture<CommandResult> future, public MigrateVmWithVolumesContext(AsyncCompletionCallback<T> callback, AsyncCallFuture<CommandResult> future,
Map<VolumeInfo, DataStore> volumeToPool) { Map<VolumeInfo, DataStore> volumeToPool) {
super(callback); super(callback);

View File

@ -124,50 +124,32 @@ public class CloudStackImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
@Override @Override
public boolean attachCluster(DataStore store, ClusterScope scope) { public boolean attachCluster(DataStore store, ClusterScope scope) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) { public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) { public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean dettach() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean unmanaged() {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean maintain(DataStore store) { public boolean maintain(DataStore store) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean cancelMaintain(DataStore store) { public boolean cancelMaintain(DataStore store) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean deleteDataStore(DataStore store) { public boolean deleteDataStore(DataStore store) {
// TODO Auto-generated method stub
return false; return false;
} }
} }

View File

@ -53,8 +53,6 @@ public class S3ImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
ImageStoreHelper imageStoreHelper; ImageStoreHelper imageStoreHelper;
@Inject @Inject
ImageStoreProviderManager imageStoreMgr; ImageStoreProviderManager imageStoreMgr;
@Inject
S3Manager _s3Mgr;
protected List<? extends Discoverer> _discoverers; protected List<? extends Discoverer> _discoverers;
@ -83,12 +81,6 @@ public class S3ImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
s_logger.info("Trying to add a S3 store in data center " + dcId); s_logger.info("Trying to add a S3 store in data center " + dcId);
/*
* try{ // verify S3 parameters _s3Mgr.verifyS3Fields(details); } catch
* (DiscoveryException ex){ throw new
* InvalidParameterValueException("failed to verify S3 parameters!"); }
*/
Map<String, Object> imageStoreParameters = new HashMap<String, Object>(); Map<String, Object> imageStoreParameters = new HashMap<String, Object>();
imageStoreParameters.put("name", name); imageStoreParameters.put("name", name);
imageStoreParameters.put("zoneId", dcId); imageStoreParameters.put("zoneId", dcId);
@ -113,51 +105,31 @@ public class S3ImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
@Override @Override
public boolean attachCluster(DataStore store, ClusterScope scope) { public boolean attachCluster(DataStore store, ClusterScope scope) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) { public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) { public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean dettach() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean unmanaged() {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean maintain(DataStore store) { public boolean maintain(DataStore store) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean cancelMaintain(DataStore store) { public boolean cancelMaintain(DataStore store) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean deleteDataStore(DataStore store) { public boolean deleteDataStore(DataStore store) {
// TODO Auto-generated method stub
return false; return false;
} }
} }

View File

@ -37,15 +37,12 @@ public class SampleImageStoreDriverImpl extends BaseImageStoreDriverImpl {
public SampleImageStoreDriverImpl() { public SampleImageStoreDriverImpl() {
} }
@Override @Override
public DataStoreTO getStoreTO(DataStore store) { public DataStoreTO getStoreTO(DataStore store) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override @Override
public String createEntityExtractUrl(DataStore store, String installPath, ImageFormat format) { public String createEntityExtractUrl(DataStore store, String installPath, ImageFormat format) {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View File

@ -52,49 +52,31 @@ public class SampleImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
@Override @Override
public boolean attachCluster(DataStore store, ClusterScope scope) { public boolean attachCluster(DataStore store, ClusterScope scope) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) { public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisor) { public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisor) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean dettach() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean unmanaged() {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean maintain(DataStore store) { public boolean maintain(DataStore store) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean cancelMaintain(DataStore store) { public boolean cancelMaintain(DataStore store) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean deleteDataStore(DataStore store) { public boolean deleteDataStore(DataStore store) {
// TODO Auto-generated method stub
return false; return false;
} }
} }

View File

@ -44,8 +44,6 @@ public class SampleImageStoreProviderImpl implements ImageStoreProvider {
protected ImageStoreDriver driver; protected ImageStoreDriver driver;
@Inject @Inject
ImageStoreProviderManager storeMgr; ImageStoreProviderManager storeMgr;
long id;
String uuid;
@Override @Override
public DataStoreLifeCycle getDataStoreLifeCycle() { public DataStoreLifeCycle getDataStoreLifeCycle() {

View File

@ -39,7 +39,6 @@ public class SwiftImageStoreDriverImpl extends BaseImageStoreDriverImpl {
@Inject @Inject
ImageStoreDetailsDao _imageStoreDetailsDao; ImageStoreDetailsDao _imageStoreDetailsDao;
@Override @Override
public DataStoreTO getStoreTO(DataStore store) { public DataStoreTO getStoreTO(DataStore store) {
ImageStoreImpl imgStore = (ImageStoreImpl) store; ImageStoreImpl imgStore = (ImageStoreImpl) store;
@ -48,11 +47,9 @@ public class SwiftImageStoreDriverImpl extends BaseImageStoreDriverImpl {
details.get(ApiConstants.USERNAME), details.get(ApiConstants.KEY)); details.get(ApiConstants.USERNAME), details.get(ApiConstants.KEY));
} }
@Override @Override
public String createEntityExtractUrl(DataStore store, String installPath, ImageFormat format) { public String createEntityExtractUrl(DataStore store, String installPath, ImageFormat format) {
throw new UnsupportedServiceException("Extract entity url is not yet supported for Swift image store provider"); throw new UnsupportedServiceException("Extract entity url is not yet supported for Swift image store provider");
} }
} }

View File

@ -16,12 +16,11 @@
// under the License. // under the License.
package org.apache.cloudstack.storage.datastore.lifecycle; package org.apache.cloudstack.storage.datastore.lifecycle;
import java.util.HashMap; import com.cloud.agent.api.StoragePoolInfo;
import java.util.List; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import java.util.Map; import com.cloud.resource.ResourceManager;
import com.cloud.storage.DataStoreRole;
import javax.inject.Inject; import com.cloud.storage.ScopeType;
import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope; import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
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.HostScope; import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
@ -33,12 +32,9 @@ import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle; import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.cloud.agent.api.StoragePoolInfo; import javax.inject.Inject;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import java.util.HashMap;
import com.cloud.resource.Discoverer; import java.util.Map;
import com.cloud.resource.ResourceManager;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType;
public class SwiftImageStoreLifeCycleImpl implements ImageStoreLifeCycle { public class SwiftImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
@ -52,16 +48,6 @@ public class SwiftImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
@Inject @Inject
ImageStoreProviderManager imageStoreMgr; ImageStoreProviderManager imageStoreMgr;
protected List<? extends Discoverer> _discoverers;
public List<? extends Discoverer> getDiscoverers() {
return _discoverers;
}
public void setDiscoverers(List<? extends Discoverer> _discoverers) {
this._discoverers = _discoverers;
}
public SwiftImageStoreLifeCycleImpl() { public SwiftImageStoreLifeCycleImpl() {
} }
@ -99,50 +85,32 @@ public class SwiftImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
@Override @Override
public boolean attachCluster(DataStore store, ClusterScope scope) { public boolean attachCluster(DataStore store, ClusterScope scope) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) { public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) { public boolean attachZone(DataStore dataStore, ZoneScope scope, HypervisorType hypervisorType) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean dettach() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean unmanaged() {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean maintain(DataStore store) { public boolean maintain(DataStore store) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean cancelMaintain(DataStore store) { public boolean cancelMaintain(DataStore store) {
// TODO Auto-generated method stub
return false; return false;
} }
@Override @Override
public boolean deleteDataStore(DataStore store) { public boolean deleteDataStore(DataStore store) {
// TODO Auto-generated method stub
return false; return false;
} }
} }

View File

@ -18,27 +18,6 @@
*/ */
package org.apache.cloudstack.storage.datastore.driver; package org.apache.cloudstack.storage.datastore.driver;
import java.util.Set;
import javax.inject.Inject;
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPointSelector;
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.command.CreateObjectCommand;
import org.apache.cloudstack.storage.command.DeleteCommand;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.volume.VolumeObject;
import org.apache.log4j.Logger;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
import com.cloud.agent.api.storage.ResizeVolumeAnswer; import com.cloud.agent.api.storage.ResizeVolumeAnswer;
import com.cloud.agent.api.storage.ResizeVolumeCommand; import com.cloud.agent.api.storage.ResizeVolumeCommand;
@ -58,6 +37,16 @@ import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.snapshot.SnapshotManager; import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.vm.dao.VMInstanceDao; import com.cloud.vm.dao.VMInstanceDao;
import org.apache.cloudstack.engine.subsystem.api.storage.*;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.command.CreateObjectCommand;
import org.apache.cloudstack.storage.command.DeleteCommand;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.volume.VolumeObject;
import org.apache.log4j.Logger;
import javax.inject.Inject;
public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver { public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver {
private static final Logger s_logger = Logger.getLogger(CloudStackPrimaryDataStoreDriverImpl.class); private static final Logger s_logger = Logger.getLogger(CloudStackPrimaryDataStoreDriverImpl.class);
@ -84,12 +73,6 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
@Inject @Inject
EndPointSelector epSelector; EndPointSelector epSelector;
@Override
public String grantAccess(DataObject data, EndPoint ep) {
// TODO Auto-generated method stub
return null;
}
@Override @Override
public DataTO getTO(DataObject data) { public DataTO getTO(DataObject data) {
return null; return null;
@ -97,19 +80,6 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
@Override @Override
public DataStoreTO getStoreTO(DataStore store) { public DataStoreTO getStoreTO(DataStore store) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean revokeAccess(DataObject data, EndPoint ep) {
// TODO Auto-generated method stub
return false;
}
@Override
public Set<DataObject> listObjects(DataStore store) {
// TODO Auto-generated method stub
return null; return null;
} }
@ -126,7 +96,6 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
@Override @Override
public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) { public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
// TODO Auto-generated method stub
String errMsg = null; String errMsg = null;
Answer answer = null; Answer answer = null;
if (data.getType() == DataObjectType.VOLUME) { if (data.getType() == DataObjectType.VOLUME) {
@ -168,13 +137,10 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
@Override @Override
public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) { public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
// TODO Auto-generated method stub
} }
@Override @Override
public boolean canCopy(DataObject srcData, DataObject destData) { public boolean canCopy(DataObject srcData, DataObject destData) {
// TODO Auto-generated method stub
return false; return false;
} }
@ -205,8 +171,6 @@ public class CloudStackPrimaryDataStoreDriverImpl implements PrimaryDataStoreDri
@Override @Override
public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback) { public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback) {
// TODO Auto-generated method stub
} }
@Override @Override

View File

@ -417,18 +417,6 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
return true; return true;
} }
@Override
public boolean dettach() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean unmanaged() {
// TODO Auto-generated method stub
return false;
}
@Override @Override
public boolean maintain(DataStore dataStore) { public boolean maintain(DataStore dataStore) {
storagePoolAutmation.maintain(dataStore); storagePoolAutmation.maintain(dataStore);

Some files were not shown because too many files have changed in this diff Show More