diff --git a/api/pom.xml b/api/pom.xml
index 8ca258f12e3..3867e718ca7 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -36,10 +36,27 @@
gson
${cs.gson.version}
+
+ org.apache.cloudstack
+ cloud-framework-db
+ ${project.version}
+ test
+
install
- src
- test
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
diff --git a/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java b/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java
index 288f76b4463..41a9b795923 100644
--- a/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/ServiceOfferingResponse.java
@@ -18,7 +18,7 @@ package org.apache.cloudstack.api.response;
import java.util.Date;
-import javax.persistence.Column;
+import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseResponse;
@@ -26,7 +26,6 @@ import org.apache.cloudstack.api.EntityReference;
import com.cloud.offering.ServiceOffering;
import com.cloud.serializer.Param;
-import com.google.gson.annotations.SerializedName;
@EntityReference(value = ServiceOffering.class)
public class ServiceOfferingResponse extends BaseResponse {
@@ -141,7 +140,7 @@ public class ServiceOfferingResponse extends BaseResponse {
}
public void setSystemVmType(String vmtype) {
- this.vm_type = vmtype;
+ vm_type = vmtype;
}
diff --git a/api/src/org/apache/cloudstack/usage/Usage.java b/api/src/org/apache/cloudstack/usage/Usage.java
index 23f9d42f08b..1bb1e906b51 100644
--- a/api/src/org/apache/cloudstack/usage/Usage.java
+++ b/api/src/org/apache/cloudstack/usage/Usage.java
@@ -16,19 +16,8 @@
// under the License.
package org.apache.cloudstack.usage;
-import org.apache.cloudstack.api.InternalIdentity;
-
import java.util.Date;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.GenerationType;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
public interface Usage {
public long getId();
@@ -39,7 +28,7 @@ public interface Usage {
public Long getDomainId();
- public String getDescription();
+ public String getDescription();
public String getUsageDisplay();
diff --git a/utils/test/org/apache/cloudstack/test/utils/SpringUtils.java b/api/test/org/apache/cloudstack/test/utils/SpringUtils.java
similarity index 100%
rename from utils/test/org/apache/cloudstack/test/utils/SpringUtils.java
rename to api/test/org/apache/cloudstack/test/utils/SpringUtils.java
diff --git a/awsapi/pom.xml b/awsapi/pom.xml
index 2fe208912d5..317d1cea2c6 100644
--- a/awsapi/pom.xml
+++ b/awsapi/pom.xml
@@ -289,6 +289,11 @@
javassist
3.9.0.GA
+
+ org.apache.cloudstack
+ cloud-framework-db
+ ${project.version}
+
diff --git a/engine/api/pom.xml b/engine/api/pom.xml
index 1b8f26c2320..ccea255333b 100644
--- a/engine/api/pom.xml
+++ b/engine/api/pom.xml
@@ -25,6 +25,11 @@
cloud-utils
${project.version}
+
+ org.apache.cloudstack
+ cloud-framework-db
+ ${project.version}
+
org.apache.cloudstack
cloud-api
diff --git a/engine/schema/pom.xml b/engine/schema/pom.xml
index da40d9cc4a3..a9ad13fd02d 100644
--- a/engine/schema/pom.xml
+++ b/engine/schema/pom.xml
@@ -43,6 +43,11 @@
cloud-engine-components-api
${project.version}
+
+ org.apache.cloudstack
+ cloud-framework-db
+ ${project.version}
+
install
diff --git a/engine/storage/integration-test/pom.xml b/engine/storage/integration-test/pom.xml
index 4df44512e57..d082710134d 100644
--- a/engine/storage/integration-test/pom.xml
+++ b/engine/storage/integration-test/pom.xml
@@ -64,7 +64,7 @@
org.apache.cloudstack
- cloud-utils
+ cloud-api
${project.version}
test-jar
test
diff --git a/framework/cluster/pom.xml b/framework/cluster/pom.xml
index 116b6353258..131511ddb38 100644
--- a/framework/cluster/pom.xml
+++ b/framework/cluster/pom.xml
@@ -24,5 +24,10 @@
cloud-utils
${project.version}
+
+ org.apache.cloudstack
+ cloud-framework-db
+ ${project.version}
+
diff --git a/framework/db/pom.xml b/framework/db/pom.xml
index b4011c7b7ea..c23f96fc2c4 100644
--- a/framework/db/pom.xml
+++ b/framework/db/pom.xml
@@ -19,10 +19,34 @@
../pom.xml
+
+ javax.ejb
+ ejb-api
+ ${cs.ejb.version}
+
+
+ org.eclipse.persistence
+ javax.persistence
+ ${cs.jpa.version}
+
org.apache.cloudstack
cloud-utils
${project.version}
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ com/cloud/utils/testcase/*TestCase*
+ com/cloud/utils/db/*Test*
+
+
+
+
+
diff --git a/server/src/com/cloud/dao/EntityManagerImpl.java b/framework/db/src/com/cloud/dao/EntityManagerImpl.java
similarity index 85%
rename from server/src/com/cloud/dao/EntityManagerImpl.java
rename to framework/db/src/com/cloud/dao/EntityManagerImpl.java
index 14ea2bf0b71..bb493c0b795 100644
--- a/server/src/com/cloud/dao/EntityManagerImpl.java
+++ b/framework/db/src/com/cloud/dao/EntityManagerImpl.java
@@ -23,8 +23,6 @@ import java.util.Map;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
-import org.springframework.stereotype.Component;
-
import net.sf.ehcache.Cache;
import com.cloud.utils.component.ManagerBase;
@@ -35,7 +33,6 @@ import com.cloud.utils.db.GenericSearchBuilder;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
-@Component
@Local(value=EntityManager.class)
@SuppressWarnings("unchecked")
public class EntityManagerImpl extends ManagerBase implements EntityManager {
@@ -48,7 +45,6 @@ public class EntityManagerImpl extends ManagerBase implements EntityManager {
return dao.findById(id);
}
- @Override
public T findByIdIncludingRemoved(Class entityType, K id) {
GenericDao extends T, K> dao = (GenericDao extends T, K>)GenericDaoBase.getDao(entityType);
return dao.findByIdIncludingRemoved(id);
@@ -61,7 +57,6 @@ public class EntityManagerImpl extends ManagerBase implements EntityManager {
return dao.findByUuid(uuid);
}
- @Override
public T findByUuidIncludingRemoved(Class entityType, String uuid) {
// Finds and returns a unique VO using uuid, null if entity not found in db
GenericDao extends T, String> dao = (GenericDao extends T, String>)GenericDaoBase.getDao(entityType);
@@ -79,19 +74,16 @@ public class EntityManagerImpl extends ManagerBase implements EntityManager {
return dao.listAll();
}
- @Override
public T persist(T t) {
GenericDao dao = (GenericDao)GenericDaoBase.getDao((Class)t.getClass());
return dao.persist(t);
}
- @Override
public SearchBuilder createSearchBuilder(Class entityType) {
GenericDao dao = (GenericDao)GenericDaoBase.getDao(entityType);
return dao.createSearchBuilder();
}
- @Override
public GenericSearchBuilder createGenericSearchBuilder(Class entityType, Class resultType) {
GenericDao dao = (GenericDao)GenericDaoBase.getDao(entityType);
return dao.createSearchBuilder((Class)resultType.getClass());
@@ -100,22 +92,6 @@ public class EntityManagerImpl extends ManagerBase implements EntityManager {
@Override
public boolean configure(String name, Map params) throws ConfigurationException {
_name = name;
- /*
- String threadId = Long.toString(Thread.currentThread().getId());
-
- CacheManager cm = CacheManager.create();
-
- _cache = cm.getCache(threadId);
-
- if (_cache == null) {
- int maxElements = NumbersUtil.parseInt((String)params.get("cache.size"), 100);
- int live = NumbersUtil.parseInt((String)params.get("cache.time.to.live"), 300);
- int idle = NumbersUtil.parseInt((String)params.get("cache.time.to.idle"), 300);
-
- _cache = new Cache(threadId, maxElements, false, live == -1, live == -1 ? Integer.MAX_VALUE : live, idle);
- cm.addCache(_cache);
-
- }*/
return true;
}
@@ -135,7 +111,6 @@ public class EntityManagerImpl extends ManagerBase implements EntityManager {
return _name;
}
- @Override
public List search(Class entityType, SearchCriteria sc) {
GenericDao dao = (GenericDao)GenericDaoBase.getDao(entityType);
return dao.customSearch(sc, null);
diff --git a/utils/src/com/cloud/utils/crypt/EncryptionSecretKeyChanger.java b/framework/db/src/com/cloud/utils/crypt/EncryptionSecretKeyChanger.java
similarity index 100%
rename from utils/src/com/cloud/utils/crypt/EncryptionSecretKeyChanger.java
rename to framework/db/src/com/cloud/utils/crypt/EncryptionSecretKeyChanger.java
diff --git a/utils/src/com/cloud/utils/db/Attribute.java b/framework/db/src/com/cloud/utils/db/Attribute.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/Attribute.java
rename to framework/db/src/com/cloud/utils/db/Attribute.java
diff --git a/utils/src/com/cloud/utils/db/ConnectionConcierge.java b/framework/db/src/com/cloud/utils/db/ConnectionConcierge.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/ConnectionConcierge.java
rename to framework/db/src/com/cloud/utils/db/ConnectionConcierge.java
diff --git a/utils/src/com/cloud/utils/db/ConnectionConciergeMBean.java b/framework/db/src/com/cloud/utils/db/ConnectionConciergeMBean.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/ConnectionConciergeMBean.java
rename to framework/db/src/com/cloud/utils/db/ConnectionConciergeMBean.java
diff --git a/utils/src/com/cloud/utils/db/DB.java b/framework/db/src/com/cloud/utils/db/DB.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/DB.java
rename to framework/db/src/com/cloud/utils/db/DB.java
diff --git a/utils/src/com/cloud/utils/db/DbUtil.java b/framework/db/src/com/cloud/utils/db/DbUtil.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/DbUtil.java
rename to framework/db/src/com/cloud/utils/db/DbUtil.java
diff --git a/utils/src/com/cloud/utils/db/EcInfo.java b/framework/db/src/com/cloud/utils/db/EcInfo.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/EcInfo.java
rename to framework/db/src/com/cloud/utils/db/EcInfo.java
diff --git a/utils/src/com/cloud/utils/db/Encrypt.java b/framework/db/src/com/cloud/utils/db/Encrypt.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/Encrypt.java
rename to framework/db/src/com/cloud/utils/db/Encrypt.java
diff --git a/utils/src/com/cloud/utils/db/Filter.java b/framework/db/src/com/cloud/utils/db/Filter.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/Filter.java
rename to framework/db/src/com/cloud/utils/db/Filter.java
diff --git a/utils/src/com/cloud/utils/db/GenericDao.java b/framework/db/src/com/cloud/utils/db/GenericDao.java
similarity index 99%
rename from utils/src/com/cloud/utils/db/GenericDao.java
rename to framework/db/src/com/cloud/utils/db/GenericDao.java
index 1c830c85f5e..66d0f670370 100755
--- a/utils/src/com/cloud/utils/db/GenericDao.java
+++ b/framework/db/src/com/cloud/utils/db/GenericDao.java
@@ -215,7 +215,7 @@ public interface GenericDao {
/**
* Remove based on the search criteria. This will delete if the VO object
- * does not have a REMOVED column.
+ * does not have a REMOVED column.
* @param sc search criteria to match
* @return rows removed.
*/
diff --git a/utils/src/com/cloud/utils/db/GenericDaoBase.java b/framework/db/src/com/cloud/utils/db/GenericDaoBase.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/GenericDaoBase.java
rename to framework/db/src/com/cloud/utils/db/GenericDaoBase.java
diff --git a/utils/src/com/cloud/utils/db/GenericSearchBuilder.java b/framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/GenericSearchBuilder.java
rename to framework/db/src/com/cloud/utils/db/GenericSearchBuilder.java
diff --git a/utils/src/com/cloud/utils/db/GlobalLock.java b/framework/db/src/com/cloud/utils/db/GlobalLock.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/GlobalLock.java
rename to framework/db/src/com/cloud/utils/db/GlobalLock.java
diff --git a/utils/src/com/cloud/utils/db/GroupBy.java b/framework/db/src/com/cloud/utils/db/GroupBy.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/GroupBy.java
rename to framework/db/src/com/cloud/utils/db/GroupBy.java
diff --git a/utils/src/com/cloud/utils/db/JoinBuilder.java b/framework/db/src/com/cloud/utils/db/JoinBuilder.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/JoinBuilder.java
rename to framework/db/src/com/cloud/utils/db/JoinBuilder.java
diff --git a/utils/src/com/cloud/utils/db/JoinType.java b/framework/db/src/com/cloud/utils/db/JoinType.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/JoinType.java
rename to framework/db/src/com/cloud/utils/db/JoinType.java
diff --git a/utils/src/com/cloud/utils/db/Merovingian2.java b/framework/db/src/com/cloud/utils/db/Merovingian2.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/Merovingian2.java
rename to framework/db/src/com/cloud/utils/db/Merovingian2.java
diff --git a/utils/src/com/cloud/utils/db/MerovingianMBean.java b/framework/db/src/com/cloud/utils/db/MerovingianMBean.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/MerovingianMBean.java
rename to framework/db/src/com/cloud/utils/db/MerovingianMBean.java
diff --git a/utils/src/com/cloud/utils/db/ScriptRunner.java b/framework/db/src/com/cloud/utils/db/ScriptRunner.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/ScriptRunner.java
rename to framework/db/src/com/cloud/utils/db/ScriptRunner.java
diff --git a/utils/src/com/cloud/utils/db/SearchBuilder.java b/framework/db/src/com/cloud/utils/db/SearchBuilder.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/SearchBuilder.java
rename to framework/db/src/com/cloud/utils/db/SearchBuilder.java
diff --git a/utils/src/com/cloud/utils/db/SearchCriteria.java b/framework/db/src/com/cloud/utils/db/SearchCriteria.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/SearchCriteria.java
rename to framework/db/src/com/cloud/utils/db/SearchCriteria.java
diff --git a/utils/src/com/cloud/utils/db/SearchCriteria2.java b/framework/db/src/com/cloud/utils/db/SearchCriteria2.java
similarity index 97%
rename from utils/src/com/cloud/utils/db/SearchCriteria2.java
rename to framework/db/src/com/cloud/utils/db/SearchCriteria2.java
index 5875106363f..67e95b09244 100755
--- a/utils/src/com/cloud/utils/db/SearchCriteria2.java
+++ b/framework/db/src/com/cloud/utils/db/SearchCriteria2.java
@@ -49,7 +49,7 @@ public class SearchCriteria2 implements SearchCriteriaService, Metho
protected SelectType _selectType;
protected Class _entityBeanType;
- protected SearchCriteria2(T entity, Class resultType, final Map attrs, GenericDao extends Serializable, ? extends Serializable> dao) {
+ protected SearchCriteria2(T entity, Class resultType, final Map attrs, GenericDao extends Serializable, ? extends Serializable> dao) {
_entityBeanType = (Class)entity.getClass();
_dao = dao;
_resultType = resultType;
@@ -125,7 +125,7 @@ public class SearchCriteria2 implements SearchCriteriaService, Metho
if (isSelectAll()) {
return (List)_dao.search(sc1, null);
} else {
- return (List)_dao.customSearch(sc1, null);
+ return _dao.customSearch(sc1, null);
}
}
@@ -135,7 +135,7 @@ public class SearchCriteria2 implements SearchCriteriaService, Metho
@Override
public T getEntity() {
- return (T) _entity;
+ return _entity;
}
private SearchCriteria createSearchCriteria() {
diff --git a/utils/src/com/cloud/utils/db/SearchCriteriaService.java b/framework/db/src/com/cloud/utils/db/SearchCriteriaService.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/SearchCriteriaService.java
rename to framework/db/src/com/cloud/utils/db/SearchCriteriaService.java
diff --git a/utils/src/com/cloud/utils/db/SequenceFetcher.java b/framework/db/src/com/cloud/utils/db/SequenceFetcher.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/SequenceFetcher.java
rename to framework/db/src/com/cloud/utils/db/SequenceFetcher.java
diff --git a/utils/src/com/cloud/utils/db/SqlGenerator.java b/framework/db/src/com/cloud/utils/db/SqlGenerator.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/SqlGenerator.java
rename to framework/db/src/com/cloud/utils/db/SqlGenerator.java
diff --git a/utils/src/com/cloud/utils/db/StateMachine.java b/framework/db/src/com/cloud/utils/db/StateMachine.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/StateMachine.java
rename to framework/db/src/com/cloud/utils/db/StateMachine.java
diff --git a/utils/src/com/cloud/utils/db/Transaction.java b/framework/db/src/com/cloud/utils/db/Transaction.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/Transaction.java
rename to framework/db/src/com/cloud/utils/db/Transaction.java
diff --git a/utils/src/com/cloud/utils/db/TransactionAttachment.java b/framework/db/src/com/cloud/utils/db/TransactionAttachment.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/TransactionAttachment.java
rename to framework/db/src/com/cloud/utils/db/TransactionAttachment.java
diff --git a/utils/src/com/cloud/utils/db/TransactionContextBuilder.java b/framework/db/src/com/cloud/utils/db/TransactionContextBuilder.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/TransactionContextBuilder.java
rename to framework/db/src/com/cloud/utils/db/TransactionContextBuilder.java
diff --git a/utils/src/com/cloud/utils/db/TransactionMBean.java b/framework/db/src/com/cloud/utils/db/TransactionMBean.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/TransactionMBean.java
rename to framework/db/src/com/cloud/utils/db/TransactionMBean.java
diff --git a/utils/src/com/cloud/utils/db/TransactionMBeanImpl.java b/framework/db/src/com/cloud/utils/db/TransactionMBeanImpl.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/TransactionMBeanImpl.java
rename to framework/db/src/com/cloud/utils/db/TransactionMBeanImpl.java
diff --git a/utils/src/com/cloud/utils/db/UpdateBuilder.java b/framework/db/src/com/cloud/utils/db/UpdateBuilder.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/UpdateBuilder.java
rename to framework/db/src/com/cloud/utils/db/UpdateBuilder.java
diff --git a/utils/src/com/cloud/utils/db/UpdateFilter.java b/framework/db/src/com/cloud/utils/db/UpdateFilter.java
similarity index 100%
rename from utils/src/com/cloud/utils/db/UpdateFilter.java
rename to framework/db/src/com/cloud/utils/db/UpdateFilter.java
diff --git a/utils/test/com/cloud/utils/db/DbAnnotatedBase.java b/framework/db/test/com/cloud/utils/db/DbAnnotatedBase.java
similarity index 100%
rename from utils/test/com/cloud/utils/db/DbAnnotatedBase.java
rename to framework/db/test/com/cloud/utils/db/DbAnnotatedBase.java
diff --git a/utils/test/com/cloud/utils/db/DbAnnotatedBaseDerived.java b/framework/db/test/com/cloud/utils/db/DbAnnotatedBaseDerived.java
similarity index 100%
rename from utils/test/com/cloud/utils/db/DbAnnotatedBaseDerived.java
rename to framework/db/test/com/cloud/utils/db/DbAnnotatedBaseDerived.java
diff --git a/utils/test/com/cloud/utils/db/DbTestDao.java b/framework/db/test/com/cloud/utils/db/DbTestDao.java
similarity index 100%
rename from utils/test/com/cloud/utils/db/DbTestDao.java
rename to framework/db/test/com/cloud/utils/db/DbTestDao.java
diff --git a/utils/test/com/cloud/utils/db/DbTestUtils.java b/framework/db/test/com/cloud/utils/db/DbTestUtils.java
similarity index 100%
rename from utils/test/com/cloud/utils/db/DbTestUtils.java
rename to framework/db/test/com/cloud/utils/db/DbTestUtils.java
diff --git a/utils/test/com/cloud/utils/db/DbTestVO.java b/framework/db/test/com/cloud/utils/db/DbTestVO.java
similarity index 100%
rename from utils/test/com/cloud/utils/db/DbTestVO.java
rename to framework/db/test/com/cloud/utils/db/DbTestVO.java
diff --git a/utils/test/com/cloud/utils/db/DummyComponent.java b/framework/db/test/com/cloud/utils/db/DummyComponent.java
similarity index 100%
rename from utils/test/com/cloud/utils/db/DummyComponent.java
rename to framework/db/test/com/cloud/utils/db/DummyComponent.java
diff --git a/utils/test/com/cloud/utils/db/ElementCollectionTest.java b/framework/db/test/com/cloud/utils/db/ElementCollectionTest.java
similarity index 100%
rename from utils/test/com/cloud/utils/db/ElementCollectionTest.java
rename to framework/db/test/com/cloud/utils/db/ElementCollectionTest.java
diff --git a/utils/test/com/cloud/utils/db/GlobalLockTest.java b/framework/db/test/com/cloud/utils/db/GlobalLockTest.java
similarity index 97%
rename from utils/test/com/cloud/utils/db/GlobalLockTest.java
rename to framework/db/test/com/cloud/utils/db/GlobalLockTest.java
index 01e1e332fc8..8d6ff41f519 100644
--- a/utils/test/com/cloud/utils/db/GlobalLockTest.java
+++ b/framework/db/test/com/cloud/utils/db/GlobalLockTest.java
@@ -22,10 +22,7 @@ import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import junit.framework.Assert;
-
import com.cloud.utils.Profiler;
-import com.cloud.utils.testcase.Log4jEnabledTestCase;
@RunWith(SpringJUnit4ClassRunner.class)
@@ -42,6 +39,7 @@ public class GlobalLockTest {
timeoutSeconds = timeout;
jobDuration = duration;
}
+ @Override
public void run() {
boolean locked = false;
try {
diff --git a/utils/test/com/cloud/utils/db/Merovingian2Test.java b/framework/db/test/com/cloud/utils/db/Merovingian2Test.java
similarity index 100%
rename from utils/test/com/cloud/utils/db/Merovingian2Test.java
rename to framework/db/test/com/cloud/utils/db/Merovingian2Test.java
diff --git a/utils/test/com/cloud/utils/db/TransactionContextBuilderTest.java b/framework/db/test/com/cloud/utils/db/TransactionContextBuilderTest.java
similarity index 100%
rename from utils/test/com/cloud/utils/db/TransactionContextBuilderTest.java
rename to framework/db/test/com/cloud/utils/db/TransactionContextBuilderTest.java
diff --git a/utils/test/com/cloud/utils/db/TransactionTest.java b/framework/db/test/com/cloud/utils/db/TransactionTest.java
similarity index 100%
rename from utils/test/com/cloud/utils/db/TransactionTest.java
rename to framework/db/test/com/cloud/utils/db/TransactionTest.java
diff --git a/plugins/hypervisors/vmware/pom.xml b/plugins/hypervisors/vmware/pom.xml
index 755244f5f61..ad764117136 100644
--- a/plugins/hypervisors/vmware/pom.xml
+++ b/plugins/hypervisors/vmware/pom.xml
@@ -64,15 +64,5 @@
wsdl4j
1.4
-
- junit
- junit
- 4.10
-
-
- org.mockito
- mockito-all
- 1.9.5
-
diff --git a/plugins/pom.xml b/plugins/pom.xml
index ff1e9c9c78d..e2f767a462c 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -77,7 +77,7 @@
org.apache.cloudstack
- cloud-utils
+ cloud-api
${project.version}
test-jar
test
diff --git a/server/pom.xml b/server/pom.xml
index 484d603b0e2..20bcecedfc7 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -92,7 +92,7 @@
org.apache.cloudstack
- cloud-utils
+ cloud-api
${project.version}
test-jar
test
diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java
index 223c6b35999..65e21135369 100755
--- a/server/src/com/cloud/api/ApiDispatcher.java
+++ b/server/src/com/cloud/api/ApiDispatcher.java
@@ -352,7 +352,7 @@ public class ApiDispatcher {
for (Class> entity : entities) {
// For backward compatibility, we search within removed entities and let service layer deal
// with removed ones, return empty response or error
- Object objVO = s_instance._entityMgr.findByUuidIncludingRemoved(entity, uuid);
+ Object objVO = s_instance._entityMgr.findByUuid(entity, uuid);
if (objVO == null) {
continue;
}
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index f7b740bd3f8..c1ae7d0c3c3 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -31,6 +31,9 @@ import java.util.TimeZone;
import javax.inject.Inject;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.affinity.AffinityGroup;
@@ -70,6 +73,7 @@ import org.apache.cloudstack.api.response.HostForMigrationResponse;
import org.apache.cloudstack.api.response.HostResponse;
import org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse;
import org.apache.cloudstack.api.response.IPAddressResponse;
+import org.apache.cloudstack.api.response.ImageStoreResponse;
import org.apache.cloudstack.api.response.InstanceGroupResponse;
import org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse;
import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
@@ -86,7 +90,6 @@ import org.apache.cloudstack.api.response.NetworkOfferingResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.api.response.NicResponse;
import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
-import org.apache.cloudstack.api.response.ImageStoreResponse;
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
import org.apache.cloudstack.api.response.PodResponse;
import org.apache.cloudstack.api.response.PortableIpRangeResponse;
@@ -144,9 +147,6 @@ import org.apache.cloudstack.usage.Usage;
import org.apache.cloudstack.usage.UsageService;
import org.apache.cloudstack.usage.UsageTypes;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
import com.cloud.api.query.ViewResponseHelper;
import com.cloud.api.query.vo.AccountJoinVO;
import com.cloud.api.query.vo.AsyncJobJoinVO;
@@ -301,9 +301,9 @@ public class ApiResponseHelper implements ResponseGenerator {
public final Logger s_logger = Logger.getLogger(ApiResponseHelper.class);
private static final DecimalFormat s_percentFormat = new DecimalFormat("##.##");
@Inject
- private EntityManager _entityMgr = null;
+ private final EntityManager _entityMgr = null;
@Inject
- private UsageService _usageSvc = null;
+ private final UsageService _usageSvc = null;
@Inject NetworkModel _ntwkModel;
@Override
@@ -831,7 +831,7 @@ public class ApiResponseHelper implements ResponseGenerator {
capacityResponse.setCapacityType(capacity.getCapacityType());
capacityResponse.setCapacityUsed(capacity.getUsedCapacity());
if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_CPU) {
- capacityResponse.setCapacityTotal(new Long((long) (capacity.getTotalCapacity())));
+ capacityResponse.setCapacityTotal(new Long((capacity.getTotalCapacity())));
} else if (capacity.getCapacityType() == Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED) {
List c = ApiDBUtils.findNonSharedStorageForClusterPodZone(null, pod.getId(), null);
capacityResponse.setCapacityTotal(capacity.getTotalCapacity() - c.get(0).getTotalCapacity());
@@ -1409,7 +1409,7 @@ public class ApiResponseHelper implements ResponseGenerator {
templateResponse.setOsTypeName("");
}
- final Account account = ApiDBUtils.findAccountByIdIncludingRemoved(iso.getAccountId());
+ final Account account = ApiDBUtils.findAccountById(iso.getAccountId());
populateAccount(templateResponse, account.getId());
populateDomain(templateResponse, account.getDomainId());
@@ -1466,7 +1466,7 @@ public class ApiResponseHelper implements ResponseGenerator {
isoResponse.setOsTypeId("-1");
isoResponse.setOsTypeName("");
}
- Account account = ApiDBUtils.findAccountByIdIncludingRemoved(iso.getAccountId());
+ Account account = ApiDBUtils.findAccountById(iso.getAccountId());
populateAccount(isoResponse, account.getId());
populateDomain(isoResponse, account.getDomainId());
boolean isAdmin = false;
@@ -1521,7 +1521,7 @@ public class ApiResponseHelper implements ResponseGenerator {
isoResponse.setOsTypeName("");
}
- Account account = ApiDBUtils.findAccountByIdIncludingRemoved(iso.getAccountId());
+ Account account = ApiDBUtils.findAccountById(iso.getAccountId());
populateAccount(isoResponse, account.getId());
populateDomain(isoResponse, account.getDomainId());
@@ -1578,7 +1578,7 @@ public class ApiResponseHelper implements ResponseGenerator {
isoResponses.add(isoResponse);
return isoResponses;
}
-*/
+ */
@Override
public SecurityGroupResponse createSecurityGroupResponse(SecurityGroup group) {
@@ -1909,7 +1909,7 @@ public class ApiResponseHelper implements ResponseGenerator {
regularAccounts.add(accountName);
} else {
// convert account to projectIds
- Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
+ Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
if (project.getUuid() != null && !project.getUuid().isEmpty())
projectIds.add(project.getUuid());
@@ -2211,7 +2211,7 @@ public class ApiResponseHelper implements ResponseGenerator {
}
// populate network offering information
- NetworkOffering networkOffering = (NetworkOffering) ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
+ NetworkOffering networkOffering = ApiDBUtils.findNetworkOfferingById(network.getNetworkOfferingId());
if (networkOffering != null) {
response.setNetworkOfferingId(networkOffering.getUuid());
response.setNetworkOfferingName(networkOffering.getName());
@@ -2455,11 +2455,11 @@ public class ApiResponseHelper implements ResponseGenerator {
// ControlledEntity id to uuid conversion are all done.
// currently code is scattered in
private void populateOwner(ControlledEntityResponse response, ControlledEntity object) {
- Account account = ApiDBUtils.findAccountByIdIncludingRemoved(object.getAccountId());
+ Account account = ApiDBUtils.findAccountById(object.getAccountId());
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
// find the project
- Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
+ Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
response.setProjectId(project.getUuid());
response.setProjectName(project.getName());
} else {
@@ -2485,10 +2485,10 @@ public class ApiResponseHelper implements ResponseGenerator {
}
private void populateAccount(ControlledEntityResponse response, long accountId) {
- Account account = ApiDBUtils.findAccountByIdIncludingRemoved(accountId);
+ Account account = ApiDBUtils.findAccountById(accountId);
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
// find the project
- Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
+ Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
response.setProjectId(project.getUuid());
response.setProjectName(project.getName());
response.setAccountName(account.getAccountName());
@@ -3273,10 +3273,10 @@ public class ApiResponseHelper implements ResponseGenerator {
public UsageRecordResponse createUsageResponse(Usage usageRecord) {
UsageRecordResponse usageRecResponse = new UsageRecordResponse();
- Account account = ApiDBUtils.findAccountByIdIncludingRemoved(usageRecord.getAccountId());
+ Account account = ApiDBUtils.findAccountById(usageRecord.getAccountId());
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
//find the project
- Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getId());
+ Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
usageRecResponse.setProjectId(project.getUuid());
usageRecResponse.setProjectName(project.getName());
} else {
@@ -3299,7 +3299,7 @@ public class ApiResponseHelper implements ResponseGenerator {
usageRecResponse.setUsage(usageRecord.getUsageDisplay());
usageRecResponse.setUsageType(usageRecord.getUsageType());
if (usageRecord.getVmInstanceId() != null) {
- VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getVmInstanceId());
+ VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getVmInstanceId());
usageRecResponse.setVirtualMachineId(vm.getUuid());
}
usageRecResponse.setVmName(usageRecord.getVmName());
@@ -3311,11 +3311,11 @@ public class ApiResponseHelper implements ResponseGenerator {
}
if(usageRecord.getUsageType() == UsageTypes.RUNNING_VM || usageRecord.getUsageType() == UsageTypes.ALLOCATED_VM){
- ServiceOfferingVO svcOffering = _entityMgr.findByIdIncludingRemoved(ServiceOfferingVO.class, usageRecord.getOfferingId().toString());
+ ServiceOfferingVO svcOffering = _entityMgr.findById(ServiceOfferingVO.class, usageRecord.getOfferingId().toString());
//Service Offering Id
usageRecResponse.setOfferingId(svcOffering.getUuid());
//VM Instance ID
- VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getUsageId().toString());
+ VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(vm.getUuid());
//Hypervisor Type
usageRecResponse.setType(usageRecord.getType());
@@ -3326,7 +3326,7 @@ public class ApiResponseHelper implements ResponseGenerator {
//isSystem
usageRecResponse.setSystem((usageRecord.getSize() == 1)?true:false);
//IP Address ID
- IPAddressVO ip = _entityMgr.findByIdIncludingRemoved(IPAddressVO.class, usageRecord.getUsageId().toString());
+ IPAddressVO ip = _entityMgr.findById(IPAddressVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(ip.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_SENT || usageRecord.getUsageType() == UsageTypes.NETWORK_BYTES_RECEIVED){
@@ -3334,15 +3334,15 @@ public class ApiResponseHelper implements ResponseGenerator {
usageRecResponse.setType(usageRecord.getType());
if(usageRecord.getType().equals("DomainRouter")){
//Domain Router Id
- VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getUsageId().toString());
+ VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(vm.getUuid());
} else {
//External Device Host Id
- HostVO host = _entityMgr.findByIdIncludingRemoved(HostVO.class, usageRecord.getUsageId().toString());
+ HostVO host = _entityMgr.findById(HostVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(host.getUuid());
}
//Network ID
- NetworkVO network = _entityMgr.findByIdIncludingRemoved(NetworkVO.class, usageRecord.getNetworkId().toString());
+ NetworkVO network = _entityMgr.findById(NetworkVO.class, usageRecord.getNetworkId().toString());
usageRecResponse.setNetworkId(network.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.VM_DISK_IO_READ || usageRecord.getUsageType() == UsageTypes.VM_DISK_IO_WRITE ||
@@ -3350,27 +3350,27 @@ public class ApiResponseHelper implements ResponseGenerator {
//Device Type
usageRecResponse.setType(usageRecord.getType());
//VM Instance Id
- VMInstanceVO vm = _entityMgr.findByIdIncludingRemoved(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
+ VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, usageRecord.getVmInstanceId().toString());
usageRecResponse.setVirtualMachineId(vm.getUuid());
//Volume ID
- VolumeVO volume = _entityMgr.findByIdIncludingRemoved(VolumeVO.class, usageRecord.getUsageId().toString());
+ VolumeVO volume = _entityMgr.findById(VolumeVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(volume.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.VOLUME){
//Volume ID
- VolumeVO volume = _entityMgr.findByIdIncludingRemoved(VolumeVO.class, usageRecord.getUsageId().toString());
+ VolumeVO volume = _entityMgr.findById(VolumeVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(volume.getUuid());
//Volume Size
usageRecResponse.setSize(usageRecord.getSize());
//Disk Offering Id
if(usageRecord.getOfferingId() != null){
- DiskOfferingVO diskOff = _entityMgr.findByIdIncludingRemoved(DiskOfferingVO.class, usageRecord.getOfferingId().toString());
+ DiskOfferingVO diskOff = _entityMgr.findById(DiskOfferingVO.class, usageRecord.getOfferingId().toString());
usageRecResponse.setOfferingId(diskOff.getUuid());
}
} else if(usageRecord.getUsageType() == UsageTypes.TEMPLATE || usageRecord.getUsageType() == UsageTypes.ISO){
//Template/ISO ID
- VMTemplateVO tmpl = _entityMgr.findByIdIncludingRemoved(VMTemplateVO.class, usageRecord.getUsageId().toString());
+ VMTemplateVO tmpl = _entityMgr.findById(VMTemplateVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(tmpl.getUuid());
//Template/ISO Size
usageRecResponse.setSize(usageRecord.getSize());
@@ -3382,35 +3382,35 @@ public class ApiResponseHelper implements ResponseGenerator {
} else if(usageRecord.getUsageType() == UsageTypes.SNAPSHOT){
//Snapshot ID
- SnapshotVO snap = _entityMgr.findByIdIncludingRemoved(SnapshotVO.class, usageRecord.getUsageId().toString());
+ SnapshotVO snap = _entityMgr.findById(SnapshotVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(snap.getUuid());
//Snapshot Size
usageRecResponse.setSize(usageRecord.getSize());
} else if(usageRecord.getUsageType() == UsageTypes.LOAD_BALANCER_POLICY){
//Load Balancer Policy ID
- LoadBalancerVO lb = _entityMgr.findByIdIncludingRemoved(LoadBalancerVO.class, usageRecord.getUsageId().toString());
+ LoadBalancerVO lb = _entityMgr.findById(LoadBalancerVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(lb.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.PORT_FORWARDING_RULE){
//Port Forwarding Rule ID
- PortForwardingRuleVO pf = _entityMgr.findByIdIncludingRemoved(PortForwardingRuleVO.class, usageRecord.getUsageId().toString());
+ PortForwardingRuleVO pf = _entityMgr.findById(PortForwardingRuleVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(pf.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.NETWORK_OFFERING){
//Network Offering Id
- NetworkOfferingVO netOff = _entityMgr.findByIdIncludingRemoved(NetworkOfferingVO.class, usageRecord.getOfferingId().toString());
+ NetworkOfferingVO netOff = _entityMgr.findById(NetworkOfferingVO.class, usageRecord.getOfferingId().toString());
usageRecResponse.setOfferingId(netOff.getUuid());
//is Default
usageRecResponse.setDefault((usageRecord.getUsageId() == 1)? true:false);
} else if(usageRecord.getUsageType() == UsageTypes.VPN_USERS){
//VPN User ID
- VpnUserVO vpnUser = _entityMgr.findByIdIncludingRemoved(VpnUserVO.class, usageRecord.getUsageId().toString());
+ VpnUserVO vpnUser = _entityMgr.findById(VpnUserVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(vpnUser.getUuid());
} else if(usageRecord.getUsageType() == UsageTypes.SECURITY_GROUP){
//Security Group Id
- SecurityGroupVO sg = _entityMgr.findByIdIncludingRemoved(SecurityGroupVO.class, usageRecord.getUsageId().toString());
+ SecurityGroupVO sg = _entityMgr.findById(SecurityGroupVO.class, usageRecord.getUsageId().toString());
usageRecResponse.setUsageId(sg.getUuid());
}
diff --git a/usage/pom.xml b/usage/pom.xml
index af08f535294..2051d5eb5bf 100644
--- a/usage/pom.xml
+++ b/usage/pom.xml
@@ -28,7 +28,7 @@
org.apache.cloudstack
- cloud-utils
+ cloud-api
${project.version}
test-jar
test
diff --git a/utils/pom.xml b/utils/pom.xml
index e8aa805d778..686afddc4b8 100644
--- a/utils/pom.xml
+++ b/utils/pom.xml
@@ -82,11 +82,6 @@
jsch
${cs.jsch.version}
-
- org.eclipse.persistence
- javax.persistence
- ${cs.jpa.version}
-
org.jasypt
jasypt
diff --git a/utils/src/com/cloud/utils/AnnotationHelper.java b/utils/src/com/cloud/utils/AnnotationHelper.java
deleted file mode 100755
index e7a6166677e..00000000000
--- a/utils/src/com/cloud/utils/AnnotationHelper.java
+++ /dev/null
@@ -1,57 +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
-// 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 com.cloud.utils;
-
-import javax.persistence.Table;
-
-import org.apache.log4j.Logger;
-
-
-public class AnnotationHelper extends Object {
- // This class contains routines to help query annotation elements of objects.
-
- public static final Logger s_logger = Logger.getLogger(AnnotationHelper.class.getName());
-
- public static String getTableName(Object proxyObj) {
- // The cglib class is generated by cglib during runtime.
-
- Class> curClass = proxyObj.getClass();
- if (curClass == null) {
- s_logger.trace("Could not retrieve class information for proxy object");
- return null;
- }
-
- while (curClass.getSuperclass() != null && curClass.getSuperclass().getName() != "java.lang.Object") {
- curClass = curClass.getSuperclass();
- }
- // At this point, curClass is the root base class of proxyObj's class, and curClass is not java.lang.Object.
-
- Table tabObj = curClass.getAnnotation(Table.class);
-
- if (tabObj == null) {
- s_logger.trace(curClass + "does not have a Table annotation");
- return null;
- }
-
- return tabObj.name();
- }
-
-}
-
-
-
-
diff --git a/utils/src/com/cloud/utils/db/EntityManager.java b/utils/src/com/cloud/utils/db/EntityManager.java
index 24e12f8ea1f..49f4f720698 100644
--- a/utils/src/com/cloud/utils/db/EntityManager.java
+++ b/utils/src/com/cloud/utils/db/EntityManager.java
@@ -34,16 +34,6 @@ public interface EntityManager {
*/
public T findById(Class entityType, K id);
- /**
- * Finds an entity by its id including removed.
- * @param class of the entity you're trying to find.
- * @param class of the id that the entity uses.
- * @param entityType Type of the entity.
- * @param id id value
- * @return T if found; null if not.
- */
- public T findByIdIncludingRemoved(Class entityType, K id);
-
/**
* Finds a unique entity by uuid string
* @param entity class
@@ -53,15 +43,6 @@ public interface EntityManager {
*/
public T findByUuid(Class entityType, String uuid);
- /**
- * Finds a unique entity by uuid string
- * @param entity class
- * @param entityType type of entity you're looking for.
- * @param uuid the unique id
- * @return T if found, null if not.
- */
- public T findByUuidIncludingRemoved(Class entityType, String uuid);
-
/**
* Finds an entity by external id which is always String
* @param entity class
@@ -79,20 +60,6 @@ public interface EntityManager {
*/
public List extends T> list(Class entityType);
- /**
- * Persists the entity.
- * @param entity class
- * @param t entity
- * @return persisted entity. Only use this after persisting.
- */
- public T persist(T t);
-
- public SearchBuilder createSearchBuilder(Class entityType);
-
- public GenericSearchBuilder createGenericSearchBuilder(Class entityType, Class resultType);
-
- public List search(Class entityType, SearchCriteria sc);
-
public void remove(Class entityType, K id);
}
diff --git a/utils/test/com/cloud/utils/log/CglibThrowableRendererTest.java b/utils/test/com/cloud/utils/log/CglibThrowableRendererTest.java
deleted file mode 100644
index 5e3571a8984..00000000000
--- a/utils/test/com/cloud/utils/log/CglibThrowableRendererTest.java
+++ /dev/null
@@ -1,104 +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
-// 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 com.cloud.utils.log;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.*;
-
-import com.cloud.utils.component.ComponentContext;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.exception.CloudRuntimeException;
-import org.apache.log4j.spi.RootLogger;
-import org.apache.log4j.spi.ThrowableRenderer;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-import java.io.CharArrayWriter;
-import java.io.Writer;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations="classpath:/testContext.xml")
-public class CglibThrowableRendererTest extends TestCase {
- static Logger another = Logger.getLogger("TEST");
-
- private final static Logger s_logger = Logger.getLogger(CglibThrowableRendererTest.class);
- public static class TestClass {
-
- public TestClass() {
- }
-
- @DB
- public void exception1() {
- throw new IllegalArgumentException("What a bad exception");
- }
- public void exception2() {
- try {
- exception1();
- } catch (Exception e) {
- throw new CloudRuntimeException("exception2", e);
- }
- }
- @DB
- public void exception() {
- try {
- exception2();
- } catch (Exception e) {
- throw new CloudRuntimeException("exception", e);
- }
- }
- }
-
- private Logger getAlternateLogger(Writer writer, ThrowableRenderer renderer) {
- Hierarchy hierarchy = new Hierarchy(new RootLogger(Level.INFO));
- if (renderer != null) {
- hierarchy.setThrowableRenderer(renderer);
- }
- Logger alternateRoot = hierarchy.getRootLogger();
- alternateRoot.addAppender(new WriterAppender(new SimpleLayout(), writer));
- return alternateRoot;
- }
-
- @Test
- public void testException() {
- Writer w = new CharArrayWriter();
- Logger alt = getAlternateLogger(w, null);
-
- TestClass test = new TestClass();
- try {
- test.exception();
- } catch (Exception e) {
- alt.warn("exception caught", e);
- }
- // first check that we actually have some call traces containing ""
- // assertTrue(w.toString().contains(""));
-
- w = new CharArrayWriter();
- alt = getAlternateLogger(w, new CglibThrowableRenderer());
-
- try {
- test.exception();
- } catch (Exception e) {
- alt.warn("exception caught", e);
- }
- // then we check that CglibThrowableRenderer indeed remove those occurrences
- assertFalse(w.toString().contains(""));
-
- }
-}
diff --git a/vmware-base/pom.xml b/vmware-base/pom.xml
index c5d555e82b7..90e0709250f 100644
--- a/vmware-base/pom.xml
+++ b/vmware-base/pom.xml
@@ -32,6 +32,11 @@
cloud-utils
${project.version}
+
+ org.apache.cloudstack
+ cloud-framework-db
+ ${project.version}
+
org.apache.cloudstack
cloud-api
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
index dd0f88902d4..c92b8558737 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
@@ -27,21 +27,6 @@ import java.util.Map;
import org.apache.log4j.Logger;
-import com.cloud.hypervisor.vmware.util.VmwareContext;
-import com.cloud.hypervisor.vmware.util.VmwareHelper;
-import com.cloud.network.Networks.BroadcastDomainType;
-import com.cloud.utils.ActionDelegate;
-import com.cloud.utils.Pair;
-import com.cloud.utils.cisco.n1kv.vsm.NetconfHelper;
-import com.cloud.utils.cisco.n1kv.vsm.PolicyMap;
-import com.cloud.utils.cisco.n1kv.vsm.PortProfile;
-import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.BindingType;
-import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.OperationType;
-import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.PortProfileType;
-import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.SwitchPortMode;
-import com.cloud.utils.db.GlobalLock;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.net.NetUtils;
import com.vmware.vim25.AlreadyExistsFaultMsg;
import com.vmware.vim25.BoolPolicy;
import com.vmware.vim25.DVPortSetting;
@@ -79,6 +64,22 @@ import com.vmware.vim25.VmwareDistributedVirtualSwitchPvlanSpec;
import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanSpec;
+import com.cloud.hypervisor.vmware.util.VmwareContext;
+import com.cloud.hypervisor.vmware.util.VmwareHelper;
+import com.cloud.network.Networks.BroadcastDomainType;
+import com.cloud.utils.ActionDelegate;
+import com.cloud.utils.Pair;
+import com.cloud.utils.cisco.n1kv.vsm.NetconfHelper;
+import com.cloud.utils.cisco.n1kv.vsm.PolicyMap;
+import com.cloud.utils.cisco.n1kv.vsm.PortProfile;
+import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.BindingType;
+import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.OperationType;
+import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.PortProfileType;
+import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.SwitchPortMode;
+import com.cloud.utils.db.GlobalLock;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.net.NetUtils;
+
public class HypervisorHostHelper {
private static final Logger s_logger = Logger.getLogger(HypervisorHostHelper.class);
private static final int DEFAULT_LOCK_TIMEOUT_SECONDS = 600;
@@ -446,29 +447,29 @@ public class HypervisorHostHelper {
Integer vid = null;
Integer spvlanid = null; // secondary pvlan id
- /** This is the list of BroadcastDomainTypes we can actually
+ /** This is the list of BroadcastDomainTypes we can actually
* prepare networks for in this function.
*/
- BroadcastDomainType[] supportedBroadcastTypes =
- new BroadcastDomainType[] { BroadcastDomainType.Lswitch,
- BroadcastDomainType.LinkLocal,
- BroadcastDomainType.Native,
+ BroadcastDomainType[] supportedBroadcastTypes =
+ new BroadcastDomainType[] { BroadcastDomainType.Lswitch,
+ BroadcastDomainType.LinkLocal,
+ BroadcastDomainType.Native,
BroadcastDomainType.Pvlan,
BroadcastDomainType.Storage,
BroadcastDomainType.UnDecided,
BroadcastDomainType.Vlan };
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
- throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType +
+ throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType +
" it not supported on a VMWare hypervisor at this time.");
}
if (broadcastDomainType == BroadcastDomainType.Lswitch) {
if (vSwitchType == VirtualSwitchType.NexusDistributedVirtualSwitch) {
- throw new InvalidParameterException("Nexus Distributed Virtualswitch is not supported with BroadcastDomainType " +
+ throw new InvalidParameterException("Nexus Distributed Virtualswitch is not supported with BroadcastDomainType " +
broadcastDomainType);
}
- /**
+ /**
* Nicira NVP requires all vms to be connected to a single port-group.
* A unique vlan needs to be set per port. This vlan is specific to
* this implementation and has no reference to other vlans in CS
@@ -552,7 +553,7 @@ public class HypervisorHostHelper {
}
long averageBandwidth = 0L;
if (networkRateMbps != null && networkRateMbps.intValue() > 0) {
- averageBandwidth = (long) (networkRateMbps.intValue() * 1024L * 1024L);
+ averageBandwidth = networkRateMbps.intValue() * 1024L * 1024L;
}
// We chose 50% higher allocation than average bandwidth.
// TODO(sateesh): Optionally let user specify the peak coefficient
@@ -601,7 +602,7 @@ public class HypervisorHostHelper {
return vCenterApiVersion.compareTo(minVcenterApiVersionForFeature) >= 0 ? true : false;
}
- private static void setupPVlanPair(DistributedVirtualSwitchMO dvSwitchMo, ManagedObjectReference morDvSwitch,
+ private static void setupPVlanPair(DistributedVirtualSwitchMO dvSwitchMo, ManagedObjectReference morDvSwitch,
Integer vid, Integer spvlanid) throws Exception {
Map vlanmap = dvSwitchMo.retrieveVlanPvlan(vid, spvlanid, morDvSwitch);
if (!vlanmap.isEmpty()) {
@@ -664,7 +665,7 @@ public class HypervisorHostHelper {
}
- private static void createPortGroup(String physicalNetwork, String networkName, Integer vid, Integer spvlanid, DatacenterMO dataCenterMo,
+ private static void createPortGroup(String physicalNetwork, String networkName, Integer vid, Integer spvlanid, DatacenterMO dataCenterMo,
DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy, DistributedVirtualSwitchMO dvSwitchMo, int numPorts, boolean autoExpandSupported) throws Exception{
VmwareDistributedVirtualSwitchVlanSpec vlanSpec = null;
VmwareDistributedVirtualSwitchPvlanSpec pvlanSpec = null;
@@ -717,7 +718,7 @@ public class HypervisorHostHelper {
throw new Exception(msg);
}
}
- }
+ }
}
public static ManagedObjectReference waitForDvPortGroupReady(
@@ -806,12 +807,12 @@ public class HypervisorHostHelper {
LongPolicy burstSize = new LongPolicy();
isEnabled.setValue(true);
- averageBandwidth.setValue((long) networkRateMbps.intValue() * 1024L * 1024L);
+ averageBandwidth.setValue(networkRateMbps.intValue() * 1024L * 1024L);
// We chose 50% higher allocation than average bandwidth.
// TODO(sateesh): Also let user specify the peak coefficient
peakBandwidth.setValue((long) (averageBandwidth.getValue() * 1.5));
// TODO(sateesh): Also let user specify the burst coefficient
- burstSize.setValue((long) (5 * averageBandwidth.getValue() / 8));
+ burstSize.setValue(5 * averageBandwidth.getValue() / 8);
shapingPolicy.setEnabled(isEnabled);
shapingPolicy.setAverageBandwidth(averageBandwidth);
@@ -889,25 +890,25 @@ public class HypervisorHostHelper {
String networkName;
Integer vid = null;
- /** This is the list of BroadcastDomainTypes we can actually
+ /** This is the list of BroadcastDomainTypes we can actually
* prepare networks for in this function.
*/
- BroadcastDomainType[] supportedBroadcastTypes =
- new BroadcastDomainType[] { BroadcastDomainType.Lswitch,
- BroadcastDomainType.LinkLocal,
- BroadcastDomainType.Native,
+ BroadcastDomainType[] supportedBroadcastTypes =
+ new BroadcastDomainType[] { BroadcastDomainType.Lswitch,
+ BroadcastDomainType.LinkLocal,
+ BroadcastDomainType.Native,
BroadcastDomainType.Pvlan,
BroadcastDomainType.Storage,
BroadcastDomainType.UnDecided,
BroadcastDomainType.Vlan };
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
- throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType +
+ throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType +
" it not supported on a VMWare hypervisor at this time.");
}
if (broadcastDomainType == BroadcastDomainType.Lswitch) {
- /**
+ /**
* Nicira NVP requires each vm to have its own port-group with a dedicated
* vlan. We'll set the name of the pg to the uuid of the nic.
*/
@@ -934,7 +935,7 @@ public class HypervisorHostHelper {
if(networkRateMbps != null && networkRateMbps.intValue() > 0) {
shapingPolicy = new HostNetworkTrafficShapingPolicy();
shapingPolicy.setEnabled(true);
- shapingPolicy.setAverageBandwidth((long)networkRateMbps.intValue()*1024L*1024L);
+ shapingPolicy.setAverageBandwidth(networkRateMbps.intValue()*1024L*1024L);
//
// TODO : people may have different opinion on how to set the following
@@ -1062,10 +1063,10 @@ public class HypervisorHostHelper {
}
private static void createNvpPortGroup(HostMO hostMo, HostVirtualSwitch vSwitch, String networkName, HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
- /**
+ /**
* No portgroup created yet for this nic
* We need to find an unused vlan and create the pg
- * The vlan is limited to this vSwitch and the NVP vAPP,
+ * The vlan is limited to this vSwitch and the NVP vAPP,
* so no relation to the other vlans in use in CloudStack.
*/
String vSwitchName = vSwitch.getName();
@@ -1096,7 +1097,7 @@ public class HypervisorHostHelper {
secPolicy.setMacChanges(Boolean.FALSE);
// Create a portgroup with the uuid of the nic and the vlanid found above
- hostMo.createPortGroup(vSwitch, networkName, nvpVlanId, secPolicy, shapingPolicy);
+ hostMo.createPortGroup(vSwitch, networkName, nvpVlanId, secPolicy, shapingPolicy);
}
public static ManagedObjectReference waitForNetworkReady(HostMO hostMo,