Skip to content

Commit 9cbb309

Browse files
Refactor missed classes
1 parent 711ad38 commit 9cbb309

15 files changed

Lines changed: 408 additions & 458 deletions

File tree

plugins/file-systems/netapp/src/com/cloud/netapp/NetappManagerImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
import com.cloud.netapp.dao.VolumeDao;
5151
import com.cloud.utils.component.ManagerBase;
5252
import com.cloud.utils.db.DB;
53-
import com.cloud.utils.db.Transaction;
53+
import com.cloud.utils.db.TransactionLegacy;
5454
import com.cloud.utils.exception.CloudRuntimeException;
5555

5656
@Component
@@ -225,7 +225,7 @@ public void destroyVolumeOnFiler(String ipAddress, String aggrName, String volNa
225225
throw new ResourceInUseException("There are luns on the volume");
226226
}
227227

228-
final Transaction txn = Transaction.currentTxn();
228+
final TransactionLegacy txn = TransactionLegacy.currentTxn();
229229
txn.start();
230230
PoolVO pool = _poolDao.findById(volume.getPoolId());
231231
if (pool == null) {
@@ -388,7 +388,7 @@ public void createVolumeOnFiler(String ipAddress, String aggName, String poolNam
388388
}
389389
Long volumeId = null;
390390

391-
final Transaction txn = Transaction.currentTxn();
391+
final TransactionLegacy txn = TransactionLegacy.currentTxn();
392392
txn.start();
393393
NetappVolumeVO volume = null;
394394
volume = _volumeDao.findVolume(ipAddress, aggName, volName);
@@ -624,7 +624,7 @@ public String[] createLunOnFiler(String poolName, Long lunSize) throws ServerEx
624624
String[] result = new String[3];
625625
StringBuilder lunName = new StringBuilder("lun-");
626626
LunVO lun = null;
627-
final Transaction txn = Transaction.currentTxn();
627+
final TransactionLegacy txn = TransactionLegacy.currentTxn();
628628
txn.start();
629629
PoolVO pool = _poolDao.findPool(poolName);
630630

@@ -802,7 +802,7 @@ else if(algorithm.equals(Algorithm.leastfull.toString()))
802802
@DB
803803
public void destroyLunOnFiler(String lunName) throws InvalidParameterValueException, ServerException{
804804

805-
final Transaction txn = Transaction.currentTxn();
805+
final TransactionLegacy txn = TransactionLegacy.currentTxn();
806806
txn.start();
807807

808808
LunVO lun = _lunDao.findByName(lunName);

plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,18 @@
4242
import com.cloud.utils.concurrency.NamedThreadFactory;
4343
import com.cloud.utils.db.DB;
4444
import com.cloud.utils.db.Transaction;
45+
import com.cloud.utils.db.TransactionLegacy;
4546
import com.cloud.utils.exception.CloudRuntimeException;
4647
import com.cloud.utils.net.NetUtils;
48+
4749
import org.apache.cloudstack.api.command.admin.host.AddSecondaryStorageCmd;
4850
import org.apache.log4j.Logger;
4951
import org.springframework.stereotype.Component;
5052

5153
import javax.ejb.Local;
5254
import javax.inject.Inject;
5355
import javax.naming.ConfigurationException;
56+
5457
import java.security.NoSuchAlgorithmException;
5558
import java.security.SecureRandom;
5659
import java.util.HashMap;
@@ -159,7 +162,7 @@ public Map<AgentResourceBase, Map<String, String>> createServerResources(Map<Str
159162
mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
160163
mockHost.setResource("com.cloud.agent.AgentRoutingResource");
161164

162-
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
165+
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
163166
try {
164167
txn.start();
165168
mockHost = _mockHostDao.persist(mockHost);
@@ -170,7 +173,7 @@ public Map<AgentResourceBase, Map<String, String>> createServerResources(Map<Str
170173
throw new CloudRuntimeException("Error configuring agent", ex);
171174
} finally {
172175
txn.close();
173-
txn = Transaction.open(Transaction.CLOUD_DB);
176+
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
174177
txn.close();
175178
}
176179

@@ -256,7 +259,7 @@ public SystemVMHandler(long vmId) {
256259

257260

258261
private void handleSystemVMStop() {
259-
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
262+
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
260263
try {
261264
if (this.mode.equalsIgnoreCase("Stop")) {
262265
txn.start();
@@ -279,7 +282,7 @@ private void handleSystemVMStop() {
279282
throw new CloudRuntimeException("Unable to get host " + guid + " due to " + ex.getMessage(), ex);
280283
} finally {
281284
txn.close();
282-
txn = Transaction.open(Transaction.CLOUD_DB);
285+
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
283286
txn.close();
284287
}
285288

@@ -323,7 +326,7 @@ public void run() {
323326
mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
324327
mockHost.setResource(resource);
325328
mockHost.setVmId(vmId);
326-
Transaction simtxn = Transaction.open(Transaction.SIMULATOR_DB);
329+
TransactionLegacy simtxn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
327330
try {
328331
simtxn.start();
329332
mockHost = _mockHostDao.persist(mockHost);
@@ -334,7 +337,7 @@ public void run() {
334337
+ ex.getMessage(), ex);
335338
} finally {
336339
simtxn.close();
337-
simtxn = Transaction.open(Transaction.CLOUD_DB);
340+
simtxn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
338341
simtxn.close();
339342
}
340343

@@ -366,7 +369,7 @@ public void run() {
366369

367370
@Override
368371
public MockHost getHost(String guid) {
369-
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
372+
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
370373
try {
371374
txn.start();
372375
MockHost _host = _mockHostDao.findByGuid(guid);
@@ -382,7 +385,7 @@ public MockHost getHost(String guid) {
382385
throw new CloudRuntimeException("Unable to get host " + guid + " due to " + ex.getMessage(), ex);
383386
} finally {
384387
txn.close();
385-
txn = Transaction.open(Transaction.CLOUD_DB);
388+
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
386389
txn.close();
387390
}
388391
}
@@ -391,7 +394,7 @@ public MockHost getHost(String guid) {
391394
public GetHostStatsAnswer getHostStatistic(GetHostStatsCommand cmd) {
392395
String hostGuid = cmd.getHostGuid();
393396
MockHost host = null;
394-
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
397+
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
395398
try {
396399
txn.start();
397400
host = _mockHostDao.findByGuid(hostGuid);
@@ -404,11 +407,11 @@ public GetHostStatsAnswer getHostStatistic(GetHostStatsCommand cmd) {
404407
throw new CloudRuntimeException("Unable to get host " + hostGuid + " due to " + ex.getMessage(), ex);
405408
} finally {
406409
txn.close();
407-
txn = Transaction.open(Transaction.CLOUD_DB);
410+
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
408411
txn.close();
409412
}
410413

411-
Transaction vmtxn = Transaction.open(Transaction.SIMULATOR_DB);
414+
TransactionLegacy vmtxn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
412415
try {
413416
vmtxn.start();
414417
List<MockVMVO> vms = _mockVmDao.findByHostId(host.getId());
@@ -435,7 +438,7 @@ public GetHostStatsAnswer getHostStatistic(GetHostStatsCommand cmd) {
435438
+ ex.getMessage(), ex);
436439
} finally {
437440
vmtxn.close();
438-
vmtxn = Transaction.open(Transaction.CLOUD_DB);
441+
vmtxn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
439442
vmtxn.close();
440443
}
441444
}

0 commit comments

Comments
 (0)