Author: swagle
Date: Thu May 16 17:12:21 2013
New Revision: 1483452
URL: http://svn.apache.org/r1483452
Log:
AMBARI-2142. Unecessary use of @Transactional on all DAO methods. (swagle)
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
Modified: incubator/ambari/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1483452&r1=1483451&r2=1483452&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu May 16 17:12:21 2013
@@ -856,6 +856,8 @@ Trunk (unreleased changes):
BUG FIXES
+ AMBARI-2142. Unecessary use of @Transactional on all DAO methods. (swagle)
+
AMBARI-2107. Cluster CPU Chart is off the charts. Reopened. (swagle)
AMBARI-2139. Hive Service check fails on secure cluster. (jaimin)
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java?rev=1483452&r1=1483451&r2=1483452&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
Thu May 16 17:12:21 2013
@@ -20,6 +20,7 @@ package org.apache.ambari.server.actionm
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.name.Named;
+import com.google.inject.persist.UnitOfWork;
import org.apache.ambari.server.agent.ActionQueue;
import org.apache.ambari.server.agent.CommandReport;
import org.apache.ambari.server.controller.HostsMap;
@@ -51,11 +52,11 @@ public class ActionManager {
public ActionManager(@Named("schedulerSleeptime") long schedulerSleepTime,
@Named("actionTimeout") long actionTimeout,
ActionQueue aq, Clusters fsm, ActionDBAccessor db, HostsMap hostsMap,
- ServerActionManager serverActionManager) {
+ ServerActionManager serverActionManager, UnitOfWork unitOfWork) {
this.actionQueue = aq;
this.db = db;
scheduler = new ActionScheduler(schedulerSleepTime, actionTimeout, db,
- actionQueue, fsm, 2, hostsMap, serverActionManager);
+ actionQueue, fsm, 2, hostsMap, serverActionManager, unitOfWork);
requestCounter = new AtomicLong(
db.getLastPersistedRequestIdWhenInitialized());
}
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java?rev=1483452&r1=1483451&r2=1483452&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionScheduler.java
Thu May 16 17:12:21 2013
@@ -17,6 +17,7 @@
*/
package org.apache.ambari.server.actionmanager;
+import com.google.inject.persist.UnitOfWork;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.Role;
import org.apache.ambari.server.ServiceComponentNotFoundException;
@@ -43,6 +44,7 @@ class ActionScheduler implements Runnabl
private static Logger LOG = LoggerFactory.getLogger(ActionScheduler.class);
private final long actionTimeout;
private final long sleepTime;
+ private final UnitOfWork unitOfWork;
private volatile boolean shouldRun = true;
private Thread schedulerThread = null;
private final ActionDBAccessor db;
@@ -63,7 +65,7 @@ class ActionScheduler implements Runnabl
public ActionScheduler(long sleepTimeMilliSec, long actionTimeoutMilliSec,
ActionDBAccessor db, ActionQueue actionQueue, Clusters fsmObject,
- int maxAttempts, HostsMap hostsMap, ServerActionManager
serverActionManager) {
+ int maxAttempts, HostsMap hostsMap, ServerActionManager
serverActionManager, UnitOfWork unitOfWork) {
this.sleepTime = sleepTimeMilliSec;
this.hostsMap = hostsMap;
this.actionTimeout = actionTimeoutMilliSec;
@@ -72,6 +74,7 @@ class ActionScheduler implements Runnabl
this.fsmObject = fsmObject;
this.maxAttempts = (short) maxAttempts;
this.serverActionManager = serverActionManager;
+ this.unitOfWork = unitOfWork;
}
public void start() {
@@ -119,89 +122,96 @@ class ActionScheduler implements Runnabl
}
public void doWork() throws AmbariException {
- List<Stage> stages = db.getStagesInProgress();
- if (LOG.isDebugEnabled()) {
- LOG.debug("Scheduler wakes up");
- }
- if (stages == null || stages.isEmpty()) {
- //Nothing to do
+ try {
+ unitOfWork.begin();
+
+ List<Stage> stages = db.getStagesInProgress();
if (LOG.isDebugEnabled()) {
- LOG.debug("No stage in progress..nothing to do");
+ LOG.debug("Scheduler wakes up");
}
- return;
- }
-
- for (Stage s : stages) {
- List<ExecutionCommand> commandsToSchedule = new
ArrayList<ExecutionCommand>();
- Map<String, RoleStats> roleStats = processInProgressStage(s,
commandsToSchedule);
- //Check if stage is failed
- boolean failed = false;
- for (String role : roleStats.keySet()) {
- RoleStats stats = roleStats.get(role);
+ if (stages == null || stages.isEmpty()) {
+ //Nothing to do
if (LOG.isDebugEnabled()) {
- LOG.debug("Stats for role:" + role + ", stats=" + stats);
+ LOG.debug("No stage in progress..nothing to do");
}
- if (stats.isRoleFailed()) {
- failed = true;
- break;
- }
- }
-
- if(!failed) {
- // Prior stage may have failed and it may need to fail the whole
request
- failed = hasPreviousStageFailed(s);
- }
-
- if (failed) {
- LOG.warn("Operation completely failed, aborting request id:"
- + s.getRequestId());
- db.abortOperation(s.getRequestId());
return;
}
- //Schedule what we have so far
- for (ExecutionCommand cmd : commandsToSchedule) {
- if (cmd.getRole() == Role.AMBARI_SERVER_ACTION) {
- try {
- long now = System.currentTimeMillis();
- String hostName = cmd.getHostname();
- String roleName = cmd.getRole().toString();
-
- s.setStartTime(hostName, roleName, now);
- s.setLastAttemptTime(hostName, roleName, now);
- s.incrementAttemptCount(hostName, roleName);
- s.setHostRoleStatus(hostName, roleName, HostRoleStatus.QUEUED);
- db.hostRoleScheduled(s, hostName, roleName);
- String actionName =
cmd.getRoleParams().get(ServerAction.ACTION_NAME);
- this.serverActionManager.executeAction(actionName,
cmd.getCommandParams());
- reportServerActionSuccess(s, cmd);
- } catch (AmbariException e) {
- LOG.warn("Could not execute server action " + cmd.toString(), e);
- reportServerActionFailure(s, cmd, e.getMessage());
+ for (Stage s : stages) {
+ List<ExecutionCommand> commandsToSchedule = new
ArrayList<ExecutionCommand>();
+ Map<String, RoleStats> roleStats = processInProgressStage(s,
commandsToSchedule);
+ //Check if stage is failed
+ boolean failed = false;
+ for (String role : roleStats.keySet()) {
+ RoleStats stats = roleStats.get(role);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Stats for role:" + role + ", stats=" + stats);
}
- } else {
- try {
- scheduleHostRole(s, cmd);
- } catch (InvalidStateTransitionException e) {
- LOG.warn("Could not schedule host role " + cmd.toString(), e);
- db.abortHostRole(cmd.getHostname(), s.getRequestId(),
s.getStageId(),
- cmd.getRole());
+ if (stats.isRoleFailed()) {
+ failed = true;
+ break;
}
}
- }
- //Check if ready to go to next stage
- boolean goToNextStage = true;
- for (String role : roleStats.keySet()) {
- RoleStats stats = roleStats.get(role);
- if (!stats.isSuccessFactorMet()) {
- goToNextStage = false;
- break;
+ if(!failed) {
+ // Prior stage may have failed and it may need to fail the whole
request
+ failed = hasPreviousStageFailed(s);
+ }
+
+ if (failed) {
+ LOG.warn("Operation completely failed, aborting request id:"
+ + s.getRequestId());
+ db.abortOperation(s.getRequestId());
+ return;
+ }
+
+ //Schedule what we have so far
+ for (ExecutionCommand cmd : commandsToSchedule) {
+ if (cmd.getRole() == Role.AMBARI_SERVER_ACTION) {
+ try {
+ long now = System.currentTimeMillis();
+ String hostName = cmd.getHostname();
+ String roleName = cmd.getRole().toString();
+
+ s.setStartTime(hostName, roleName, now);
+ s.setLastAttemptTime(hostName, roleName, now);
+ s.incrementAttemptCount(hostName, roleName);
+ s.setHostRoleStatus(hostName, roleName, HostRoleStatus.QUEUED);
+ db.hostRoleScheduled(s, hostName, roleName);
+ String actionName =
cmd.getRoleParams().get(ServerAction.ACTION_NAME);
+ this.serverActionManager.executeAction(actionName,
cmd.getCommandParams());
+ reportServerActionSuccess(s, cmd);
+ } catch (AmbariException e) {
+ LOG.warn("Could not execute server action " + cmd.toString(), e);
+ reportServerActionFailure(s, cmd, e.getMessage());
+ }
+ } else {
+ try {
+ scheduleHostRole(s, cmd);
+ } catch (InvalidStateTransitionException e) {
+ LOG.warn("Could not schedule host role " + cmd.toString(), e);
+ db.abortHostRole(cmd.getHostname(), s.getRequestId(),
s.getStageId(),
+ cmd.getRole());
+ }
+ }
+ }
+
+ //Check if ready to go to next stage
+ boolean goToNextStage = true;
+ for (String role : roleStats.keySet()) {
+ RoleStats stats = roleStats.get(role);
+ if (!stats.isSuccessFactorMet()) {
+ goToNextStage = false;
+ break;
+ }
+ }
+ if (!goToNextStage) {
+ return;
}
}
- if (!goToNextStage) {
- return;
- }
+
+ } finally {
+ unitOfWork.end();
}
}
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1483452&r1=1483451&r2=1483452&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
Thu May 16 17:12:21 2013
@@ -31,6 +31,7 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
+import com.google.inject.persist.Transactional;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.ClusterNotFoundException;
import org.apache.ambari.server.DuplicateResourceException;
@@ -2214,7 +2215,8 @@ public class AmbariManagementControllerI
}
}
- private void updateServiceStates(
+ @Transactional
+ void updateServiceStates(
Map<State, List<Service>> changedServices,
Map<State, List<ServiceComponent>> changedComps,
Map<String, Map<State, List<ServiceComponentHost>>> changedScHosts) {
Modified:
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java?rev=1483452&r1=1483451&r2=1483452&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
Thu May 16 17:12:21 2013
@@ -173,8 +173,9 @@ public class AmbariServer {
DelegatingFilterProxy springSecurityFilter = new DelegatingFilterProxy();
springSecurityFilter.setTargetBeanName("springSecurityFilterChain");
- //session-per-request strategy for api
+ //session-per-request strategy for api and agents
root.addFilter(new
FilterHolder(injector.getInstance(AmbariPersistFilter.class)), "/api/*", 1);
+ agentroot.addFilter(new
FilterHolder(injector.getInstance(AmbariPersistFilter.class)), "/agent/*", 1);
if (configs.getApiAuthentication()) {
root.addFilter(new FilterHolder(springSecurityFilter), "/api/*", 1);
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java?rev=1483452&r1=1483451&r2=1483452&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionDBAccessorImpl.java
Thu May 16 17:12:21 2013
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import com.google.inject.persist.UnitOfWork;
import junit.framework.Assert;
import org.apache.ambari.server.AmbariException;
@@ -79,7 +80,7 @@ public class TestActionDBAccessorImpl {
db = injector.getInstance(ActionDBAccessorImpl.class);
am = new ActionManager(5000, 1200000, new ActionQueue(), clusters, db,
- new HostsMap((String) null), null);
+ new HostsMap((String) null), null,
injector.getInstance(UnitOfWork.class));
}
@After
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java?rev=1483452&r1=1483451&r2=1483452&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionManager.java
Thu May 16 17:12:21 2013
@@ -30,6 +30,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
+import com.google.inject.persist.UnitOfWork;
import junit.framework.Assert;
import org.apache.ambari.server.AmbariException;
@@ -63,6 +64,7 @@ public class TestActionManager {
private String clusterName = "cluster1";
private Clusters clusters;
+ private UnitOfWork unitOfWork;
@Before
public void setup() throws AmbariException {
@@ -72,6 +74,7 @@ public class TestActionManager {
clusters.addHost(hostname);
clusters.getHost(hostname).persist();
clusters.addCluster(clusterName);
+ unitOfWork = injector.getInstance(UnitOfWork.class);
}
@After
@@ -83,7 +86,7 @@ public class TestActionManager {
public void testActionResponse() {
ActionDBAccessor db = injector.getInstance(ActionDBAccessorImpl.class);
ActionManager am = new ActionManager(5000, 1200000, new ActionQueue(),
- clusters, db, new HostsMap((String) null), null);
+ clusters, db, new HostsMap((String) null), null, unitOfWork);
populateActionDB(db, hostname);
Stage stage = db.getAllStages(requestId).get(0);
Assert.assertEquals(stageId, stage.getStageId());
@@ -119,7 +122,7 @@ public class TestActionManager {
public void testLargeLogs() {
ActionDBAccessor db = injector.getInstance(ActionDBAccessorImpl.class);
ActionManager am = new ActionManager(5000, 1200000, new ActionQueue(),
- clusters, db, new HostsMap((String) null), null);
+ clusters, db, new HostsMap((String) null), null, unitOfWork);
populateActionDB(db, hostname);
Stage stage = db.getAllStages(requestId).get(0);
Assert.assertEquals(stageId, stage.getStageId());
@@ -204,7 +207,7 @@ public class TestActionManager {
replay(queue, db, clusters);
- ActionManager manager = new ActionManager(0, 0, queue, clusters, db, null,
null);
+ ActionManager manager = new ActionManager(0, 0, queue, clusters, db, null,
null, unitOfWork);
assertSame(listStages, manager.getActions(requestId));
verify(queue, db, clusters);
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java?rev=1483452&r1=1483451&r2=1483452&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java
Thu May 16 17:12:21 2013
@@ -29,6 +29,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import com.google.inject.persist.UnitOfWork;
import junit.framework.Assert;
import org.apache.ambari.server.Role;
@@ -72,6 +73,7 @@ public class TestActionScheduler {
Service serviceObj = mock(Service.class);
ServiceComponent scomp = mock(ServiceComponent.class);
ServiceComponentHost sch = mock(ServiceComponentHost.class);
+ UnitOfWork unitOfWork = mock(UnitOfWork.class);
when(fsm.getCluster(anyString())).thenReturn(oneClusterMock);
when(oneClusterMock.getService(anyString())).thenReturn(serviceObj);
when(serviceObj.getServiceComponent(anyString())).thenReturn(scomp);
@@ -92,7 +94,7 @@ public class TestActionScheduler {
//Keep large number of attempts so that the task is not expired finally
//Small action timeout to test rescheduling
ActionScheduler scheduler = new ActionScheduler(100, 100, db, aq, fsm,
- 10000, new HostsMap((String) null), null);
+ 10000, new HostsMap((String) null), null, unitOfWork);
scheduler.setTaskTimeoutAdjustment(false);
// Start the thread
scheduler.start();
@@ -142,6 +144,7 @@ public class TestActionScheduler {
Service serviceObj = mock(Service.class);
ServiceComponent scomp = mock(ServiceComponent.class);
ServiceComponentHost sch = mock(ServiceComponentHost.class);
+ UnitOfWork unitOfWork = mock(UnitOfWork.class);
when(fsm.getCluster(anyString())).thenReturn(oneClusterMock);
when(oneClusterMock.getService(anyString())).thenReturn(serviceObj);
when(serviceObj.getServiceComponent(anyString())).thenReturn(scomp);
@@ -161,7 +164,7 @@ public class TestActionScheduler {
//Small action timeout to test rescheduling
ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
- new HostsMap((String) null), null);
+ new HostsMap((String) null), null, unitOfWork);
scheduler.setTaskTimeoutAdjustment(false);
// Start the thread
scheduler.start();
@@ -182,6 +185,7 @@ public class TestActionScheduler {
Service serviceObj = mock(Service.class);
ServiceComponent scomp = mock(ServiceComponent.class);
ServiceComponentHost sch = mock(ServiceComponentHost.class);
+ UnitOfWork unitOfWork = mock(UnitOfWork.class);
when(fsm.getCluster(anyString())).thenReturn(oneClusterMock);
when(oneClusterMock.getService(anyString())).thenReturn(serviceObj);
when(serviceObj.getServiceComponent(anyString())).thenReturn(scomp);
@@ -201,7 +205,7 @@ public class TestActionScheduler {
//Small action timeout to test rescheduling
ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
- new HostsMap((String) null), null);
+ new HostsMap((String) null), null, unitOfWork);
scheduler.setTaskTimeoutAdjustment(false);
// Start the thread
scheduler.start();
@@ -225,6 +229,7 @@ public class TestActionScheduler {
Service serviceObj = mock(Service.class);
ServiceComponent scomp = mock(ServiceComponent.class);
ServiceComponentHost sch = mock(ServiceComponentHost.class);
+ UnitOfWork unitOfWork = mock(UnitOfWork.class);
when(fsm.getCluster(anyString())).thenReturn(oneClusterMock);
when(oneClusterMock.getService(anyString())).thenReturn(serviceObj);
when(serviceObj.getServiceComponent(anyString())).thenReturn(scomp);
@@ -242,7 +247,7 @@ public class TestActionScheduler {
db.persistActions(stages);
ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
- new HostsMap((String) null), new ServerActionManagerImpl(fsm));
+ new HostsMap((String) null), new ServerActionManagerImpl(fsm),
unitOfWork);
scheduler.start();
while (!stages.get(0).getHostRoleStatus(hostname, "AMBARI_SERVER_ACTION")
@@ -260,7 +265,7 @@ public class TestActionScheduler {
db.persistActions(stages);
scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
- new HostsMap((String) null), new ServerActionManagerImpl(fsm));
+ new HostsMap((String) null), new ServerActionManagerImpl(fsm),
unitOfWork);
scheduler.start();
while (!stages.get(0).getHostRoleStatus(hostname, "AMBARI_SERVER_ACTION")
@@ -297,6 +302,7 @@ public class TestActionScheduler {
Service serviceObj = mock(Service.class);
ServiceComponent scomp = mock(ServiceComponent.class);
ServiceComponentHost sch = mock(ServiceComponentHost.class);
+ UnitOfWork unitOfWork = mock(UnitOfWork.class);
when(fsm.getCluster(anyString())).thenReturn(oneClusterMock);
when(oneClusterMock.getService(anyString())).thenReturn(serviceObj);
when(serviceObj.getServiceComponent(anyString())).thenReturn(scomp);
@@ -315,9 +321,9 @@ public class TestActionScheduler {
db.persistActions(stages);
ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
- new HostsMap((String) null), new ServerActionManagerImpl(fsm));
+ new HostsMap((String) null), new ServerActionManagerImpl(fsm),
unitOfWork);
ActionManager am = new ActionManager(
- 2, 2, aq, fsm, db, new HostsMap((String) null), new
ServerActionManagerImpl(fsm));
+ 2, 2, aq, fsm, db, new HostsMap((String) null), new
ServerActionManagerImpl(fsm), unitOfWork);
scheduler.doWork();
@@ -344,6 +350,7 @@ public class TestActionScheduler {
Service serviceObj = mock(Service.class);
ServiceComponent scomp = mock(ServiceComponent.class);
ServiceComponentHost sch = mock(ServiceComponentHost.class);
+ UnitOfWork unitOfWork = mock(UnitOfWork.class);
when(fsm.getCluster(anyString())).thenReturn(oneClusterMock);
when(oneClusterMock.getService(anyString())).thenReturn(serviceObj);
when(serviceObj.getServiceComponent(anyString())).thenReturn(scomp);
@@ -404,9 +411,9 @@ public class TestActionScheduler {
db.persistActions(stages);
ActionScheduler scheduler = new ActionScheduler(100, 10000, db, aq, fsm, 3,
- new HostsMap((String) null), new ServerActionManagerImpl(fsm));
+ new HostsMap((String) null), new ServerActionManagerImpl(fsm),
unitOfWork);
ActionManager am = new ActionManager(
- 2, 10000, aq, fsm, db, new HostsMap((String) null), new
ServerActionManagerImpl(fsm));
+ 2, 10000, aq, fsm, db, new HostsMap((String) null), new
ServerActionManagerImpl(fsm), unitOfWork);
scheduler.doWork();
@@ -476,6 +483,7 @@ public class TestActionScheduler {
Service serviceObj = mock(Service.class);
ServiceComponent scomp = mock(ServiceComponent.class);
ServiceComponentHost sch = mock(ServiceComponentHost.class);
+ UnitOfWork unitOfWork = mock(UnitOfWork.class);
when(fsm.getCluster(anyString())).thenReturn(oneClusterMock);
when(oneClusterMock.getService(anyString())).thenReturn(serviceObj);
when(serviceObj.getServiceComponent(anyString())).thenReturn(scomp);
@@ -517,9 +525,9 @@ public class TestActionScheduler {
db.persistActions(stages);
ActionScheduler scheduler = new ActionScheduler(100, 50, db, aq, fsm, 3,
- new HostsMap((String) null), new ServerActionManagerImpl(fsm));
+ new HostsMap((String) null), new ServerActionManagerImpl(fsm),
unitOfWork);
ActionManager am = new ActionManager(
- 2, 2, aq, fsm, db, new HostsMap((String) null), new
ServerActionManagerImpl(fsm));
+ 2, 2, aq, fsm, db, new HostsMap((String) null), new
ServerActionManagerImpl(fsm), unitOfWork);
scheduler.doWork();
Modified:
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java?rev=1483452&r1=1483451&r2=1483452&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
(original)
+++
incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
Thu May 16 17:12:21 2013
@@ -51,6 +51,7 @@ import java.util.Set;
import javax.xml.bind.JAXBException;
+import com.google.inject.persist.UnitOfWork;
import junit.framework.Assert;
import org.apache.ambari.server.AmbariException;
@@ -103,6 +104,7 @@ public class TestHeartbeatHandler {
AmbariMetaInfo metaInfo;
@Inject
Configuration config;
+ private UnitOfWork unitOfWork;
@Before
public void setup() throws Exception {
@@ -112,6 +114,7 @@ public class TestHeartbeatHandler {
injector.injectMembers(this);
metaInfo.init();
log.debug("Using server os type=" + config.getServerOsType());
+ unitOfWork = injector.getInstance(UnitOfWork.class);
}
@After
@@ -360,7 +363,7 @@ public class TestHeartbeatHandler {
clusters.addCluster(DummyCluster);
ActionDBAccessor db = injector.getInstance(ActionDBAccessorImpl.class);
ActionManager am = new ActionManager(5000, 1200000, new ActionQueue(),
clusters, db,
- new HostsMap((String) null), null);
+ new HostsMap((String) null), null, unitOfWork);
populateActionDB(db, DummyHostname1);
Stage stage = db.getAllStages(requestId).get(0);
Assert.assertEquals(stageId, stage.getStageId());
@@ -1214,7 +1217,7 @@ public class TestHeartbeatHandler {
private ActionManager getMockActionManager() {
return new ActionManager(0, 0, null, null,
- new ActionDBInMemoryImpl(), new HostsMap((String) null), null);
+ new ActionDBInMemoryImpl(), new HostsMap((String) null), null,
unitOfWork);
}