Repository: ambari Updated Branches: refs/heads/branch-2.6 373d131ce -> 34dce14fd
AMBARI-21897: Fix NPE in InstallHostTask (jluniya) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/34dce14f Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/34dce14f Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/34dce14f Branch: refs/heads/branch-2.6 Commit: 34dce14fdf2c946d4740d3237696a4f2021ef27a Parents: 373d131 Author: Jayush Luniya <jlun...@hortonworks.com> Authored: Wed Sep 6 14:48:02 2017 -0700 Committer: Jayush Luniya <jlun...@hortonworks.com> Committed: Wed Sep 6 14:57:00 2017 -0700 ---------------------------------------------------------------------- .../server/topology/tasks/InstallHostTask.java | 24 +++++++++++--------- .../tasks/PersistHostResourcesTask.java | 3 +++ .../tasks/RegisterWithConfigGroupTask.java | 3 +++ .../server/topology/tasks/StartHostTask.java | 23 +++++++++++-------- 4 files changed, 32 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/34dce14f/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/InstallHostTask.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/InstallHostTask.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/InstallHostTask.java index f38022a..ceb58c8 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/InstallHostTask.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/InstallHostTask.java @@ -50,19 +50,21 @@ public class InstallHostTask extends TopologyHostTask { LOG.info("HostRequest: Executing INSTALL task for host: {}", hostRequest.getHostName()); boolean skipInstallTaskCreate = clusterTopology.getProvisionAction().equals(ProvisionAction.START_ONLY); RequestStatusResponse response = clusterTopology.installHost(hostRequest.getHostName(), skipInstallTaskCreate, skipFailure); - // map logical install tasks to physical install tasks - List<ShortTaskStatus> underlyingTasks = response.getTasks(); - for (ShortTaskStatus task : underlyingTasks) { + if(response != null) { + // map logical install tasks to physical install tasks + List<ShortTaskStatus> underlyingTasks = response.getTasks(); + for (ShortTaskStatus task : underlyingTasks) { - String component = task.getRole(); - Long logicalInstallTaskId = hostRequest.getLogicalTasksForTopologyTask(this).get(component); - if(logicalInstallTaskId == null) { - LOG.info("Skipping physical install task registering, because component {} cannot be found", task.getRole()); - continue; + String component = task.getRole(); + Long logicalInstallTaskId = hostRequest.getLogicalTasksForTopologyTask(this).get(component); + if (logicalInstallTaskId == null) { + LOG.info("Skipping physical install task registering, because component {} cannot be found", task.getRole()); + continue; + } + //todo: for now only one physical task per component + long taskId = task.getTaskId(); + hostRequest.registerPhysicalTaskId(logicalInstallTaskId, taskId); } - //todo: for now only one physical task per component - long taskId = task.getTaskId(); - hostRequest.registerPhysicalTaskId(logicalInstallTaskId, taskId); } LOG.info("HostRequest: Exiting INSTALL task for host: {}", hostRequest.getHostName()); http://git-wip-us.apache.org/repos/asf/ambari/blob/34dce14f/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java index 0730fe8..2c255a8 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/PersistHostResourcesTask.java @@ -48,6 +48,7 @@ public class PersistHostResourcesTask extends TopologyHostTask { @Override public void runTask() { LOG.info("HostRequest: Executing RESOURCE_CREATION task for host: {}", hostRequest.getHostName()); + HostGroup group = hostRequest.getHostGroup(); Map<String, Collection<String>> serviceComponents = new HashMap<String, Collection<String>>(); for (String service : group.getServices()) { @@ -55,5 +56,7 @@ public class PersistHostResourcesTask extends TopologyHostTask { } clusterTopology.getAmbariContext().createAmbariHostResources(hostRequest.getClusterId(), hostRequest.getHostName(), serviceComponents); + + LOG.info("HostRequest: Exiting RESOURCE_CREATION task for host: {}", hostRequest.getHostName()); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/34dce14f/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/RegisterWithConfigGroupTask.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/RegisterWithConfigGroupTask.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/RegisterWithConfigGroupTask.java index 029f2a4..1613c19 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/RegisterWithConfigGroupTask.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/RegisterWithConfigGroupTask.java @@ -43,8 +43,11 @@ public class RegisterWithConfigGroupTask extends TopologyHostTask { @Override public void runTask() { LOG.info("HostRequest: Executing CONFIGURE task for host: {}", hostRequest.getHostName()); + clusterTopology.getAmbariContext().registerHostWithConfigGroup(hostRequest.getHostName(), clusterTopology, hostRequest.getHostgroupName()); + + LOG.info("HostRequest: Exiting CONFIGURE task for host: {}", hostRequest.getHostName()); } } http://git-wip-us.apache.org/repos/asf/ambari/blob/34dce14f/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/StartHostTask.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/StartHostTask.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/StartHostTask.java index 054ed1e..ab2ffbf 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/StartHostTask.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/tasks/StartHostTask.java @@ -47,19 +47,22 @@ public class StartHostTask extends TopologyHostTask { @Override public void runTask() { LOG.info("HostRequest: Executing START task for host: {}", hostRequest.getHostName()); + RequestStatusResponse response = clusterTopology.startHost(hostRequest.getHostName(), skipFailure); - // map logical install tasks to physical install tasks - List<ShortTaskStatus> underlyingTasks = response.getTasks(); - for (ShortTaskStatus task : underlyingTasks) { + if (response != null) { + // map logical install tasks to physical install tasks + List<ShortTaskStatus> underlyingTasks = response.getTasks(); + for (ShortTaskStatus task : underlyingTasks) { - String component = task.getRole(); - Long logicalStartTaskId = hostRequest.getLogicalTasksForTopologyTask(this).get(component); - if(logicalStartTaskId == null) { - LOG.info("Skipping physical start task registering, because component {} cannot be found", task.getRole()); - continue; + String component = task.getRole(); + Long logicalStartTaskId = hostRequest.getLogicalTasksForTopologyTask(this).get(component); + if (logicalStartTaskId == null) { + LOG.info("Skipping physical start task registering, because component {} cannot be found", task.getRole()); + continue; + } + // for now just set on outer map + hostRequest.registerPhysicalTaskId(logicalStartTaskId, task.getTaskId()); } - // for now just set on outer map - hostRequest.registerPhysicalTaskId(logicalStartTaskId, task.getTaskId()); } LOG.info("HostRequest: Exiting START task for host: {}", hostRequest.getHostName());