cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dar...@apache.org
Subject [16/47] New Transaction API
Date Wed, 23 Oct 2013 19:43:33 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f62e28c1/server/test/com/cloud/configuration/ConfigurationManagerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/configuration/ConfigurationManagerTest.java b/server/test/com/cloud/configuration/ConfigurationManagerTest.java
index 908f0d0..2d2c03d 100755
--- a/server/test/com/cloud/configuration/ConfigurationManagerTest.java
+++ b/server/test/com/cloud/configuration/ConfigurationManagerTest.java
@@ -40,7 +40,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-
 import org.apache.cloudstack.api.command.admin.vlan.DedicatePublicIpRangeCmd;
 import org.apache.cloudstack.api.command.admin.vlan.ReleasePublicIpRangeCmd;
 import org.apache.cloudstack.context.CallContext;
@@ -69,6 +68,7 @@ import com.cloud.user.ResourceLimitService;
 import com.cloud.user.UserVO;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.utils.db.Transaction;
+import com.cloud.utils.db.TransactionLegacy;
 import com.cloud.utils.net.Ip;
 
 public class ConfigurationManagerTest {
@@ -213,7 +213,7 @@ public class ConfigurationManagerTest {
     }
 
     void runDedicatePublicIpRangePostiveTest() throws Exception {
-        Transaction txn = Transaction.open("runDedicatePublicIpRangePostiveTest");
+        TransactionLegacy txn = TransactionLegacy.open("runDedicatePublicIpRangePostiveTest");
 
         when(configurationMgr._vlanDao.findById(anyLong())).thenReturn(vlan);
 
@@ -239,7 +239,7 @@ public class ConfigurationManagerTest {
     }
 
     void runDedicatePublicIpRangeInvalidRange() throws Exception {
-        Transaction txn = Transaction.open("runDedicatePublicIpRangeInvalidRange");
+        TransactionLegacy txn = TransactionLegacy.open("runDedicatePublicIpRangeInvalidRange");
 
         when(configurationMgr._vlanDao.findById(anyLong())).thenReturn(null);
         try {
@@ -252,7 +252,7 @@ public class ConfigurationManagerTest {
     }
 
     void runDedicatePublicIpRangeDedicatedRange() throws Exception {
-        Transaction txn = Transaction.open("runDedicatePublicIpRangeDedicatedRange");
+        TransactionLegacy txn = TransactionLegacy.open("runDedicatePublicIpRangeDedicatedRange");
 
         when(configurationMgr._vlanDao.findById(anyLong())).thenReturn(vlan);
 
@@ -281,7 +281,7 @@ public class ConfigurationManagerTest {
     }
 
     void runDedicatePublicIpRangeInvalidZone() throws Exception {
-        Transaction txn = Transaction.open("runDedicatePublicIpRangeInvalidZone");
+        TransactionLegacy txn = TransactionLegacy.open("runDedicatePublicIpRangeInvalidZone");
 
         when(configurationMgr._vlanDao.findById(anyLong())).thenReturn(vlan);
 
@@ -307,7 +307,7 @@ public class ConfigurationManagerTest {
     }
 
     void runDedicatePublicIpRangeIPAdressAllocated() throws Exception {
-        Transaction txn = Transaction.open("runDedicatePublicIpRangeIPAdressAllocated");
+        TransactionLegacy txn = TransactionLegacy.open("runDedicatePublicIpRangeIPAdressAllocated");
 
         when(configurationMgr._vlanDao.findById(anyLong())).thenReturn(vlan);
 
@@ -334,7 +334,7 @@ public class ConfigurationManagerTest {
     }
 
     void runReleasePublicIpRangePostiveTest1() throws Exception {
-        Transaction txn = Transaction.open("runReleasePublicIpRangePostiveTest1");
+        TransactionLegacy txn = TransactionLegacy.open("runReleasePublicIpRangePostiveTest1");
 
         when(configurationMgr._vlanDao.findById(anyLong())).thenReturn(vlan);
 
@@ -358,7 +358,7 @@ public class ConfigurationManagerTest {
     }
 
     void runReleasePublicIpRangePostiveTest2() throws Exception {
-        Transaction txn = Transaction.open("runReleasePublicIpRangePostiveTest2");
+        TransactionLegacy txn = TransactionLegacy.open("runReleasePublicIpRangePostiveTest2");
 
         when(configurationMgr._vlanDao.findById(anyLong())).thenReturn(vlan);
 
@@ -392,7 +392,7 @@ public class ConfigurationManagerTest {
     }
 
     void runReleasePublicIpRangeInvalidIpRange() throws Exception {
-        Transaction txn = Transaction.open("runReleasePublicIpRangeInvalidIpRange");
+        TransactionLegacy txn = TransactionLegacy.open("runReleasePublicIpRangeInvalidIpRange");
 
         when(configurationMgr._vlanDao.findById(anyLong())).thenReturn(null);
         try {
@@ -405,7 +405,7 @@ public class ConfigurationManagerTest {
     }
 
     void runReleaseNonDedicatedPublicIpRange() throws Exception {
-        Transaction txn = Transaction.open("runReleaseNonDedicatedPublicIpRange");
+        TransactionLegacy txn = TransactionLegacy.open("runReleaseNonDedicatedPublicIpRange");
 
         when(configurationMgr._vlanDao.findById(anyLong())).thenReturn(vlan);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f62e28c1/server/test/com/cloud/network/CreatePrivateNetworkTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/CreatePrivateNetworkTest.java b/server/test/com/cloud/network/CreatePrivateNetworkTest.java
index 0e57b02..9276309 100644
--- a/server/test/com/cloud/network/CreatePrivateNetworkTest.java
+++ b/server/test/com/cloud/network/CreatePrivateNetworkTest.java
@@ -36,7 +36,6 @@ import org.junit.Ignore;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
 import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
 
@@ -63,6 +62,7 @@ import com.cloud.user.AccountManager;
 import com.cloud.user.AccountVO;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.Transaction;
+import com.cloud.utils.db.TransactionLegacy;
 import com.cloud.utils.exception.CloudRuntimeException;
 
 //@Ignore("Requires database to be set up")
@@ -152,8 +152,8 @@ public class CreatePrivateNetworkTest {
     @Test
     @DB
     public void createInvalidlyHostedPrivateNetwork() {
-        Transaction __txn;
-        __txn = Transaction.open("createInvalidlyHostedPrivateNetworkTest");
+        TransactionLegacy __txn;
+        __txn = TransactionLegacy.open("createInvalidlyHostedPrivateNetworkTest");
         /* Network nw; */
         try {
             /* nw = */

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f62e28c1/server/test/com/cloud/network/DedicateGuestVlanRangesTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/DedicateGuestVlanRangesTest.java b/server/test/com/cloud/network/DedicateGuestVlanRangesTest.java
index d6ee630..ea7167b 100644
--- a/server/test/com/cloud/network/DedicateGuestVlanRangesTest.java
+++ b/server/test/com/cloud/network/DedicateGuestVlanRangesTest.java
@@ -37,7 +37,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-
 import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
 import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
 import org.apache.cloudstack.api.command.admin.network.ReleaseDedicatedGuestVlanRangeCmd;
@@ -56,6 +55,7 @@ import com.cloud.user.AccountVO;
 import com.cloud.user.UserVO;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.utils.db.Transaction;
+import com.cloud.utils.db.TransactionLegacy;
 
 public class DedicateGuestVlanRangesTest {
 
@@ -177,7 +177,7 @@ public class DedicateGuestVlanRangesTest {
     }
 
     void runDedicateGuestVlanRangePostiveTest() throws Exception {
-        Transaction txn = Transaction.open("runDedicateGuestVlanRangePostiveTest");
+        TransactionLegacy txn = TransactionLegacy.open("runDedicateGuestVlanRangePostiveTest");
         
         Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan");
         dedicateVlanField.setAccessible(true);
@@ -213,7 +213,7 @@ public class DedicateGuestVlanRangesTest {
     }
 
     void runDedicateGuestVlanRangeInvalidFormat() throws Exception {
-        Transaction txn = Transaction.open("runDedicateGuestVlanRangeInvalidFormat");
+        TransactionLegacy txn = TransactionLegacy.open("runDedicateGuestVlanRangeInvalidFormat");
 
         Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan");
         dedicateVlanField.setAccessible(true);
@@ -234,7 +234,7 @@ public class DedicateGuestVlanRangesTest {
     }
 
     void runDedicateGuestVlanRangeInvalidRangeValue() throws Exception {
-        Transaction txn = Transaction.open("runDedicateGuestVlanRangeInvalidRangeValue");
+        TransactionLegacy txn = TransactionLegacy.open("runDedicateGuestVlanRangeInvalidRangeValue");
 
         Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan");
         dedicateVlanField.setAccessible(true);
@@ -255,7 +255,7 @@ public class DedicateGuestVlanRangesTest {
     }
 
     void runDedicateGuestVlanRangeAllocatedVlans() throws Exception {
-        Transaction txn = Transaction.open("runDedicateGuestVlanRangeAllocatedVlans");
+        TransactionLegacy txn = TransactionLegacy.open("runDedicateGuestVlanRangeAllocatedVlans");
         
         Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan");
         dedicateVlanField.setAccessible(true);
@@ -281,7 +281,7 @@ public class DedicateGuestVlanRangesTest {
     }
 
     void runDedicateGuestVlanRangeDedicatedRange() throws Exception {
-        Transaction txn = Transaction.open("runDedicateGuestVlanRangeDedicatedRange");
+        TransactionLegacy txn = TransactionLegacy.open("runDedicateGuestVlanRangeDedicatedRange");
         
         Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan");
         dedicateVlanField.setAccessible(true);
@@ -310,7 +310,7 @@ public class DedicateGuestVlanRangesTest {
     }
 
     void runDedicateGuestVlanRangePartiallyDedicated() throws Exception {
-        Transaction txn = Transaction.open("runDedicateGuestVlanRangePartiallyDedicated");
+        TransactionLegacy txn = TransactionLegacy.open("runDedicateGuestVlanRangePartiallyDedicated");
         
         Field dedicateVlanField = _dedicateGuestVlanRangeClass.getDeclaredField("vlan");
         dedicateVlanField.setAccessible(true);
@@ -339,7 +339,7 @@ public class DedicateGuestVlanRangesTest {
     }
     
     void runReleaseDedicatedGuestVlanRangePostiveTest() throws Exception {
-        Transaction txn = Transaction.open("runReleaseDedicatedGuestVlanRangePostiveTest");
+        TransactionLegacy txn = TransactionLegacy.open("runReleaseDedicatedGuestVlanRangePostiveTest");
 
         AccountGuestVlanMapVO accountGuestVlanMap = new AccountGuestVlanMapVO(1L, 1L);
         when(networkService._accountGuestVlanMapDao.findById(anyLong())).thenReturn(accountGuestVlanMap);
@@ -357,7 +357,7 @@ public class DedicateGuestVlanRangesTest {
     }
 
     void runReleaseDedicatedGuestVlanRangeInvalidRange() throws Exception {
-        Transaction txn = Transaction.open("runReleaseDedicatedGuestVlanRangeInvalidRange");
+        TransactionLegacy txn = TransactionLegacy.open("runReleaseDedicatedGuestVlanRangeInvalidRange");
 
         when(networkService._accountGuestVlanMapDao.findById(anyLong())).thenReturn(null);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f62e28c1/server/test/com/cloud/network/UpdatePhysicalNetworkTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/UpdatePhysicalNetworkTest.java b/server/test/com/cloud/network/UpdatePhysicalNetworkTest.java
index 1c0eff6..264f91c 100644
--- a/server/test/com/cloud/network/UpdatePhysicalNetworkTest.java
+++ b/server/test/com/cloud/network/UpdatePhysicalNetworkTest.java
@@ -24,7 +24,8 @@ import com.cloud.network.dao.PhysicalNetworkDao;
 import com.cloud.network.dao.PhysicalNetworkVO;
 import com.cloud.utils.Pair;
 import com.cloud.utils.db.Transaction;
-import org.junit.Test;
+import com.cloud.utils.db.TransactionLegacy;
+
 import org.junit.*;
 import org.mockito.ArgumentCaptor;
 import org.mockito.MockitoAnnotations.*;
@@ -58,7 +59,7 @@ public class UpdatePhysicalNetworkTest {
 
     @Test
     public void updatePhysicalNetworkTest(){
-        Transaction txn = Transaction.open("updatePhysicalNetworkTest");
+        TransactionLegacy txn = TransactionLegacy.open("updatePhysicalNetworkTest");
         NetworkServiceImpl networkService = setUp();
         existingRange.add("524");
         when(_physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetworkVO);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f62e28c1/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
b/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
index d0f0951..504ab9c 100644
--- a/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
+++ b/server/test/org/apache/cloudstack/region/gslb/GlobalLoadBalancingRulesServiceImplTest.java
@@ -33,7 +33,6 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
-
 import org.apache.cloudstack.api.command.user.region.ha.gslb.AssignToGlobalLoadBalancerRuleCmd;
 import org.apache.cloudstack.api.command.user.region.ha.gslb.CreateGlobalLoadBalancerRuleCmd;
 import org.apache.cloudstack.api.command.user.region.ha.gslb.DeleteGlobalLoadBalancerRuleCmd;
@@ -59,6 +58,7 @@ import com.cloud.user.AccountManager;
 import com.cloud.user.AccountVO;
 import com.cloud.user.UserVO;
 import com.cloud.utils.db.Transaction;
+import com.cloud.utils.db.TransactionLegacy;
 import com.cloud.utils.net.Ip;
 
 public class GlobalLoadBalancingRulesServiceImplTest extends TestCase {
@@ -181,7 +181,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
 
     void runCreateGlobalLoadBalancerRulePostiveTest() throws Exception {
 
-        Transaction txn = Transaction.open("runCreateGlobalLoadBalancerRulePostiveTest");
+        TransactionLegacy txn = TransactionLegacy.open("runCreateGlobalLoadBalancerRulePostiveTest");
 
         GlobalLoadBalancingRulesServiceImpl gslbServiceImpl =  new GlobalLoadBalancingRulesServiceImpl();
 
@@ -246,7 +246,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
 
     void runCreateGlobalLoadBalancerRuleInvalidAlgorithm() throws Exception {
 
-        Transaction txn = Transaction.open("runCreateGlobalLoadBalancerRulePostiveTest");
+        TransactionLegacy txn = TransactionLegacy.open("runCreateGlobalLoadBalancerRulePostiveTest");
 
         GlobalLoadBalancingRulesServiceImpl gslbServiceImpl =  new GlobalLoadBalancingRulesServiceImpl();
 
@@ -311,7 +311,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
 
     void runCreateGlobalLoadBalancerRuleInvalidStickyMethod() throws Exception {
 
-        Transaction txn = Transaction.open("runCreateGlobalLoadBalancerRulePostiveTest");
+        TransactionLegacy txn = TransactionLegacy.open("runCreateGlobalLoadBalancerRulePostiveTest");
 
         GlobalLoadBalancingRulesServiceImpl gslbServiceImpl =  new GlobalLoadBalancingRulesServiceImpl();
 
@@ -376,7 +376,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
 
     void runCreateGlobalLoadBalancerRuleInvalidServiceType() throws Exception {
 
-        Transaction txn = Transaction.open("runCreateGlobalLoadBalancerRulePostiveTest");
+        TransactionLegacy txn = TransactionLegacy.open("runCreateGlobalLoadBalancerRulePostiveTest");
 
         GlobalLoadBalancingRulesServiceImpl gslbServiceImpl =  new GlobalLoadBalancingRulesServiceImpl();
 
@@ -441,7 +441,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
 
     void runCreateGlobalLoadBalancerRuleInvalidDomainName() throws Exception {
 
-        Transaction txn = Transaction.open("runCreateGlobalLoadBalancerRulePostiveTest");
+        TransactionLegacy txn = TransactionLegacy.open("runCreateGlobalLoadBalancerRulePostiveTest");
 
         GlobalLoadBalancingRulesServiceImpl gslbServiceImpl =  new GlobalLoadBalancingRulesServiceImpl();
 
@@ -507,7 +507,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
 
     void runAssignToGlobalLoadBalancerRuleTest() throws Exception {
 
-        Transaction txn = Transaction.open("runAssignToGlobalLoadBalancerRuleTest");
+        TransactionLegacy txn = TransactionLegacy.open("runAssignToGlobalLoadBalancerRuleTest");
 
         GlobalLoadBalancingRulesServiceImpl gslbServiceImpl =  new GlobalLoadBalancingRulesServiceImpl();
 
@@ -570,7 +570,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
 
     void runAssignToGlobalLoadBalancerRuleTestSameZoneLb() throws  Exception {
 
-        Transaction txn = Transaction.open("runAssignToGlobalLoadBalancerRuleTestSameZoneLb");
+        TransactionLegacy txn = TransactionLegacy.open("runAssignToGlobalLoadBalancerRuleTestSameZoneLb");
 
         GlobalLoadBalancingRulesServiceImpl gslbServiceImpl =  new GlobalLoadBalancingRulesServiceImpl();
 
@@ -655,7 +655,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
 
     void runAssignToGlobalLoadBalancerRuleTestRevokedState() throws Exception {
 
-        Transaction txn = Transaction.open("runAssignToGlobalLoadBalancerRuleTestRevokedState");
+        TransactionLegacy txn = TransactionLegacy.open("runAssignToGlobalLoadBalancerRuleTestRevokedState");
 
         GlobalLoadBalancingRulesServiceImpl gslbServiceImpl =  new GlobalLoadBalancingRulesServiceImpl();
 
@@ -712,7 +712,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
 
     void runRemoveFromGlobalLoadBalancerRuleTest() throws Exception {
 
-        Transaction txn = Transaction.open("runRemoveFromGlobalLoadBalancerRuleTest");
+        TransactionLegacy txn = TransactionLegacy.open("runRemoveFromGlobalLoadBalancerRuleTest");
 
         GlobalLoadBalancingRulesServiceImpl gslbServiceImpl =  new GlobalLoadBalancingRulesServiceImpl();
 
@@ -785,7 +785,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
 
     void runRemoveFromGlobalLoadBalancerRuleTestUnassignedLb() throws Exception {
 
-        Transaction txn = Transaction.open("runRemoveFromGlobalLoadBalancerRuleTestUnassignedLb");
+        TransactionLegacy txn = TransactionLegacy.open("runRemoveFromGlobalLoadBalancerRuleTestUnassignedLb");
 
         GlobalLoadBalancingRulesServiceImpl gslbServiceImpl =  new GlobalLoadBalancingRulesServiceImpl();
 
@@ -846,7 +846,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
 
     void runRemoveFromGlobalLoadBalancerRuleTestInvalidLb() throws Exception {
 
-        Transaction txn = Transaction.open("runRemoveFromGlobalLoadBalancerRuleTestInvalidLb");
+        TransactionLegacy txn = TransactionLegacy.open("runRemoveFromGlobalLoadBalancerRuleTestInvalidLb");
 
         GlobalLoadBalancingRulesServiceImpl gslbServiceImpl =  new GlobalLoadBalancingRulesServiceImpl();
 
@@ -890,7 +890,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
 
     void runDeleteGlobalLoadBalancerRuleTestWithNoLbRules() throws Exception {
 
-        Transaction txn = Transaction.open("runDeleteGlobalLoadBalancerRuleTestWithNoLbRules");
+        TransactionLegacy txn = TransactionLegacy.open("runDeleteGlobalLoadBalancerRuleTestWithNoLbRules");
 
         GlobalLoadBalancingRulesServiceImpl gslbServiceImpl =  new GlobalLoadBalancingRulesServiceImpl();
 
@@ -936,7 +936,7 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase
{
 
     void runDeleteGlobalLoadBalancerRuleTestWithLbRules() throws Exception {
 
-        Transaction txn = Transaction.open("runDeleteGlobalLoadBalancerRuleTestWithLbRules");
+        TransactionLegacy txn = TransactionLegacy.open("runDeleteGlobalLoadBalancerRuleTestWithLbRules");
 
         GlobalLoadBalancingRulesServiceImpl gslbServiceImpl =  new GlobalLoadBalancingRulesServiceImpl();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f62e28c1/usage/src/com/cloud/usage/UsageManagerImpl.java
----------------------------------------------------------------------
diff --git a/usage/src/com/cloud/usage/UsageManagerImpl.java b/usage/src/com/cloud/usage/UsageManagerImpl.java
index 3ff53e0..1ee21c9 100644
--- a/usage/src/com/cloud/usage/UsageManagerImpl.java
+++ b/usage/src/com/cloud/usage/UsageManagerImpl.java
@@ -84,7 +84,7 @@ import com.cloud.utils.db.DB;
 import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.GlobalLock;
 import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.Transaction;
+import com.cloud.utils.db.TransactionLegacy;
 
 @Component
 @Local(value={UsageManager.class})
@@ -248,7 +248,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager,
Runna
             m_sanity = m_sanityExecutor.scheduleAtFixedRate(new SanityCheck(), 1, m_sanityCheckInterval,
TimeUnit.DAYS);
         }
 
-        Transaction usageTxn = Transaction.open(Transaction.USAGE_DB);
+        TransactionLegacy usageTxn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
         try {
             if(m_heartbeatLock.lock(3)) { // 3 second timeout
                 try {
@@ -381,7 +381,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager,
Runna
                     s_logger.info("not parsing usage records since start time mills (" +
startDateMillis + ") is on or after end time millis (" + endDateMillis + ")");
                 }
 
-                Transaction jobUpdateTxn = Transaction.open(Transaction.USAGE_DB);
+                TransactionLegacy jobUpdateTxn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
                 try {
                     jobUpdateTxn.start();
                     // everything seemed to work...set endDate as the last success date
@@ -411,7 +411,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager,
Runna
             Map<String, UsageNetworkVO> networkStats = null;
             List<VmDiskStatisticsVO> vmDiskStats = null;
             Map<String, UsageVmDiskVO> vmDiskUsages = null;
-            Transaction userTxn = Transaction.open(Transaction.CLOUD_DB);
+            TransactionLegacy userTxn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
             try {
                 Long limit = Long.valueOf(500);
                 Long offset = Long.valueOf(0);
@@ -552,7 +552,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager,
Runna
             List<UsageEventVO> events = _usageEventDao.getRecentEvents(new Date(endDateMillis));
 
             
-            Transaction usageTxn = Transaction.open(Transaction.USAGE_DB);
+            TransactionLegacy usageTxn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
             try {
                 usageTxn.start();
 
@@ -779,7 +779,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager,
Runna
                 usageTxn.close();
 
                 // switch back to CLOUD_DB
-                Transaction swap = Transaction.open(Transaction.CLOUD_DB);
+                TransactionLegacy swap = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
                 if(!success){
                     _alertMgr.sendAlert(AlertManager.ALERT_TYPE_USAGE_SERVER_RESULT, 0, new
Long(0), "Usage job failed. Job id: "+job.getId(), "Usage job failed. Job id: "+job.getId());
                 } else {
@@ -1664,7 +1664,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager,
Runna
     private class Heartbeat extends ManagedContextRunnable {
         @Override
         protected void runInContext() {
-            Transaction usageTxn = Transaction.open(Transaction.USAGE_DB);
+            TransactionLegacy usageTxn = TransactionLegacy.open(TransactionLegacy.USAGE_DB);
             try {
                 if(!m_heartbeatLock.lock(3)) { // 3 second timeout
                     if(s_logger.isTraceEnabled())
@@ -1723,7 +1723,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager,
Runna
         @DB
         protected boolean updateJob(Long jobId, String hostname, Integer pid, Date heartbeat,
int scheduled) {
             boolean changeOwner = false;
-            Transaction txn = Transaction.currentTxn();
+            TransactionLegacy txn = TransactionLegacy.currentTxn();
             try {
                 txn.start();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f62e28c1/usage/src/com/cloud/usage/UsageSanityChecker.java
----------------------------------------------------------------------
diff --git a/usage/src/com/cloud/usage/UsageSanityChecker.java b/usage/src/com/cloud/usage/UsageSanityChecker.java
index ed78a15..35fbe81 100644
--- a/usage/src/com/cloud/usage/UsageSanityChecker.java
+++ b/usage/src/com/cloud/usage/UsageSanityChecker.java
@@ -26,7 +26,7 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
-import com.cloud.utils.db.Transaction;
+import com.cloud.utils.db.TransactionLegacy;
 
 public class UsageSanityChecker {
     
@@ -186,7 +186,7 @@ public class UsageSanityChecker {
             // Error while reading last check id  
         }
 
-        Connection conn = Transaction.getStandaloneConnection();
+        Connection conn = TransactionLegacy.getStandaloneConnection();
         int maxId = 0;
         PreparedStatement pstmt = conn.prepareStatement("select max(id) from cloud_usage.cloud_usage");
         ResultSet rs = pstmt.executeQuery();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f62e28c1/utils/src/com/cloud/utils/exception/ExceptionUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/exception/ExceptionUtil.java b/utils/src/com/cloud/utils/exception/ExceptionUtil.java
index 977af92..322c23d 100644
--- a/utils/src/com/cloud/utils/exception/ExceptionUtil.java
+++ b/utils/src/com/cloud/utils/exception/ExceptionUtil.java
@@ -35,4 +35,16 @@ public class ExceptionUtil {
         }
         return writer.toString();
     }
+    
+    @SuppressWarnings("unchecked")
+    public static <T extends Throwable> void rethrow(Throwable t, Class<T> clz)
throws T {
+        if ( clz.isAssignableFrom(t.getClass()) )
+            throw (T)t;
+    }
+    
+    public static <T extends Throwable> void rethrowRuntime(Throwable t) {
+        rethrow(t, RuntimeException.class);
+        rethrow(t, Error.class);
+    }
+
 }


Mime
View raw message