Repository: ambari Updated Branches: refs/heads/trunk f9eade043 -> fdd07bd81
AMBARI-16082. Test Refresh Phase 1 (#3) (jonathanhurley) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/fdd07bd8 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/fdd07bd8 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/fdd07bd8 Branch: refs/heads/trunk Commit: fdd07bd8159efed093a5bea5b92fe6ec677f251e Parents: f9eade0 Author: Jonathan Hurley <[email protected]> Authored: Thu Apr 28 16:42:43 2016 -0400 Committer: Jonathan Hurley <[email protected]> Committed: Fri Apr 29 09:36:02 2016 -0400 ---------------------------------------------------------------------- .../actionmanager/ExecutionCommandWrapper.java | 33 ++++--- .../ExecutionCommandWrapperFactory.java | 32 +++++++ .../server/actionmanager/HostRoleCommand.java | 23 +++-- .../HostRoleCommandFactoryImpl.java | 12 ++- .../ambari/server/actionmanager/Stage.java | 12 ++- .../server/actionmanager/StageFactoryImpl.java | 20 ++--- .../server/controller/ControllerModule.java | 79 ++++++++-------- .../ExecutionCommandWrapperTest.java | 6 +- .../ambari/server/agent/AgentResourceTest.java | 6 +- .../internal/CalculatedStatusTest.java | 21 ++++- .../internal/TaskResourceProviderTest.java | 4 +- .../UpgradeResourceProviderHDP22Test.java | 4 +- .../AutoSkipFailedSummaryActionTest.java | 72 ++++++++++----- .../ambari/server/utils/StageUtilsTest.java | 94 +++++++++++--------- 14 files changed, 261 insertions(+), 157 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java index 52febc4..ef12c3a 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapper.java @@ -31,25 +31,36 @@ import org.apache.ambari.server.state.Cluster; import org.apache.ambari.server.state.Clusters; import org.apache.ambari.server.state.ConfigHelper; import org.apache.ambari.server.utils.StageUtils; - -import com.google.inject.Inject; -import com.google.inject.Injector; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.inject.Inject; +import com.google.inject.assistedinject.Assisted; +import com.google.inject.assistedinject.AssistedInject; + public class ExecutionCommandWrapper { - @Inject - static Injector injector; + private final static Logger LOG = LoggerFactory.getLogger(ExecutionCommandWrapper.class); private static String DELETED = "DELETED_"; String jsonExecutionCommand = null; ExecutionCommand executionCommand = null; - public ExecutionCommandWrapper(String jsonExecutionCommand) { + @Inject + Clusters clusters; + + @Inject + HostRoleCommandDAO hostRoleCommandDAO; + + @Inject + ConfigHelper configHelper; + + @AssistedInject + public ExecutionCommandWrapper(@Assisted String jsonExecutionCommand) { this.jsonExecutionCommand = jsonExecutionCommand; } - public ExecutionCommandWrapper(ExecutionCommand executionCommand) { + @AssistedInject + public ExecutionCommandWrapper(@Assisted ExecutionCommand executionCommand) { this.executionCommand = executionCommand; } @@ -60,23 +71,19 @@ public class ExecutionCommandWrapper { } else if (jsonExecutionCommand != null) { executionCommand = StageUtils.getGson().fromJson(jsonExecutionCommand, ExecutionCommand.class); - if (injector == null) { - throw new RuntimeException("Injector not found, configuration cannot be restored"); - } else if (executionCommand.getConfigurationTags() != null && + if (executionCommand.getConfigurationTags() != null + && !executionCommand.getConfigurationTags().isEmpty()) { // For a configuration type, both tag and an actual configuration can be stored // Configurations from the tag is always expanded and then over-written by the actual // global:version1:{a1:A1,b1:B1,d1:D1} + global:{a1:A2,c1:C1,DELETED_d1:x} ==> // global:{a1:A2,b1:B1,c1:C1} - Clusters clusters = injector.getInstance(Clusters.class); - HostRoleCommandDAO hostRoleCommandDAO = injector.getInstance(HostRoleCommandDAO.class); Long clusterId = hostRoleCommandDAO.findByPK( executionCommand.getTaskId()).getStage().getClusterId(); try { Cluster cluster = clusters.getClusterById(clusterId); - ConfigHelper configHelper = injector.getInstance(ConfigHelper.class); Map<String, Map<String, String>> configurationTags = executionCommand.getConfigurationTags(); // Execution commands have config-tags already set during their creation. However, these http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperFactory.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperFactory.java new file mode 100644 index 0000000..29ee709 --- /dev/null +++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperFactory.java @@ -0,0 +1,32 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.ambari.server.actionmanager; + +import org.apache.ambari.server.agent.ExecutionCommand; + +/** + * The {@link ExecutionCommandWrapperFactory} is used to create instances of + * {@link ExecutionCommandWrapper} that have Guice injected members set. + */ +public interface ExecutionCommandWrapperFactory { + + ExecutionCommandWrapper createFromJson(String jsonExecutionCommand); + + ExecutionCommandWrapper createFromCommand(ExecutionCommand executionCommand); + +} http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java index 83fa6b9..2b9c10b 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommand.java @@ -75,6 +75,9 @@ public class HostRoleCommand { @Inject private HostDAO hostDAO; + @Inject + private ExecutionCommandWrapperFactory ecwFactory; + /** * Simple constructor, should be created using the Factory class. * @param hostName Host name @@ -85,8 +88,9 @@ public class HostRoleCommand { */ @AssistedInject public HostRoleCommand(String hostName, Role role, - ServiceComponentHostEvent event, RoleCommand command, HostDAO hostDAO, ExecutionCommandDAO executionCommandDAO) { - this(hostName, role, event, command, false, false, hostDAO, executionCommandDAO); + ServiceComponentHostEvent event, RoleCommand command, HostDAO hostDAO, + ExecutionCommandDAO executionCommandDAO, ExecutionCommandWrapperFactory ecwFactory) { + this(hostName, role, event, command, false, false, hostDAO, executionCommandDAO, ecwFactory); } /** @@ -101,9 +105,10 @@ public class HostRoleCommand { @AssistedInject public HostRoleCommand(String hostName, Role role, ServiceComponentHostEvent event, RoleCommand roleCommand, boolean retryAllowed, boolean autoSkipFailure, HostDAO hostDAO, - ExecutionCommandDAO executionCommandDAO) { + ExecutionCommandDAO executionCommandDAO, ExecutionCommandWrapperFactory ecwFactory) { this.hostDAO = hostDAO; this.executionCommandDAO = executionCommandDAO; + this.ecwFactory = ecwFactory; this.role = role; this.event = new ServiceComponentHostEventWrapper(event); @@ -121,9 +126,10 @@ public class HostRoleCommand { @AssistedInject public HostRoleCommand(Host host, Role role, ServiceComponentHostEvent event, RoleCommand roleCommand, boolean retryAllowed, boolean autoSkipFailure, HostDAO hostDAO, - ExecutionCommandDAO executionCommandDAO) { + ExecutionCommandDAO executionCommandDAO, ExecutionCommandWrapperFactory ecwFactory) { this.hostDAO = hostDAO; this.executionCommandDAO = executionCommandDAO; + this.ecwFactory = ecwFactory; this.role = role; this.event = new ServiceComponentHostEventWrapper(event); @@ -135,9 +141,11 @@ public class HostRoleCommand { } @AssistedInject - public HostRoleCommand(@Assisted HostRoleCommandEntity hostRoleCommandEntity, HostDAO hostDAO, ExecutionCommandDAO executionCommandDAO) { + public HostRoleCommand(@Assisted HostRoleCommandEntity hostRoleCommandEntity, HostDAO hostDAO, + ExecutionCommandDAO executionCommandDAO, ExecutionCommandWrapperFactory ecwFactory) { this.hostDAO = hostDAO; this.executionCommandDAO = executionCommandDAO; + this.ecwFactory = ecwFactory; taskId = hostRoleCommandEntity.getTaskId(); @@ -381,9 +389,8 @@ public class HostRoleCommand { if (commandEntity == null) { throw new RuntimeException("Invalid DB state, broken one-to-one relation for taskId=" + taskId); } - executionCommandWrapper = new ExecutionCommandWrapper(new String( - commandEntity.getCommand() - )); + + executionCommandWrapper = ecwFactory.createFromJson(new String(commandEntity.getCommand())); } return executionCommandWrapper; http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommandFactoryImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommandFactoryImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommandFactoryImpl.java index cf1e989..bad1926 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommandFactoryImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/HostRoleCommandFactoryImpl.java @@ -53,7 +53,8 @@ public class HostRoleCommandFactoryImpl implements HostRoleCommandFactory { ServiceComponentHostEvent event, RoleCommand command) { return new HostRoleCommand(hostName, role, event, command, injector.getInstance(HostDAO.class), - injector.getInstance(ExecutionCommandDAO.class)); + injector.getInstance(ExecutionCommandDAO.class), + injector.getInstance(ExecutionCommandWrapperFactory.class)); } /** @@ -63,7 +64,8 @@ public class HostRoleCommandFactoryImpl implements HostRoleCommandFactory { public HostRoleCommand create(String hostName, Role role, ServiceComponentHostEvent event, RoleCommand command, boolean retryAllowed, boolean autoSkipFailure) { return new HostRoleCommand(hostName, role, event, command, retryAllowed, autoSkipFailure, - injector.getInstance(HostDAO.class), injector.getInstance(ExecutionCommandDAO.class)); + injector.getInstance(HostDAO.class), injector.getInstance(ExecutionCommandDAO.class), + injector.getInstance(ExecutionCommandWrapperFactory.class)); } /** @@ -73,7 +75,8 @@ public class HostRoleCommandFactoryImpl implements HostRoleCommandFactory { public HostRoleCommand create(Host host, Role role, ServiceComponentHostEvent event, RoleCommand command, boolean retryAllowed, boolean autoSkipFailure) { return new HostRoleCommand(host, role, event, command, retryAllowed, autoSkipFailure, - injector.getInstance(HostDAO.class), injector.getInstance(ExecutionCommandDAO.class)); + injector.getInstance(HostDAO.class), injector.getInstance(ExecutionCommandDAO.class), + injector.getInstance(ExecutionCommandWrapperFactory.class)); } /** @@ -85,6 +88,7 @@ public class HostRoleCommandFactoryImpl implements HostRoleCommandFactory { public HostRoleCommand createExisting(HostRoleCommandEntity hostRoleCommandEntity) { return new HostRoleCommand(hostRoleCommandEntity, injector.getInstance(HostDAO.class), - injector.getInstance(ExecutionCommandDAO.class)); + injector.getInstance(ExecutionCommandDAO.class), + injector.getInstance(ExecutionCommandWrapperFactory.class)); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java index 5a313d8..3fbeef9 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/Stage.java @@ -95,6 +95,9 @@ public class Stage { @Inject private HostRoleCommandFactory hostRoleCommandFactory; + @Inject + private ExecutionCommandWrapperFactory ecwFactory; + @AssistedInject public Stage(@Assisted long requestId, @Assisted("logDir") String logDir, @@ -104,7 +107,7 @@ public class Stage { @Assisted("clusterHostInfo") String clusterHostInfo, @Assisted("commandParamsStage") String commandParamsStage, @Assisted("hostParamsStage") String hostParamsStage, - HostRoleCommandFactory hostRoleCommandFactory) { + HostRoleCommandFactory hostRoleCommandFactory, ExecutionCommandWrapperFactory ecwFactory) { wrappersLoaded = true; this.requestId = requestId; this.logDir = logDir; @@ -119,12 +122,15 @@ public class Stage { supportsAutoSkipOnFailure = false; this.hostRoleCommandFactory = hostRoleCommandFactory; + this.ecwFactory = ecwFactory; } @AssistedInject public Stage(@Assisted StageEntity stageEntity, HostRoleCommandDAO hostRoleCommandDAO, - ActionDBAccessor dbAccessor, Clusters clusters, HostRoleCommandFactory hostRoleCommandFactory) { + ActionDBAccessor dbAccessor, Clusters clusters, HostRoleCommandFactory hostRoleCommandFactory, + ExecutionCommandWrapperFactory ecwFactory) { this.hostRoleCommandFactory = hostRoleCommandFactory; + this.ecwFactory = ecwFactory; requestId = stageEntity.getRequestId(); stageId = stageEntity.getStageId(); @@ -307,7 +313,7 @@ public class Stage { //TODO refactor method to use Host object (host_id support) private ExecutionCommandWrapper addGenericExecutionCommand(String clusterName, String hostName, Role role, RoleCommand command, ServiceComponentHostEvent event, HostRoleCommand hrc) { ExecutionCommand cmd = new ExecutionCommand(); - ExecutionCommandWrapper wrapper = new ExecutionCommandWrapper(cmd); + ExecutionCommandWrapper wrapper = ecwFactory.createFromCommand(cmd); hrc.setExecutionCommandWrapper(wrapper); cmd.setHostname(hostName); cmd.setClusterName(clusterName); http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/StageFactoryImpl.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/StageFactoryImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/StageFactoryImpl.java index 9ee7c16..3cad82d 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/StageFactoryImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/StageFactoryImpl.java @@ -18,20 +18,14 @@ package org.apache.ambari.server.actionmanager; +import org.apache.ambari.server.orm.dao.HostRoleCommandDAO; +import org.apache.ambari.server.orm.entities.StageEntity; +import org.apache.ambari.server.state.Clusters; + import com.google.inject.Inject; import com.google.inject.Injector; import com.google.inject.Singleton; import com.google.inject.assistedinject.Assisted; -import org.apache.ambari.server.Role; -import org.apache.ambari.server.RoleCommand; -import org.apache.ambari.server.orm.DBAccessor; -import org.apache.ambari.server.orm.dao.HostRoleCommandDAO; -import org.apache.ambari.server.orm.entities.HostEntity; -import org.apache.ambari.server.orm.entities.HostRoleCommandEntity; -import org.apache.ambari.server.orm.entities.StageEntity; -import org.apache.ambari.server.state.Clusters; -import org.apache.ambari.server.state.ServiceComponentHostEvent; -import org.apache.ambari.server.state.cluster.ClusterImpl; @Singleton public class StageFactoryImpl implements StageFactory { @@ -64,7 +58,8 @@ public class StageFactoryImpl implements StageFactory { @Assisted("commandParamsStage") String commandParamsStage, @Assisted("hostParamsStage") String hostParamsStage) { return new Stage(requestId, logDir, clusterName, clusterId, requestContext, clusterHostInfo, commandParamsStage, hostParamsStage, - injector.getInstance(HostRoleCommandFactory.class)); + injector.getInstance(HostRoleCommandFactory.class), + injector.getInstance(ExecutionCommandWrapperFactory.class)); } /** @@ -76,6 +71,7 @@ public class StageFactoryImpl implements StageFactory { public Stage createExisting(@Assisted StageEntity stageEntity) { return new Stage(stageEntity, injector.getInstance(HostRoleCommandDAO.class), injector.getInstance(ActionDBAccessor.class), injector.getInstance(Clusters.class), - injector.getInstance(HostRoleCommandFactory.class)); + injector.getInstance(HostRoleCommandFactory.class), + injector.getInstance(ExecutionCommandWrapperFactory.class)); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java index 91d6b4d..3506031 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java @@ -18,23 +18,39 @@ package org.apache.ambari.server.controller; -import com.google.common.util.concurrent.AbstractScheduledService; -import com.google.common.util.concurrent.ServiceManager; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.inject.AbstractModule; -import com.google.inject.Scopes; -import com.google.inject.assistedinject.FactoryModuleBuilder; -import com.google.inject.name.Names; -import com.google.inject.persist.PersistModule; -import com.google.inject.persist.jpa.AmbariJpaPersistModule; -import com.mchange.v2.c3p0.ComboPooledDataSource; +import static org.eclipse.persistence.config.PersistenceUnitProperties.CREATE_JDBC_DDL_FILE; +import static org.eclipse.persistence.config.PersistenceUnitProperties.CREATE_ONLY; +import static org.eclipse.persistence.config.PersistenceUnitProperties.CREATE_OR_EXTEND; +import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_BOTH_GENERATION; +import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_GENERATION; +import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_GENERATION_MODE; +import static org.eclipse.persistence.config.PersistenceUnitProperties.DROP_AND_CREATE; +import static org.eclipse.persistence.config.PersistenceUnitProperties.DROP_JDBC_DDL_FILE; +import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_DRIVER; +import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_PASSWORD; +import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_URL; +import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_USER; +import static org.eclipse.persistence.config.PersistenceUnitProperties.NON_JTA_DATASOURCE; +import static org.eclipse.persistence.config.PersistenceUnitProperties.THROW_EXCEPTIONS; + +import java.beans.PropertyVetoException; +import java.lang.annotation.Annotation; +import java.security.SecureRandom; +import java.text.MessageFormat; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.Set; + import org.apache.ambari.server.AmbariService; import org.apache.ambari.server.EagerSingleton; import org.apache.ambari.server.StaticallyInject; import org.apache.ambari.server.actionmanager.ActionDBAccessor; import org.apache.ambari.server.actionmanager.ActionDBAccessorImpl; -import org.apache.ambari.server.actionmanager.ExecutionCommandWrapper; +import org.apache.ambari.server.actionmanager.ExecutionCommandWrapperFactory; import org.apache.ambari.server.actionmanager.HostRoleCommandFactory; import org.apache.ambari.server.actionmanager.HostRoleCommandFactoryImpl; import org.apache.ambari.server.actionmanager.RequestFactory; @@ -127,32 +143,17 @@ import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.util.ClassUtils; import org.springframework.web.filter.DelegatingFilterProxy; -import java.beans.PropertyVetoException; -import java.lang.annotation.Annotation; -import java.security.SecureRandom; -import java.text.MessageFormat; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.Set; - -import static org.eclipse.persistence.config.PersistenceUnitProperties.CREATE_JDBC_DDL_FILE; -import static org.eclipse.persistence.config.PersistenceUnitProperties.CREATE_ONLY; -import static org.eclipse.persistence.config.PersistenceUnitProperties.CREATE_OR_EXTEND; -import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_BOTH_GENERATION; -import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_GENERATION; -import static org.eclipse.persistence.config.PersistenceUnitProperties.DDL_GENERATION_MODE; -import static org.eclipse.persistence.config.PersistenceUnitProperties.DROP_AND_CREATE; -import static org.eclipse.persistence.config.PersistenceUnitProperties.DROP_JDBC_DDL_FILE; -import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_DRIVER; -import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_PASSWORD; -import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_URL; -import static org.eclipse.persistence.config.PersistenceUnitProperties.JDBC_USER; -import static org.eclipse.persistence.config.PersistenceUnitProperties.NON_JTA_DATASOURCE; -import static org.eclipse.persistence.config.PersistenceUnitProperties.THROW_EXCEPTIONS; +import com.google.common.util.concurrent.AbstractScheduledService; +import com.google.common.util.concurrent.ServiceManager; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.inject.AbstractModule; +import com.google.inject.Scopes; +import com.google.inject.assistedinject.FactoryModuleBuilder; +import com.google.inject.name.Names; +import com.google.inject.persist.PersistModule; +import com.google.inject.persist.jpa.AmbariJpaPersistModule; +import com.mchange.v2.c3p0.ComboPooledDataSource; /** * Used for injection purposes. @@ -368,7 +369,6 @@ public class ControllerModule extends AbstractModule { bind(AuthenticationEntryPoint.class).to(AmbariEntryPoint.class).in(Scopes.SINGLETON); - requestStaticInjection(ExecutionCommandWrapper.class); requestStaticInjection(DatabaseChecker.class); requestStaticInjection(KerberosChecker.class); @@ -456,6 +456,7 @@ public class ControllerModule extends AbstractModule { bind(RoleGraphFactory.class).to(RoleGraphFactoryImpl.class); install(new FactoryModuleBuilder().build(RequestFactory.class)); install(new FactoryModuleBuilder().build(StackManagerFactory.class)); + install(new FactoryModuleBuilder().build(ExecutionCommandWrapperFactory.class)); bind(HostRoleCommandFactory.class).to(HostRoleCommandFactoryImpl.class); bind(SecurityHelper.class).toInstance(SecurityHelperImpl.getInstance()); http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java index df033d1..b212e93 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/actionmanager/ExecutionCommandWrapperTest.java @@ -27,8 +27,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import junit.framework.Assert; - import org.apache.ambari.server.AmbariException; import org.apache.ambari.server.Role; import org.apache.ambari.server.RoleCommand; @@ -51,6 +49,8 @@ import org.junit.Test; import com.google.inject.Guice; import com.google.inject.Injector; +import junit.framework.Assert; + public class ExecutionCommandWrapperTest { private static final String HOST1 = "dev01.ambari.apache.org"; @@ -210,6 +210,8 @@ public class ExecutionCommandWrapperTest { String json = StageUtils.getGson().toJson(executionCommand, ExecutionCommand.class); ExecutionCommandWrapper execCommWrap = new ExecutionCommandWrapper(json); + injector.injectMembers(execCommWrap); + ExecutionCommand processedExecutionCommand = execCommWrap.getExecutionCommand(); Map<String, String> serviceSiteConfig = processedExecutionCommand.getConfigurations().get(SERVICE_SITE_CONFIG); http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java index 6cb9e6f..dd741e9 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/AgentResourceTest.java @@ -24,11 +24,10 @@ import static org.mockito.Mockito.when; import javax.ws.rs.core.MediaType; -import junit.framework.Assert; - import org.apache.ambari.server.RandomPortJerseyTest; import org.apache.ambari.server.actionmanager.ActionDBAccessor; import org.apache.ambari.server.actionmanager.ActionManager; +import org.apache.ambari.server.actionmanager.ExecutionCommandWrapperFactory; import org.apache.ambari.server.actionmanager.HostRoleCommandFactory; import org.apache.ambari.server.actionmanager.HostRoleCommandFactoryImpl; import org.apache.ambari.server.actionmanager.StageFactory; @@ -91,6 +90,8 @@ import com.sun.jersey.api.json.JSONConfiguration; import com.sun.jersey.spi.container.servlet.ServletContainer; import com.sun.jersey.test.framework.WebAppDescriptor; +import junit.framework.Assert; + public class AgentResourceTest extends RandomPortJerseyTest { static String PACKAGE_NAME = "org.apache.ambari.server.agent.rest"; @@ -333,6 +334,7 @@ public class AgentResourceTest extends RandomPortJerseyTest { install(new FactoryModuleBuilder().implement(RequestExecution.class, RequestExecutionImpl.class).build(RequestExecutionFactory.class)); install(new FactoryModuleBuilder().build(StageFactory.class)); + install(new FactoryModuleBuilder().build(ExecutionCommandWrapperFactory.class)); bind(HostRoleCommandFactory.class).to(HostRoleCommandFactoryImpl.class); bind(SecurityHelper.class).toInstance(SecurityHelperImpl.getInstance()); http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CalculatedStatusTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CalculatedStatusTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CalculatedStatusTest.java index 46c0b03..6f592cd 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CalculatedStatusTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CalculatedStatusTest.java @@ -17,15 +17,26 @@ */ package org.apache.ambari.server.controller.internal; +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.assertNull; -import static org.easymock.EasyMock.*; import java.lang.reflect.Field; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +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.ExecutionCommandWrapperFactory; import org.apache.ambari.server.actionmanager.HostRoleCommand; import org.apache.ambari.server.actionmanager.HostRoleCommandFactory; import org.apache.ambari.server.actionmanager.HostRoleStatus; @@ -35,7 +46,6 @@ import org.apache.ambari.server.orm.InMemoryDefaultTestModule; import org.apache.ambari.server.orm.dao.HostRoleCommandStatusSummaryDTO; import org.apache.ambari.server.orm.entities.HostRoleCommandEntity; import org.apache.ambari.server.orm.entities.StageEntity; - import org.junit.Before; import org.junit.Test; @@ -54,6 +64,9 @@ public class CalculatedStatusTest { @Inject HostRoleCommandFactory hostRoleCommandFactory; + @Inject + ExecutionCommandWrapperFactory ecwFactory; + private static long taskId = 0L; private static long stageId = 0L; @@ -691,7 +704,7 @@ public class CalculatedStatusTest { private final List<HostRoleCommand> hostRoleCommands = new LinkedList<HostRoleCommand>(); private TestStage() { - super(1L, "", "", 1L, "", "", "", "", hostRoleCommandFactory); + super(1L, "", "", 1L, "", "", "", "", hostRoleCommandFactory, ecwFactory); } void setHostRoleCommands(Collection<HostRoleCommandEntity> tasks) { http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java index 91cfef8..dd28d6b 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/TaskResourceProviderTest.java @@ -36,6 +36,7 @@ import java.util.Map; import java.util.Set; import org.apache.ambari.server.Role; +import org.apache.ambari.server.actionmanager.ExecutionCommandWrapperFactory; import org.apache.ambari.server.actionmanager.HostRoleCommand; import org.apache.ambari.server.controller.AmbariManagementController; import org.apache.ambari.server.controller.RequestStatusResponse; @@ -168,6 +169,7 @@ public class TaskResourceProviderTest { TopologyManager topologyManager = createMock(TopologyManager.class); HostDAO hostDAO = createMock(HostDAO.class); ExecutionCommandDAO executionCommandDAO = createMock(ExecutionCommandDAO.class); + ExecutionCommandWrapperFactory ecwFactory = createMock(ExecutionCommandWrapperFactory.class); Injector m_injector = Guice.createInjector(new InMemoryDefaultTestModule()); TaskResourceProvider provider = (TaskResourceProvider) AbstractControllerResourceProvider.getResourceProvider( @@ -187,7 +189,7 @@ public class TaskResourceProviderTest { hostRoleCommandEntity.setRole(Role.DATANODE); hostRoleCommandEntity.setCustomCommandName("customCommandName"); hostRoleCommandEntity.setCommandDetail("commandDetail"); - commands.add(new HostRoleCommand(hostRoleCommandEntity, hostDAO, executionCommandDAO)); + commands.add(new HostRoleCommand(hostRoleCommandEntity, hostDAO, executionCommandDAO, ecwFactory)); // set expectations expect(hostRoleCommandDAO.findAll(EasyMock.anyObject(Request.class), http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java index a9c4b17..a4a3108 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradeResourceProviderHDP22Test.java @@ -33,6 +33,7 @@ import java.util.Set; import org.apache.ambari.server.actionmanager.ActionManager; import org.apache.ambari.server.actionmanager.ExecutionCommandWrapper; +import org.apache.ambari.server.actionmanager.ExecutionCommandWrapperFactory; import org.apache.ambari.server.agent.ExecutionCommand; import org.apache.ambari.server.agent.ExecutionCommand.KeyNames; import org.apache.ambari.server.controller.AmbariManagementController; @@ -367,7 +368,8 @@ public class UpgradeResourceProviderHDP22Test { assertEquals(1, tags.size()); assertEquals("*", tags.get(0)); - ExecutionCommandWrapper executionCommandWrapper = new ExecutionCommandWrapper(executionCommandJson); + ExecutionCommandWrapperFactory ecwFactory = injector.getInstance(ExecutionCommandWrapperFactory.class); + ExecutionCommandWrapper executionCommandWrapper = ecwFactory.createFromJson(executionCommandJson); ExecutionCommand executionCommand = executionCommandWrapper.getExecutionCommand(); Map<String, Map<String, String>> configurationTags = executionCommand.getConfigurationTags(); assertEquals(configTagVersion2, configurationTags.get("hive-site").get("tag")); http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/AutoSkipFailedSummaryActionTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/AutoSkipFailedSummaryActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/AutoSkipFailedSummaryActionTest.java index 5e35b301..8dc4c1b 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/AutoSkipFailedSummaryActionTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/AutoSkipFailedSummaryActionTest.java @@ -17,37 +17,58 @@ */ package org.apache.ambari.server.serveraction.upgrades; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Inject; -import com.google.inject.Injector; -import com.google.inject.persist.PersistService; -import com.google.inject.persist.UnitOfWork; -import com.google.inject.util.Modules; -import org.apache.ambari.server.*; -import org.apache.ambari.server.actionmanager.*; +import static org.easymock.EasyMock.anyLong; +import static org.easymock.EasyMock.anyObject; +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.assertNotNull; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +import org.apache.ambari.server.Role; +import org.apache.ambari.server.RoleCommand; +import org.apache.ambari.server.actionmanager.ExecutionCommandWrapper; +import org.apache.ambari.server.actionmanager.ExecutionCommandWrapperFactory; +import org.apache.ambari.server.actionmanager.HostRoleCommand; +import org.apache.ambari.server.actionmanager.HostRoleStatus; +import org.apache.ambari.server.actionmanager.ServiceComponentHostEventWrapper; import org.apache.ambari.server.agent.CommandReport; import org.apache.ambari.server.agent.ExecutionCommand; import org.apache.ambari.server.metadata.ActionMetadata; import org.apache.ambari.server.orm.GuiceJpaInitializer; import org.apache.ambari.server.orm.InMemoryDefaultTestModule; -import org.apache.ambari.server.orm.dao.*; -import org.apache.ambari.server.orm.entities.*; +import org.apache.ambari.server.orm.dao.ExecutionCommandDAO; +import org.apache.ambari.server.orm.dao.HostDAO; +import org.apache.ambari.server.orm.dao.HostRoleCommandDAO; +import org.apache.ambari.server.orm.dao.UpgradeDAO; +import org.apache.ambari.server.orm.entities.HostEntity; +import org.apache.ambari.server.orm.entities.HostRoleCommandEntity; +import org.apache.ambari.server.orm.entities.UpgradeGroupEntity; +import org.apache.ambari.server.orm.entities.UpgradeItemEntity; import org.apache.ambari.server.serveraction.AbstractServerAction; -import org.apache.ambari.server.state.*; +import org.apache.ambari.server.state.Cluster; +import org.apache.ambari.server.state.Clusters; +import org.apache.ambari.server.state.ServiceComponentHostEvent; +import org.apache.ambari.server.state.StackId; import org.apache.ambari.server.state.svccomphost.ServiceComponentHostOpInProgressEvent; import org.junit.After; import org.junit.Before; import org.junit.Test; -import static org.easymock.EasyMock.*; - -import java.lang.reflect.Field; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import static org.junit.Assert.*; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Inject; +import com.google.inject.Injector; +import com.google.inject.persist.PersistService; +import com.google.inject.persist.UnitOfWork; +import com.google.inject.util.Modules; public class AutoSkipFailedSummaryActionTest { @@ -61,6 +82,9 @@ public class AutoSkipFailedSummaryActionTest { @Inject private HostDAO hostDAO; + @Inject + private ExecutionCommandWrapperFactory ecwFactory; + // Mocked out values private UpgradeDAO upgradeDAOMock; private HostRoleCommandDAO hostRoleCommandDAOMock; @@ -112,7 +136,7 @@ public class AutoSkipFailedSummaryActionTest { // Set mock for parent's getHostRoleCommand() HostRoleCommand hostRoleCommand = new HostRoleCommand("host1", Role.AMBARI_SERVER_ACTION, - event, RoleCommand.EXECUTE, hostDAO, executionCommandDAO); + event, RoleCommand.EXECUTE, hostDAO, executionCommandDAO, ecwFactory); hostRoleCommand.setRequestId(1l); hostRoleCommand.setStageId(1l); @@ -181,7 +205,7 @@ public class AutoSkipFailedSummaryActionTest { // Set mock for parent's getHostRoleCommand() final HostRoleCommand hostRoleCommand = new HostRoleCommand("host1", Role.AMBARI_SERVER_ACTION, - event, RoleCommand.EXECUTE, hostDAO, executionCommandDAO); + event, RoleCommand.EXECUTE, hostDAO, executionCommandDAO, ecwFactory); hostRoleCommand.setRequestId(1l); hostRoleCommand.setStageId(1l); @@ -268,7 +292,7 @@ public class AutoSkipFailedSummaryActionTest { // Set mock for parent's getHostRoleCommand() final HostRoleCommand hostRoleCommand = new HostRoleCommand("host1", Role.AMBARI_SERVER_ACTION, - event, RoleCommand.EXECUTE, hostDAO, executionCommandDAO); + event, RoleCommand.EXECUTE, hostDAO, executionCommandDAO, ecwFactory); hostRoleCommand.setRequestId(1l); hostRoleCommand.setStageId(1l); @@ -341,7 +365,7 @@ public class AutoSkipFailedSummaryActionTest { // Set mock for parent's getHostRoleCommand() final HostRoleCommand hostRoleCommand = new HostRoleCommand("host1", Role.AMBARI_SERVER_ACTION, - event, RoleCommand.EXECUTE, hostDAO, executionCommandDAO); + event, RoleCommand.EXECUTE, hostDAO, executionCommandDAO, ecwFactory); hostRoleCommand.setRequestId(1l); hostRoleCommand.setStageId(1l); http://git-wip-us.apache.org/repos/asf/ambari/blob/fdd07bd8/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java b/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java index 215d137..3f1fba3 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/utils/StageUtilsTest.java @@ -17,17 +17,38 @@ */ package org.apache.ambari.server.utils; -import com.google.common.base.Predicate; -import com.google.common.collect.ContiguousSet; -import com.google.common.collect.DiscreteDomain; -import com.google.common.collect.Maps; -import com.google.common.collect.Range; -import com.google.gson.Gson; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.Injector; +import static org.easymock.EasyMock.anyObject; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.expectLastCall; +import static org.easymock.EasyMock.getCurrentArguments; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; + +import javax.persistence.EntityManager; +import javax.xml.bind.JAXBException; + import org.apache.ambari.server.AmbariException; import org.apache.ambari.server.actionmanager.ExecutionCommandWrapper; +import org.apache.ambari.server.actionmanager.ExecutionCommandWrapperFactory; import org.apache.ambari.server.actionmanager.HostRoleCommandFactory; import org.apache.ambari.server.actionmanager.HostRoleCommandFactoryImpl; import org.apache.ambari.server.actionmanager.Stage; @@ -63,33 +84,16 @@ import org.easymock.IAnswer; import org.junit.Before; import org.junit.Test; -import javax.persistence.EntityManager; -import javax.xml.bind.JAXBException; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.SortedMap; -import java.util.TreeMap; - -import static org.easymock.EasyMock.anyObject; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.expectLastCall; -import static org.easymock.EasyMock.getCurrentArguments; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import com.google.common.base.Predicate; +import com.google.common.collect.ContiguousSet; +import com.google.common.collect.DiscreteDomain; +import com.google.common.collect.Maps; +import com.google.common.collect.Range; +import com.google.gson.Gson; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.assistedinject.FactoryModuleBuilder; public class StageUtilsTest extends EasyMockSupport { private static final String STACK_ID = "HDP-1.3.1"; @@ -120,6 +124,8 @@ public class StageUtilsTest extends EasyMockSupport { bind(HostDAO.class).toInstance(createNiceMock(HostDAO.class)); bind(PersistedState.class).toInstance(createNiceMock(PersistedState.class)); bind(HostRoleCommandDAO.class).toInstance(createNiceMock(HostRoleCommandDAO.class)); + + install(new FactoryModuleBuilder().build(ExecutionCommandWrapperFactory.class)); } }); @@ -395,7 +401,7 @@ public class StageUtilsTest extends EasyMockSupport { @Override public ServiceComponentHost answer() throws Throwable { Object[] args = getCurrentArguments(); - return nnServiceComponentHosts.get((String) args[0]); + return nnServiceComponentHosts.get(args[0]); } }).anyTimes(); expect(nnComponent.getServiceComponentHosts()).andReturn(nnServiceComponentHosts).anyTimes(); @@ -408,7 +414,7 @@ public class StageUtilsTest extends EasyMockSupport { @Override public ServiceComponentHost answer() throws Throwable { Object[] args = getCurrentArguments(); - return snnServiceComponentHosts.get((String) args[0]); + return snnServiceComponentHosts.get(args[0]); } }).anyTimes(); expect(snnComponent.getServiceComponentHosts()).andReturn(snnServiceComponentHosts).anyTimes(); @@ -421,7 +427,7 @@ public class StageUtilsTest extends EasyMockSupport { @Override public ServiceComponentHost answer() throws Throwable { Object[] args = getCurrentArguments(); - return dnServiceComponentHosts.get((String) args[0]); + return dnServiceComponentHosts.get(args[0]); } }).anyTimes(); expect(dnComponent.getServiceComponentHosts()).andReturn(dnServiceComponentHosts).anyTimes(); @@ -434,7 +440,7 @@ public class StageUtilsTest extends EasyMockSupport { @Override public ServiceComponentHost answer() throws Throwable { Object[] args = getCurrentArguments(); - return hbmServiceComponentHosts.get((String) args[0]); + return hbmServiceComponentHosts.get(args[0]); } }).anyTimes(); expect(hbmComponent.getServiceComponentHosts()).andReturn(hbmServiceComponentHosts).anyTimes(); @@ -447,7 +453,7 @@ public class StageUtilsTest extends EasyMockSupport { @Override public ServiceComponentHost answer() throws Throwable { Object[] args = getCurrentArguments(); - return hbrsServiceComponentHosts.get((String) args[0]); + return hbrsServiceComponentHosts.get(args[0]); } }).anyTimes(); Map<String, ServiceComponentHost> hbrsHosts = Maps.filterKeys(hbrsServiceComponentHosts, new Predicate<String>() { @@ -466,7 +472,7 @@ public class StageUtilsTest extends EasyMockSupport { @Override public ServiceComponentHost answer() throws Throwable { Object[] args = getCurrentArguments(); - return mrjtServiceComponentHosts.get((String) args[0]); + return mrjtServiceComponentHosts.get(args[0]); } }).anyTimes(); expect(mrjtComponent.getServiceComponentHosts()).andReturn(mrjtServiceComponentHosts).anyTimes(); @@ -479,7 +485,7 @@ public class StageUtilsTest extends EasyMockSupport { @Override public ServiceComponentHost answer() throws Throwable { Object[] args = getCurrentArguments(); - return mrttServiceComponentHosts.get((String) args[0]); + return mrttServiceComponentHosts.get(args[0]); } }).anyTimes(); expect(mrttCompomnent.getServiceComponentHosts()).andReturn(mrttServiceComponentHosts).anyTimes(); @@ -492,7 +498,7 @@ public class StageUtilsTest extends EasyMockSupport { @Override public ServiceComponentHost answer() throws Throwable { Object[] args = getCurrentArguments(); - return nnsServiceComponentHosts.get((String) args[0]); + return nnsServiceComponentHosts.get(args[0]); } }).anyTimes(); expect(nnsComponent.getServiceComponentHosts()).andReturn(nnsServiceComponentHosts).anyTimes();
