You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2016/10/19 16:08:24 UTC
[11/32] ambari git commit: AMBARI-18539 - Remove Unnecessary Locks
Inside Of Host Business Object Implementations (jonathanhurley)
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java
index eccc1ed..8efec98 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeSummaryResourceProviderTest.java
@@ -17,15 +17,21 @@
*/
package org.apache.ambari.server.controller.internal;
-import com.google.inject.Binder;
-import com.google.inject.Guice;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-import com.google.inject.persist.PersistService;
-import com.google.inject.persist.Transactional;
-import com.google.inject.util.Modules;
-import junit.framework.Assert;
+import static org.easymock.EasyMock.anyLong;
+import static org.easymock.EasyMock.anyString;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.ambari.server.Role;
import org.apache.ambari.server.RoleCommand;
import org.apache.ambari.server.actionmanager.HostRoleStatus;
@@ -74,20 +80,16 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
+import com.google.inject.Binder;
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.persist.PersistService;
+import com.google.inject.persist.Transactional;
+import com.google.inject.util.Modules;
-import static org.easymock.EasyMock.anyLong;
-import static org.easymock.EasyMock.anyString;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import junit.framework.Assert;
/**
* UpgradeSummaryResourceProvider tests.
@@ -170,7 +172,6 @@ public class UpgradeSummaryResourceProviderTest {
hostAttributes.put("os_release_version", "6.4");
host.setHostAttributes(hostAttributes);
host.setState(HostState.HEALTHY);
- host.persist();
clusters.mapHostToCluster("h1", "c1");
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedStateTest.java
index 0d7fc67..3b2460a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/DefaultServiceCalculatedStateTest.java
@@ -19,14 +19,15 @@
package org.apache.ambari.server.controller.utilities.state;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostState;
import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.State;
import org.junit.Assert;
-import java.util.HashMap;
-import java.util.Map;
public final class DefaultServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest {
@@ -54,7 +55,6 @@ public final class DefaultServiceCalculatedStateTest extends GeneralServiceCalcu
hostAttributes.put("os_release_version", "6.3");
host.setHostAttributes(hostAttributes);
host.setState(HostState.HEALTHY);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
ServiceComponentHost sch = masterComponent.addServiceComponentHost(hostName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/FlumeServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/FlumeServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/FlumeServiceCalculatedStateTest.java
index 1bc4214..fccc5e7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/FlumeServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/FlumeServiceCalculatedStateTest.java
@@ -18,6 +18,9 @@
package org.apache.ambari.server.controller.utilities.state;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostState;
import org.apache.ambari.server.state.ServiceComponent;
@@ -25,9 +28,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.State;
import org.junit.Assert;
-import java.util.HashMap;
-import java.util.Map;
-
public class FlumeServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest{
@Override
protected String getServiceName() {
@@ -53,7 +53,6 @@ public class FlumeServiceCalculatedStateTest extends GeneralServiceCalculatedSta
hostAttributes.put("os_release_version", "6.3");
host.setHostAttributes(hostAttributes);
host.setState(HostState.HEALTHY);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
ServiceComponentHost sch = masterComponent.addServiceComponentHost(hostName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedStateTest.java
index 35a7b67..378f51e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HBaseServiceCalculatedStateTest.java
@@ -18,6 +18,9 @@
package org.apache.ambari.server.controller.utilities.state;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostState;
import org.apache.ambari.server.state.ServiceComponent;
@@ -25,9 +28,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.State;
import org.junit.Assert;
-import java.util.HashMap;
-import java.util.Map;
-
public class HBaseServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest{
@Override
protected String getServiceName() {
@@ -54,7 +54,6 @@ public class HBaseServiceCalculatedStateTest extends GeneralServiceCalculatedSta
hostAttributes.put("os_release_version", "6.3");
host.setHostAttributes(hostAttributes);
host.setState(HostState.HEALTHY);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
ServiceComponentHost sch = clientComponent.addServiceComponentHost(hostName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedStateTest.java
index a562962..99c90cf 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HDFSServiceCalculatedStateTest.java
@@ -19,6 +19,9 @@
package org.apache.ambari.server.controller.utilities.state;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostState;
import org.apache.ambari.server.state.ServiceComponent;
@@ -26,9 +29,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.State;
import org.junit.Assert;
-import java.util.HashMap;
-import java.util.Map;
-
public class HDFSServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest{
@Override
protected String getServiceName() {
@@ -55,7 +55,6 @@ public class HDFSServiceCalculatedStateTest extends GeneralServiceCalculatedStat
hostAttributes.put("os_release_version", "6.3");
host.setHostAttributes(hostAttributes);
host.setState(HostState.HEALTHY);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
ServiceComponentHost sch = masterComponent.addServiceComponentHost(hostName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedStateTest.java
index ddf1503..2c4dec6 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/HiveServiceCalculatedStateTest.java
@@ -19,6 +19,9 @@
package org.apache.ambari.server.controller.utilities.state;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostState;
import org.apache.ambari.server.state.ServiceComponent;
@@ -26,9 +29,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.State;
import org.junit.Assert;
-import java.util.HashMap;
-import java.util.Map;
-
public class HiveServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest{
@Override
protected String getServiceName() {
@@ -57,7 +57,6 @@ public class HiveServiceCalculatedStateTest extends GeneralServiceCalculatedStat
hostAttributes.put("os_release_version", "6.3");
host.setHostAttributes(hostAttributes);
host.setState(HostState.HEALTHY);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
ServiceComponentHost sch = clientComponent.addServiceComponentHost(hostName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedStateTest.java
index 7e1595e..f6bc2cb 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/OozieServiceCalculatedStateTest.java
@@ -18,6 +18,9 @@
package org.apache.ambari.server.controller.utilities.state;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostState;
import org.apache.ambari.server.state.ServiceComponent;
@@ -25,9 +28,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.State;
import org.junit.Assert;
-import java.util.HashMap;
-import java.util.Map;
-
public class OozieServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest{
@Override
protected String getServiceName() {
@@ -53,7 +53,6 @@ public class OozieServiceCalculatedStateTest extends GeneralServiceCalculatedSta
hostAttributes.put("os_release_version", "6.3");
host.setHostAttributes(hostAttributes);
host.setState(HostState.HEALTHY);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
ServiceComponentHost sch = clientComponent.addServiceComponentHost(hostName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/YarnServiceCalculatedStateTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/YarnServiceCalculatedStateTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/YarnServiceCalculatedStateTest.java
index b5cce0e..996ce69 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/YarnServiceCalculatedStateTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/utilities/state/YarnServiceCalculatedStateTest.java
@@ -19,6 +19,9 @@
package org.apache.ambari.server.controller.utilities.state;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.ambari.server.state.Host;
import org.apache.ambari.server.state.HostState;
import org.apache.ambari.server.state.ServiceComponent;
@@ -26,9 +29,6 @@ import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.State;
import org.junit.Assert;
-import java.util.HashMap;
-import java.util.Map;
-
public class YarnServiceCalculatedStateTest extends GeneralServiceCalculatedStateTest {
@Override
protected String getServiceName() {
@@ -55,7 +55,6 @@ public class YarnServiceCalculatedStateTest extends GeneralServiceCalculatedStat
hostAttributes.put("os_release_version", "6.3");
host.setHostAttributes(hostAttributes);
host.setState(HostState.HEALTHY);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
ServiceComponentHost sch = secondMasterComponent.addServiceComponentHost(hostName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java b/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java
index ce86f83..bdbaf9b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java
@@ -110,7 +110,6 @@ public class EventsTest {
hostAttributes.put("os_release_version", "6.4");
host.setHostAttributes(hostAttributes);
host.setState(HostState.HEALTHY);
- host.persist();
m_cluster = m_clusters.getCluster(m_clusterName);
Assert.assertNotNull(m_cluster);
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java
index 9135732..9a5802d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/events/listeners/upgrade/HostVersionOutOfSyncListenerTest.java
@@ -387,7 +387,6 @@ public class HostVersionOutOfSyncListenerTest {
addHost("h2");
clusters.mapHostToCluster("h2", "c1");
clusters.getHost("h2").setState(HostState.HEALTHY);
- clusters.getHost("h2").persist();
StackId stackId = new StackId(this.stackId);
RepositoryVersionEntity repositoryVersionEntity = helper.getOrCreateRepositoryVersion(stackId,
@@ -445,8 +444,6 @@ public class HostVersionOutOfSyncListenerTest {
hostAttributes.put("os_family", "redhat");
hostAttributes.put("os_release_version", "6.4");
host1.setHostAttributes(hostAttributes);
-
- host1.persist();
}
private void addService(Cluster cl, List<String> hostList,
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
index f605276..5280ae6 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
@@ -410,7 +410,6 @@ public class OrmTestHelper {
hostAttributes.put("os_release_version", "6.4");
host.setHostAttributes(hostAttributes);
host.setState(HostState.HEALTHY);
- host.persist();
clusters.mapHostToCluster(hostName, cluster.getClusterName());
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
index 207b4c7..d12adde 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
@@ -152,7 +152,6 @@ public class ComponentVersionCheckActionTest {
hostAttributes.put("os_family", "redhat");
hostAttributes.put("os_release_version", "6");
host.setHostAttributes(hostAttributes);
- host.persist();
// Create the starting repo version
m_helper.getOrCreateRepositoryVersion(sourceStack, sourceRepo);
@@ -208,7 +207,6 @@ public class ComponentVersionCheckActionTest {
hostAttributes.put("os_family", "redhat");
hostAttributes.put("os_release_version", "6");
host.setHostAttributes(hostAttributes);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java
index 5462f7b..480dfb3 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ConfigureActionTest.java
@@ -1694,7 +1694,6 @@ public class ConfigureActionTest {
hostAttributes.put("os_family", "redhat");
hostAttributes.put("os_release_version", "6");
host.setHostAttributes(hostAttributes);
- host.persist();
// Creating starting repo
m_helper.getOrCreateRepositoryVersion(HDP_220_STACK, HDP_2_2_0_0);
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
index 50ce7b4..d3d8b4c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
@@ -191,7 +191,6 @@ public class UpgradeActionTest {
hostAttributes.put("os_family", "redhat");
hostAttributes.put("os_release_version", "6");
host.setHostAttributes(hostAttributes);
- host.persist();
// Create the starting repo version
m_helper.getOrCreateRepositoryVersion(sourceStack, sourceRepo);
@@ -229,7 +228,6 @@ public class UpgradeActionTest {
hostAttributes.put("os_family", "redhat");
hostAttributes.put("os_release_version", "6");
host.setHostAttributes(hostAttributes);
- host.persist();
// Create the starting repo version
m_helper.getOrCreateRepositoryVersion(sourceStack, sourceRepo);
@@ -295,7 +293,6 @@ public class UpgradeActionTest {
hostAttributes.put("os_family", "redhat");
hostAttributes.put("os_release_version", "6");
host.setHostAttributes(hostAttributes);
- host.persist();
// without this, HostEntity will not have a relation to ClusterEntity
clusters.mapHostsToCluster(Collections.singleton(hostName), clusterName);
@@ -376,7 +373,6 @@ public class UpgradeActionTest {
hostAttributes.put("os_family", "redhat");
hostAttributes.put("os_release_version", "6");
host.setHostAttributes(hostAttributes);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java
index d8b6a83..80665a5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigGroupTest.java
@@ -72,8 +72,6 @@ public class ConfigGroupTest {
clusters.addHost("h2");
Assert.assertNotNull(clusters.getHost("h1"));
Assert.assertNotNull(clusters.getHost("h2"));
- clusters.getHost("h1").persist();
- clusters.getHost("h2").persist();
}
@After
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
index caa06e5..56ae7ee 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ConfigHelperTest.java
@@ -108,8 +108,6 @@ public class ConfigHelperTest {
clusters.addHost("h2");
Assert.assertNotNull(clusters.getHost("h1"));
Assert.assertNotNull(clusters.getHost("h2"));
- clusters.getHost("h1").persist();
- clusters.getHost("h2").persist();
// core-site
ConfigurationRequest cr = new ConfigurationRequest();
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/RequestExecutionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/RequestExecutionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/RequestExecutionTest.java
index c6c37c5..31d3028 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/RequestExecutionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/RequestExecutionTest.java
@@ -74,9 +74,6 @@ public class RequestExecutionTest {
Assert.assertNotNull(clusters.getHost("h1"));
Assert.assertNotNull(clusters.getHost("h2"));
Assert.assertNotNull(clusters.getHost("h3"));
- clusters.getHost("h1").persist();
- clusters.getHost("h2").persist();
- clusters.getHost("h3").persist();
}
@After
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
index b043da1..cfe5d61 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
@@ -18,10 +18,14 @@
package org.apache.ambari.server.state;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.persist.PersistService;
-import junit.framework.Assert;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
import org.apache.ambari.server.controller.ServiceComponentResponse;
@@ -46,13 +50,11 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.persist.PersistService;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import junit.framework.Assert;
public class ServiceComponentTest {
@@ -181,12 +183,10 @@ public class ServiceComponentTest {
h.setIPv6(hostname + "ipv6");
Map<String, String> hostAttributes = new HashMap<String, String>();
- hostAttributes.put("os_family", "redhat");
- hostAttributes.put("os_release_version", "6.3");
- h.setHostAttributes(hostAttributes);
-
+ hostAttributes.put("os_family", "redhat");
+ hostAttributes.put("os_release_version", "6.3");
+ h.setHostAttributes(hostAttributes);
- h.persist();
clusters.mapHostToCluster(hostname, clusterName);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
index 8f00b72..65751af 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceTest.java
@@ -18,7 +18,6 @@
package org.apache.ambari.server.state;
-import junit.framework.Assert;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
@@ -40,6 +39,8 @@ import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.persist.PersistService;
+import junit.framework.Assert;
+
public class ServiceTest {
private Clusters clusters;
@@ -339,8 +340,6 @@ public class ServiceTest {
hostAttributes.put("os_release_version", "6.3");
h.setHostAttributes(hostAttributes);
-
- h.persist();
clusters.mapHostToCluster(hostname, clusterName);
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
index c2e1f75..a1d4c4b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/UpgradeHelperTest.java
@@ -508,8 +508,6 @@ public class UpgradeHelperTest {
Clusters clusters = injector.getInstance(Clusters.class);
Host h4 = clusters.getHost("h4");
h4.setState(HostState.HEARTBEAT_LOST);
- h4.persist();
-
List<ServiceComponentHost> schs = cluster.getServiceComponentHosts("h4");
assertEquals(1, schs.size());
@@ -1224,7 +1222,6 @@ public class UpgradeHelperTest {
host.setHostAttributes(hostAttributes);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
}
@@ -1441,7 +1438,6 @@ public class UpgradeHelperTest {
host.setHostAttributes(hostAttributes);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
}
@@ -1521,7 +1517,6 @@ public class UpgradeHelperTest {
host.setHostAttributes(hostAttributes);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
}
@@ -1587,7 +1582,6 @@ public class UpgradeHelperTest {
host.setHostAttributes(hostAttributes);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
}
@@ -1654,7 +1648,6 @@ public class UpgradeHelperTest {
host.setHostAttributes(hostAttributes);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
}
@@ -1773,7 +1766,6 @@ public class UpgradeHelperTest {
host.setHostAttributes(hostAttributes);
- host.persist();
clusters.mapHostToCluster(hostName, clusterName);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterDeadlockTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterDeadlockTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterDeadlockTest.java
index 2ed5a2d..ab2628b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterDeadlockTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterDeadlockTest.java
@@ -141,7 +141,6 @@ public class ClusterDeadlockTest {
clusters.addHost(hostName);
setOsFamily(clusters.getHost(hostName), "redhat", "6.4");
- clusters.getHost(hostName).persist();
clusters.mapHostToCluster(hostName, "c1");
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterImplTest.java
index aca32e4..ba0ff11 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterImplTest.java
@@ -18,11 +18,20 @@
package org.apache.ambari.server.state.cluster;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Sets;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.persist.PersistService;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.createMockBuilder;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import org.apache.ambari.server.HostNotFoundException;
import org.apache.ambari.server.controller.AmbariSessionManager;
@@ -35,26 +44,13 @@ import org.apache.ambari.server.state.Service;
import org.apache.ambari.server.state.ServiceComponent;
import org.apache.ambari.server.state.ServiceComponentHost;
import org.apache.ambari.server.state.StackId;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.createMockBuilder;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.verify;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Sets;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
public class ClusterImplTest {
@@ -211,11 +207,9 @@ public class ClusterImplTest {
Host host1 = clusters.getHost(hostName1);
host1.setHostAttributes(ImmutableMap.of("os_family", "centos", "os_release_version", "6.0"));
- host1.persist();
Host host2 = clusters.getHost(hostName2);
host2.setHostAttributes(ImmutableMap.of("os_family", "centos", "os_release_version", "6.0"));
- host2.persist();
clusters.mapHostsToCluster(Sets.newHashSet(hostName1, hostName2), clusterName);
@@ -279,11 +273,9 @@ public class ClusterImplTest {
Host host1 = clusters.getHost(hostName1);
host1.setHostAttributes(ImmutableMap.of("os_family", "centos", "os_release_version", "6.0"));
- host1.persist();
Host host2 = clusters.getHost(hostName2);
host2.setHostAttributes(ImmutableMap.of("os_family", "centos", "os_release_version", "6.0"));
- host2.persist();
clusters.mapHostsToCluster(Sets.newHashSet(hostName1, hostName2), clusterName);
@@ -320,11 +312,9 @@ public class ClusterImplTest {
Host host1 = clusters.getHost(hostName1);
host1.setHostAttributes(ImmutableMap.of("os_family", "centos", "os_release_version", "6.0"));
- host1.persist();
Host host2 = clusters.getHost(hostName2);
host2.setHostAttributes(ImmutableMap.of("os_family", "centos", "os_release_version", "6.0"));
- host2.persist();
clusters.mapHostsToCluster(Sets.newHashSet(hostName1, hostName2), clusterName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
index 6005ab5..4d39f71 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java
@@ -238,8 +238,6 @@ public class ClusterTest {
Set<String> hostNames = new HashSet<String>() {{ add("h1"); add("h2"); }};
for (String hostName : hostNames) {
clusters.addHost(hostName);
- Host host = clusters.getHost(hostName);
- host.persist();
HostEntity hostEntity = hostDAO.findByName(hostName);
hostEntity.setIpv4("ipv4");
@@ -510,7 +508,6 @@ public class ClusterTest {
host.setIPv4("ipv4");
host.setIPv6("ipv6");
host.setHostAttributes(hostAttributes);
- host.persist();
}
/**
@@ -1162,7 +1159,6 @@ public class ClusterTest {
host.setState(HostState.HEALTHY);
host.setHealthStatus(new HostHealthStatus(HostHealthStatus.HealthStatus.HEALTHY, ""));
host.setStatus(host.getHealthStatus().getHealthStatus().name());
- host.persist();
c1.setDesiredStackVersion(new StackId("HDP-2.0.6"));
clusters.mapHostToCluster("h3", "c1");
@@ -2316,7 +2312,6 @@ public class ClusterTest {
hostAttributes.put("os_family", "redhat");
hostAttributes.put("os_release_version", "5.9");
h.setHostAttributes(hostAttributes);
- h.persist();
}
String v1 = "2.0.5-1";
@@ -2387,7 +2382,6 @@ public class ClusterTest {
hostAttributes.put("os_family", "redhat");
hostAttributes.put("os_release_version", "5.9");
h.setHostAttributes(hostAttributes);
- h.persist();
}
String v1 = "2.0.5-1";
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersDeadlockTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersDeadlockTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersDeadlockTest.java
index 190f64d..d2d07b5 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersDeadlockTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersDeadlockTest.java
@@ -25,9 +25,6 @@ import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
-import com.google.inject.Provider;
-import junit.framework.Assert;
-
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.ServiceComponentNotFoundException;
import org.apache.ambari.server.ServiceNotFoundException;
@@ -57,9 +54,12 @@ import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Module;
+import com.google.inject.Provider;
import com.google.inject.persist.PersistService;
import com.google.inject.util.Modules;
+import junit.framework.Assert;
+
/**
* Tests AMBARI-9738 which produced a deadlock during read and writes between
* {@link ClustersImpl} and {@link ClusterImpl}.
@@ -294,7 +294,6 @@ public class ClustersDeadlockTest {
String hostName = "c64-" + hostNameCounter.getAndIncrement();
clusters.addHost(hostName);
setOsFamily(clusters.getHost(hostName), "redhat", "6.4");
- clusters.getHost(hostName).persist();
clusters.mapHostToCluster(hostName, CLUSTER_NAME);
Thread.sleep(10);
@@ -322,7 +321,6 @@ public class ClustersDeadlockTest {
String hostName = "c64-" + hostNameCounter.getAndIncrement();
clusters.addHost(hostName);
setOsFamily(clusters.getHost(hostName), "redhat", "6.4");
- clusters.getHost(hostName).persist();
clusters.mapHostToCluster(hostName, CLUSTER_NAME);
// create DATANODE on this host so that we end up exercising the
@@ -357,7 +355,6 @@ public class ClustersDeadlockTest {
clusters.addHost(hostName);
setOsFamily(clusters.getHost(hostName), "redhat", "6.4");
- clusters.getHost(hostName).persist();
clusters.mapHostToCluster(hostName, CLUSTER_NAME);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
index bb3db03..2f2be0c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersTest.java
@@ -296,9 +296,6 @@ public class ClustersTest {
setOsFamily(clusters.getHost(h1), "redhat", "6.4");
setOsFamily(clusters.getHost(h2), "redhat", "5.9");
setOsFamily(clusters.getHost(h3), "redhat", "6.4");
- clusters.getHost(h1).persist();
- clusters.getHost(h2).persist();
- clusters.getHost(h3).persist();
try {
clusters.getClustersForHost(h4);
@@ -381,9 +378,6 @@ public class ClustersTest {
setOsFamily(clusters.getHost(h1), "redhat", "6.4");
setOsFamily(clusters.getHost(h2), "redhat", "5.9");
setOsFamily(clusters.getHost(h3), "redhat", "6.4");
- clusters.getHost(h1).persist();
- clusters.getHost(h2).persist();
- clusters.getHost(h3).persist();
clusters.mapHostToCluster(h1, c1);
clusters.mapHostToCluster(h2, c1);
@@ -435,8 +429,6 @@ public class ClustersTest {
Host host2 = clusters.getHost(h2);
setOsFamily(clusters.getHost(h1), "centos", "5.9");
setOsFamily(clusters.getHost(h2), "centos", "5.9");
- host1.persist();
- host2.persist();
clusters.mapHostsToCluster(new HashSet<String>() {
{
@@ -446,7 +438,6 @@ public class ClustersTest {
// host config override
host1.addDesiredConfig(cluster.getClusterId(), true, "_test", config2);
- host1.persist();
Service hdfs = cluster.addService("HDFS");
hdfs.persist();
@@ -705,7 +696,6 @@ public class ClustersTest {
Host host = clusters.getHost(hostName);
setOsFamily(clusters.getHost(hostName), "centos", "5.9");
- host.persist();
Set<String> hostnames = new HashSet<>();
hostnames.add(hostName);
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ConcurrentServiceConfigVersionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ConcurrentServiceConfigVersionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ConcurrentServiceConfigVersionTest.java
index ff5cbe8..992b8fe 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ConcurrentServiceConfigVersionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ConcurrentServiceConfigVersionTest.java
@@ -115,7 +115,6 @@ public class ConcurrentServiceConfigVersionTest {
String hostName = "c6401.ambari.apache.org";
clusters.addHost(hostName);
setOsFamily(clusters.getHost(hostName), "redhat", "6.4");
- clusters.getHost(hostName).persist();
clusters.mapHostToCluster(hostName, "c1");
Service service = installService("HDFS");
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ServiceComponentHostConcurrentWriteDeadlockTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ServiceComponentHostConcurrentWriteDeadlockTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ServiceComponentHostConcurrentWriteDeadlockTest.java
index 7d2ba4d..0f272f6 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ServiceComponentHostConcurrentWriteDeadlockTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ServiceComponentHostConcurrentWriteDeadlockTest.java
@@ -130,7 +130,6 @@ public class ServiceComponentHostConcurrentWriteDeadlockTest {
String hostName = "c6401";
clusters.addHost(hostName);
setOsFamily(clusters.getHost(hostName), "redhat", "6.4");
- clusters.getHost(hostName).persist();
clusters.mapHostToCluster(hostName, "c1");
Service service = installService("HDFS");
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostImplTest.java
index 4ff9bf4..fa8622d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostImplTest.java
@@ -17,25 +17,21 @@
*/
package org.apache.ambari.server.state.host;
-import com.google.gson.Gson;
-import com.google.inject.Injector;
+import static org.easymock.EasyMock.expect;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Map;
+
import org.apache.ambari.server.orm.dao.HostDAO;
import org.apache.ambari.server.orm.dao.HostStateDAO;
import org.apache.ambari.server.orm.entities.HostEntity;
import org.apache.ambari.server.orm.entities.HostStateEntity;
-import org.apache.ambari.server.state.Clusters;
-import org.apache.ambari.server.state.HostHealthStatus;
+import org.easymock.EasyMockSupport;
import org.junit.Test;
-import java.util.Map;
-
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.*;
+import com.google.gson.Gson;
-public class HostImplTest {
+public class HostImplTest extends EasyMockSupport {
@Test
public void testGetHostAttributes() throws Exception {
@@ -43,36 +39,30 @@ public class HostImplTest {
HostEntity hostEntity = createNiceMock(HostEntity.class);
HostStateEntity hostStateEntity = createNiceMock(HostStateEntity.class);
HostDAO hostDAO = createNiceMock(HostDAO.class);
- Injector injector = createNiceMock(Injector.class);
HostStateDAO hostStateDAO = createNiceMock(HostStateDAO.class);
-
Gson gson = new Gson();
- expect(injector.getInstance(Gson.class)).andReturn(gson).anyTimes();
- expect(injector.getInstance(HostDAO.class)).andReturn(hostDAO).anyTimes();
- expect(injector.getInstance(HostStateDAO.class)).andReturn(hostStateDAO).anyTimes();
expect(hostEntity.getHostAttributes()).andReturn("{\"foo\": \"aaa\", \"bar\":\"bbb\"}").anyTimes();
expect(hostEntity.getHostId()).andReturn(1L).anyTimes();
expect(hostEntity.getHostName()).andReturn("host1").anyTimes();
expect(hostEntity.getHostStateEntity()).andReturn(hostStateEntity).anyTimes();
- expect(hostDAO.findById(1L)).andReturn(hostEntity).once();
- expect(hostStateDAO.findByHostId(1L)).andReturn(hostStateEntity).once();
+ expect(hostDAO.findById(1L)).andReturn(hostEntity).atLeastOnce();
- replay(hostEntity, hostStateEntity, injector, hostDAO);
- HostImpl host = new HostImpl(hostEntity, false, injector);
+ replayAll();
+ HostImpl host = new HostImpl(hostEntity, gson, hostDAO, hostStateDAO);
Map<String, String> hostAttributes = host.getHostAttributes();
assertEquals("aaa", hostAttributes.get("foo"));
assertEquals("bbb", hostAttributes.get("bar"));
- host = new HostImpl(hostEntity, true, injector);
+ host = new HostImpl(hostEntity, gson, hostDAO, hostStateDAO);
hostAttributes = host.getHostAttributes();
assertEquals("aaa", hostAttributes.get("foo"));
assertEquals("bbb", hostAttributes.get("bar"));
- verify(hostEntity, hostStateEntity, injector, hostDAO);
+ verifyAll();
}
@Test
@@ -82,29 +72,25 @@ public class HostImplTest {
HostStateEntity hostStateEntity = createNiceMock(HostStateEntity.class);
HostDAO hostDAO = createNiceMock(HostDAO.class);
HostStateDAO hostStateDAO = createNiceMock(HostStateDAO.class);
- Injector injector = createNiceMock(Injector.class);
Gson gson = new Gson();
- expect(injector.getInstance(Gson.class)).andReturn(gson).anyTimes();
- expect(injector.getInstance(HostDAO.class)).andReturn(hostDAO).anyTimes();
- expect(injector.getInstance(HostStateDAO.class)).andReturn(hostStateDAO).anyTimes();
expect(hostEntity.getHostAttributes()).andReturn("{\"foo\": \"aaa\", \"bar\":\"bbb\"}").anyTimes();
expect(hostEntity.getHostName()).andReturn("host1").anyTimes();
expect(hostEntity.getHostId()).andReturn(1L).anyTimes();
expect(hostEntity.getHostStateEntity()).andReturn(hostStateEntity).anyTimes();
expect(hostDAO.findById(1L)).andReturn(hostEntity).anyTimes();
- expect(hostStateDAO.findByHostId(1L)).andReturn(hostStateEntity).once();
+ expect(hostStateDAO.findByHostId(1L)).andReturn(hostStateEntity).atLeastOnce();
- replay(hostEntity, hostStateEntity, injector, hostDAO);
- HostImpl host = new HostImpl(hostEntity, false, injector);
+ replayAll();
+ HostImpl host = new HostImpl(hostEntity, gson, hostDAO, hostStateDAO);
host.getHealthStatus();
- host = new HostImpl(hostEntity, true, injector);
+ host = new HostImpl(hostEntity, gson, hostDAO, hostStateDAO);
host.getHealthStatus();
- verify(hostEntity, hostStateEntity, injector, hostDAO);
+ verifyAll();
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
index 99fc0a1..596f381 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/host/HostTest.java
@@ -164,9 +164,11 @@ public class HostTest {
HostRegistrationRequestEvent e =
new HostRegistrationRequestEvent("foo", agentVersion, currentTime,
info, agentEnv);
+
if (!firstReg) {
- Assert.assertTrue(host.isPersisted());
+ Assert.assertNotNull(host.getHostId());
}
+
host.handleEvent(e);
Assert.assertEquals(currentTime, host.getLastRegistrationTime());
@@ -378,7 +380,6 @@ public class HostTest {
hostAttributes.put("os_release_version", "6.3");
host.setHostAttributes(hostAttributes);
- host.persist();
c1.setDesiredStackVersion(stackId);
clusters.mapHostToCluster("h1", "c1");
@@ -437,8 +438,6 @@ public class HostTest {
hostAttributes.put("os_release_version", "6.3");
host.setHostAttributes(hostAttributes);
- host.persist();
-
helper.getOrCreateRepositoryVersion(stackId, stackId.getStackVersion());
c1.createClusterVersion(stackId, stackId.getStackVersion(), "admin",
RepositoryVersionState.INSTALLING);
@@ -457,4 +456,19 @@ public class HostTest {
Assert.assertNotNull(stateEntity.getMaintenanceState());
Assert.assertEquals(MaintenanceState.ON, host.getMaintenanceState(c1.getClusterId()));
}
+
+ @Test
+ public void testHostPersist() throws Exception {
+ clusters.addHost("foo");
+ Host host = clusters.getHost("foo");
+
+ String rackInfo = "rackInfo";
+ long lastRegistrationTime = System.currentTimeMillis();
+
+ host.setRackInfo(rackInfo);
+ host.setLastRegistrationTime(lastRegistrationTime);
+
+ Assert.assertEquals(rackInfo, host.getRackInfo());
+ Assert.assertEquals(lastRegistrationTime, host.getLastRegistrationTime());
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/38700445/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java
index 243cb4f..7f12eb7 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostTest.java
@@ -150,7 +150,6 @@ public class ServiceComponentHostTest {
clusters.addHost(hostName);
Host host = clusters.getHost(hostName);
host.setHostAttributes(hostAttributes);
- host.persist();
}
clusterEntity.setHostEntities(hostEntities);