You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sm...@apache.org on 2016/01/11 15:34:52 UTC
ambari git commit: AMBARI-14600. Support for rack information from
cluster creation template (Laszlo Puskas via smohanty)
Repository: ambari
Updated Branches:
refs/heads/trunk 39e7bc0a2 -> d071934a5
AMBARI-14600. Support for rack information from cluster creation template (Laszlo Puskas via smohanty)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d071934a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d071934a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d071934a
Branch: refs/heads/trunk
Commit: d071934a50447357d5d56414acceaf910a425d7c
Parents: 39e7bc0
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Mon Jan 11 06:33:50 2016 -0800
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Mon Jan 11 06:33:50 2016 -0800
----------------------------------------------------------------------
.../internal/ProvisionClusterRequest.java | 12 +++++++
.../orm/entities/TopologyHostInfoEntity.java | 11 ++++++
.../ambari/server/topology/HostGroupInfo.java | 38 ++++++++++++++++++--
.../server/topology/PersistedStateImpl.java | 2 ++
.../ambari/server/topology/TopologyManager.java | 22 ++++++++++++
.../server/upgrade/UpgradeCatalog221.java | 6 ++++
.../main/resources/Ambari-DDL-Derby-CREATE.sql | 1 +
.../main/resources/Ambari-DDL-MySQL-CREATE.sql | 1 +
.../main/resources/Ambari-DDL-Oracle-CREATE.sql | 1 +
.../resources/Ambari-DDL-Postgres-CREATE.sql | 1 +
.../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql | 1 +
.../resources/Ambari-DDL-SQLAnywhere-CREATE.sql | 1 +
.../resources/Ambari-DDL-SQLServer-CREATE.sql | 1 +
13 files changed, 95 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/d071934a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
index 6a11b26..a1740fb 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ProvisionClusterRequest.java
@@ -73,6 +73,12 @@ public class ProvisionClusterRequest extends BaseClusterRequest {
*/
public static final String HOSTGROUP_HOST_FQDN_PROPERTY = "fqdn";
+
+ /**
+ * rack info property name
+ */
+ public static final String HOSTGROUP_HOST_RACK_INFO_PROPERTY = "rack_info";
+
/**
* host group hosts property name
*/
@@ -364,6 +370,12 @@ public class ProvisionClusterRequest extends BaseClusterRequest {
if (hostProperties.containsKey(HOSTGROUP_HOST_FQDN_PROPERTY)) {
hostGroupInfo.addHost(hostProperties.get(HOSTGROUP_HOST_FQDN_PROPERTY));
}
+
+ if (hostProperties.containsKey(HOSTGROUP_HOST_RACK_INFO_PROPERTY)) {
+ hostGroupInfo.addHostRackInfo(
+ hostProperties.get(HOSTGROUP_HOST_FQDN_PROPERTY),
+ hostProperties.get(HOSTGROUP_HOST_RACK_INFO_PROPERTY));
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/d071934a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyHostInfoEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyHostInfoEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyHostInfoEntity.java
index 8ae8aa6..a4f251a 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyHostInfoEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/TopologyHostInfoEntity.java
@@ -51,6 +51,9 @@ public class TopologyHostInfoEntity {
@JoinColumn(name = "group_id", referencedColumnName = "id", nullable = false)
private TopologyHostGroupEntity topologyHostGroupEntity;
+ @Column(name = "rack_info", length = 255)
+ private String rackInfo;
+
public Long getId() {
return id;
}
@@ -95,6 +98,14 @@ public class TopologyHostInfoEntity {
this.topologyHostGroupEntity = topologyHostGroupEntity;
}
+ public String getRackInfo() {
+ return rackInfo;
+ }
+
+ public void setRackInfo(String rackInfo) {
+ this.rackInfo = rackInfo;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
http://git-wip-us.apache.org/repos/asf/ambari/blob/d071934a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
index 8ff3971..98ad3a9 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/HostGroupInfo.java
@@ -18,13 +18,15 @@
package org.apache.ambari.server.topology;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
import org.apache.ambari.server.api.predicate.InvalidQueryException;
import org.apache.ambari.server.api.predicate.PredicateCompiler;
import org.apache.ambari.server.controller.spi.Predicate;
-import java.util.Collection;
-import java.util.HashSet;
-
/**
* Host Group information specific to a cluster instance.
*/
@@ -44,6 +46,12 @@ public class HostGroupInfo {
private final Collection<String> hostNames = new HashSet<String>();
/**
+ * maps host names to rack information
+ * todo maintain a single structure for hostnames and rack information
+ */
+ private final Map<String, String> hostRackInfo = new HashMap<>();
+
+ /**
* explicitly specified host count
*/
private int requested_count = 0;
@@ -191,4 +199,28 @@ public class HostGroupInfo {
public String getPredicateString() {
return predicateString;
}
+
+ /**
+ * Registers host rack information.
+ *
+ * @param host the name of the host
+ * @param rackInfo the rack information
+ */
+ public void addHostRackInfo(String host, String rackInfo) {
+ synchronized (hostRackInfo) {
+ hostRackInfo.put(host, rackInfo);
+ }
+ }
+
+ /**
+ * Returns a map with host names mapped to rack information.
+ *
+ * @return a copy of the current instance' rack information map
+ */
+ public Map<String, String> getHostRackInfo() {
+ synchronized (hostRackInfo) {
+ return new HashMap<>(hostRackInfo);
+ }
+ }
+
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/d071934a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
index dcff49c..b878955 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/PersistedStateImpl.java
@@ -282,6 +282,7 @@ public class PersistedStateImpl implements PersistedState {
hostInfoEntity.setPredicate(groupInfo.getPredicateString());
}
hostInfoEntity.setFqdn(hostName);
+ hostInfoEntity.setRackInfo(groupInfo.getHostRackInfo().get(hostName));
hostInfoEntity.setHostCount(0);
hostInfoEntities.add(hostInfoEntity);
}
@@ -383,6 +384,7 @@ public class PersistedStateImpl implements PersistedState {
String hostname = hostInfoEntity.getFqdn();
if (hostname != null && ! hostname.isEmpty()) {
groupInfo.addHost(hostname);
+ groupInfo.addHostRackInfo(hostname, hostInfoEntity.getRackInfo());
} else {
// should not be more than one group info if host count is specified
groupInfo.setRequestedCount(hostInfoEntity.getHostCount());
http://git-wip-us.apache.org/repos/asf/ambari/blob/d071934a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
index 5b2cf8b..7926628 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/TopologyManager.java
@@ -580,6 +580,10 @@ public class TopologyManager {
final String hostName = host.getHostName();
try {
topology.addHostToTopology(response.getHostGroupName(), hostName);
+
+ // update the host with the rack info if applicable
+ updateHostWithRackInfo(topology, response, host);
+
} catch (InvalidTopologyException e) {
// host already registered
throw new RuntimeException("An internal error occurred while performing request host registration: " + e, e);
@@ -615,6 +619,24 @@ public class TopologyManager {
}
}
+ private void updateHostWithRackInfo(ClusterTopology topology, HostOfferResponse response, HostImpl host) {
+ // the rack info from the cluster creation template
+ String rackInfoFromTemplate = topology.getHostGroupInfo().get(response.getHostGroupName()).getHostRackInfo().get
+ (host.getHostName());
+
+ if (null != rackInfoFromTemplate) {
+ host.setRackInfo(rackInfoFromTemplate);
+ host.persist();
+ try {
+ // todo: do we need this in case of blueprints?
+ ambariContext.getController().registerRackChange(ambariContext.getClusterName(topology.getClusterId()));
+ } catch (AmbariException e) {
+ LOG.error("Could not register rack change for cluster id {}", topology.getClusterId());
+ LOG.error("Exception during rack change: ", e);
+ }
+ }
+ }
+
private void replayRequests(Map<ClusterTopology, List<LogicalRequest>> persistedRequests) {
LOG.info("TopologyManager.replayRequests: Entering");
boolean configChecked = false;
http://git-wip-us.apache.org/repos/asf/ambari/blob/d071934a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog221.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog221.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog221.java
index 9c947a1..b41bee4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog221.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog221.java
@@ -63,6 +63,8 @@ public class UpgradeCatalog221 extends AbstractUpgradeCatalog {
private static final String ZK_TICK_TIME = "hbase.zookeeper.property.tickTime";
private static final String CLUSTER_ENV = "cluster-env";
private static final String SECURITY_ENABLED = "security_enabled";
+ private static final String TOPOLOGY_HOST_INFO_TABLE = "topology_host_info";
+ private static final String TOPOLOGY_HOST_INFO_RACK_INFO_COLUMN = "rack_info";
@Inject
DaoUtils daoUtils;
@@ -124,6 +126,10 @@ public class UpgradeCatalog221 extends AbstractUpgradeCatalog {
dbAccessor.createIndex("idx_rsc_request_id", "role_success_criteria", "request_id");
executeBlueprintProvisionActionDDLUpdates();
+
+ dbAccessor.addColumn(TOPOLOGY_HOST_INFO_TABLE,
+ new DBAccessor.DBColumnInfo(TOPOLOGY_HOST_INFO_RACK_INFO_COLUMN, String.class, 255));
+
}
private void executeBlueprintProvisionActionDDLUpdates() throws AmbariException, SQLException {
http://git-wip-us.apache.org/repos/asf/ambari/blob/d071934a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
index 6eda26d..72413ce 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@ -620,6 +620,7 @@ CREATE TABLE topology_host_info (
fqdn VARCHAR(255),
host_count INTEGER,
predicate VARCHAR(2048),
+ rack_info VARCHAR(255),
PRIMARY KEY (id)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/d071934a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index 05f7c4c..280b898 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -627,6 +627,7 @@ CREATE TABLE topology_host_info (
fqdn VARCHAR(255),
host_count INTEGER,
predicate VARCHAR(2048),
+ rack_info VARCHAR(255),
PRIMARY KEY (id)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/d071934a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index 59fd773..b2ba909 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -616,6 +616,7 @@ CREATE TABLE topology_host_info (
fqdn VARCHAR(255),
host_count INTEGER,
predicate VARCHAR(2048),
+ rack_info VARCHAR(255),
PRIMARY KEY (id)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/d071934a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index 24bf962..cec88d3 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -620,6 +620,7 @@ CREATE TABLE topology_host_info (
fqdn VARCHAR(255),
host_count INTEGER,
predicate VARCHAR(2048),
+ rack_info VARCHAR(255),
PRIMARY KEY (id)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/d071934a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
index 705a241..99248bc 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
@@ -696,6 +696,7 @@ CREATE TABLE ambari.topology_host_info (
fqdn VARCHAR(255),
host_count INTEGER,
predicate VARCHAR(2048),
+ rack_info VARCHAR(255),
PRIMARY KEY (id)
);
GRANT ALL PRIVILEGES ON TABLE ambari.topology_host_info TO :username;
http://git-wip-us.apache.org/repos/asf/ambari/blob/d071934a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index 3bb7faf..7831836 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -617,6 +617,7 @@ CREATE TABLE topology_host_info (
fqdn VARCHAR(255),
host_count INTEGER,
predicate VARCHAR(2048),
+ rack_info VARCHAR(255),
PRIMARY KEY (id)
);
http://git-wip-us.apache.org/repos/asf/ambari/blob/d071934a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index 89acb96..7f9ea12 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -725,6 +725,7 @@ CREATE TABLE topology_host_info (
fqdn VARCHAR(255),
host_count INTEGER,
predicate VARCHAR(2048),
+ rack_info VARCHAR(255),
PRIMARY KEY CLUSTERED (id)
);