You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by be...@apache.org on 2017/10/31 10:43:03 UTC
ambari git commit: AMBARI-22325 Save/Retrieve v2 blueprints (benyoka)
Repository: ambari
Updated Branches:
refs/heads/branch-feature-AMBARI-14714 70077fe02 -> 6837c1964
AMBARI-22325 Save/Retrieve v2 blueprints (benyoka)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6837c196
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6837c196
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6837c196
Branch: refs/heads/branch-feature-AMBARI-14714
Commit: 6837c196434ee722bf666d6894fe4510858a0ea0
Parents: 70077fe
Author: Balazs Bence Sari <be...@apache.org>
Authored: Tue Oct 31 11:39:01 2017 +0100
Committer: Balazs Bence Sari <be...@apache.org>
Committed: Tue Oct 31 11:39:45 2017 +0100
----------------------------------------------------------------------
.../internal/BlueprintV2ResourceProvider.java | 7 +++++++
.../apache/ambari/server/orm/dao/BlueprintV2DAO.java | 11 ++++++++---
.../ambari/server/topology/BlueprintImplV2.java | 14 +++++++++++++-
.../ambari/server/topology/BlueprintV2Factory.java | 7 +++++++
.../src/main/resources/Ambari-DDL-Derby-CREATE.sql | 4 +---
.../src/main/resources/Ambari-DDL-MySQL-CREATE.sql | 4 +---
.../src/main/resources/Ambari-DDL-Oracle-CREATE.sql | 4 +---
.../src/main/resources/Ambari-DDL-Postgres-CREATE.sql | 4 +---
.../main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql | 4 +---
.../main/resources/Ambari-DDL-SQLServer-CREATE.sql | 4 +---
.../src/main/resources/META-INF/persistence.xml | 1 +
ambari-server/src/main/resources/properties.json | 5 +++--
.../src/test/resources/blueprintv2/blueprintv2.json | 2 +-
13 files changed, 46 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/6837c196/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintV2ResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintV2ResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintV2ResourceProvider.java
index ccc9836..6d2c4f0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintV2ResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/BlueprintV2ResourceProvider.java
@@ -139,6 +139,7 @@ public class BlueprintV2ResourceProvider extends AbstractControllerResourceProvi
AmbariManagementController controller) {
super(propertyIds, keyPropertyIds, controller);
+ blueprintFactory = BlueprintV2Factory.create(controller);
}
/**
@@ -286,6 +287,12 @@ public class BlueprintV2ResourceProvider extends AbstractControllerResourceProvi
applySelectFilters(requestedIds, blueprintAsMap, filteredMap);
blueprintAsMap = filteredMap;
}
+ // flatten the Blueprint property category
+ Map<String, Object> blueprintPc = (Map<String, Object>)blueprintAsMap.remove(BLUEPRINTS_PROPERTY_ID);
+ for (Map.Entry<String, Object> entry: blueprintPc.entrySet()) {
+ blueprintAsMap.put(BLUEPRINTS_PROPERTY_ID + "/" + entry.getKey(), entry.getValue());
+ }
+ // set resources
blueprintAsMap.entrySet().forEach( entry -> resource.setProperty(entry.getKey(), entry.getValue()) );
return resource;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6837c196/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java
index 267ae05..6a054e8 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/BlueprintV2DAO.java
@@ -25,6 +25,8 @@ import javax.persistence.TypedQuery;
import org.apache.ambari.server.orm.RequiresSession;
import org.apache.ambari.server.orm.entities.BlueprintV2Entity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -37,6 +39,8 @@ import com.google.inject.persist.Transactional;
@Singleton
public class BlueprintV2DAO {
+ protected final static Logger LOG = LoggerFactory.getLogger(BlueprintV2DAO.class);
+
/**
* JPA entity manager
*/
@@ -114,11 +118,12 @@ public class BlueprintV2DAO {
/**
* Remove entity instance by primary key
- * @param blueprint_name Primary key: blueprint name
+ * @param blueprintName Primary key: blueprint name
*/
@Transactional
- public void removeByName(String blueprint_name) {
- entityManagerProvider.get().remove(findByName(blueprint_name));
+ public void removeByName(String blueprintName) {
+ LOG.debug("Removing blueprintv2: {}", blueprintName);
+ entityManagerProvider.get().remove(findByName(blueprintName));
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6837c196/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
index f7ee730..d31e9d4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintImplV2.java
@@ -76,6 +76,15 @@ public class BlueprintImplV2 implements BlueprintV2 {
this.securityConfiguration = blueprints.securityConfiguration;
}
+ @JsonProperty("Blueprints")
+ public Blueprints getBlueprints() {
+ Blueprints blueprints = new Blueprints();
+ blueprints.name = this.name;
+ blueprints.securityConfiguration = this.securityConfiguration;
+ return blueprints;
+ }
+
+
public void setName(String name) {
this.name = name;
}
@@ -102,12 +111,13 @@ public class BlueprintImplV2 implements BlueprintV2 {
));
}
- @JsonProperty("cluster-settings")
+ @JsonProperty("cluster_settings")
public void setClusterSettings(Map<String, Set<HashMap<String, String>>> properties) {
this.setting = new Setting(properties);
}
@Override
+ @JsonIgnore
public String getName() {
return name;
}
@@ -248,6 +258,7 @@ public class BlueprintImplV2 implements BlueprintV2 {
}
@Override
+ @JsonProperty("cluster_settings")
public Setting getSetting() {
return this.setting;
}
@@ -304,6 +315,7 @@ public class BlueprintImplV2 implements BlueprintV2 {
}
@Override
+ @JsonIgnore
public SecurityConfiguration getSecurity() {
return this.securityConfiguration;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6837c196/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
index 4f6e8e6..7b228e5 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/BlueprintV2Factory.java
@@ -27,6 +27,7 @@ import java.util.stream.Collectors;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.ObjectNotFoundException;
+import org.apache.ambari.server.controller.AmbariManagementController;
import org.apache.ambari.server.controller.StackV2;
import org.apache.ambari.server.controller.StackV2Factory;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
@@ -37,6 +38,7 @@ import org.apache.ambari.server.orm.entities.StackEntity;
import org.apache.ambari.server.stack.NoSuchStackException;
import org.apache.ambari.server.state.StackId;
+import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -83,6 +85,10 @@ public class BlueprintV2Factory {
this.stackFactory = stackFactory;
}
+ public static BlueprintV2Factory create(AmbariManagementController controller) {
+ return new BlueprintV2Factory(new StackV2Factory(controller));
+ }
+
public BlueprintV2 getBlueprint(String blueprintName) throws NoSuchStackException, NoSuchBlueprintException, IOException {
BlueprintV2Entity entity =
Optional.ofNullable(blueprintDAO.findByName(blueprintName)).orElseThrow(() -> new NoSuchBlueprintException(blueprintName));
@@ -181,6 +187,7 @@ public class BlueprintV2Factory {
resolver.addMapping(HostGroupV2.class, HostGroupV2Impl.class);
module.setAbstractTypes(resolver);
mapper.registerModule(module);
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return mapper;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/6837c196/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 ba0a783..ce201e4 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@ -552,10 +552,8 @@ CREATE TABLE blueprintv2 (
blueprint_name VARCHAR(255) NOT NULL,
security_type VARCHAR(32) NOT NULL DEFAULT 'NONE',
security_descriptor_reference VARCHAR(255),
- stack_id BIGINT NOT NULL,
content VARCHAR(32000) NOT NULL,
- CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name),
- CONSTRAINT FK_blueprintv2_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
+ CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name));
CREATE TABLE hostgroup (
blueprint_name VARCHAR(255) NOT NULL,
http://git-wip-us.apache.org/repos/asf/ambari/blob/6837c196/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 90a33c4..f4d9554 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -569,7 +569,6 @@ CREATE TABLE blueprintv2 (
blueprint_name VARCHAR(255) NOT NULL,
security_type VARCHAR(32) NOT NULL DEFAULT 'NONE',
security_descriptor_reference VARCHAR(255),
- stack_id BIGINT NOT NULL,
content LONGTEXT NOT NULL,
CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name),
CONSTRAINT FK_blueprintv2_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
@@ -578,8 +577,7 @@ CREATE TABLE hostgroup (
blueprint_name VARCHAR(100) NOT NULL,
name VARCHAR(100) NOT NULL,
cardinality VARCHAR(255) NOT NULL,
- CONSTRAINT PK_hostgroup PRIMARY KEY (blueprint_name, name),
- CONSTRAINT FK_hg_blueprint_name FOREIGN KEY (blueprint_name) REFERENCES blueprint(blueprint_name));
+ CONSTRAINT PK_hostgroup PRIMARY KEY (blueprint_name, name));
CREATE TABLE hostgroup_component (
blueprint_name VARCHAR(100) NOT NULL,
http://git-wip-us.apache.org/repos/asf/ambari/blob/6837c196/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 4f59b92..6b69627 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -551,10 +551,8 @@ CREATE TABLE blueprintv2 (
blueprint_name VARCHAR2(255) NOT NULL,
security_type VARCHAR2(32) NOT NULL DEFAULT 'NONE',
security_descriptor_reference VARCHAR2(255),
- stack_id NUMBER(19) NOT NULL,
content CLOB NOT NULL,
- CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name),
- CONSTRAINT FK_blueprintv2_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
+ CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name));
CREATE TABLE hostgroup (
http://git-wip-us.apache.org/repos/asf/ambari/blob/6837c196/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 68c7e1c..1708671 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -551,10 +551,8 @@ CREATE TABLE blueprintv2 (
blueprint_name VARCHAR(255) NOT NULL,
security_type VARCHAR(32) NOT NULL DEFAULT 'NONE',
security_descriptor_reference VARCHAR(255),
- stack_id BIGINT NOT NULL,
content VARCHAR(32000) NOT NULL,
- CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name),
- CONSTRAINT FK_blueprintv2_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
+ CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name));
CREATE TABLE hostgroup (
blueprint_name VARCHAR(255) NOT NULL,
http://git-wip-us.apache.org/repos/asf/ambari/blob/6837c196/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 c869286..87d9169 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -547,10 +547,8 @@ CREATE TABLE blueprintv2 (
blueprint_name VARCHAR(255) NOT NULL,
security_type VARCHAR(32) NOT NULL DEFAULT 'NONE',
security_descriptor_reference VARCHAR(255),
- stack_id NUMERIC(19) NOT NULL,
content TEXT NOT NULL,
- CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name),
- CONSTRAINT FK_blueprintv2_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
+ CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name));
CREATE TABLE hostgroup (
http://git-wip-us.apache.org/repos/asf/ambari/blob/6837c196/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 1fbc396..223fd76 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -556,7 +556,6 @@ CREATE TABLE blueprintv2 (
blueprint_name VARCHAR(255) NOT NULL,
security_type VARCHAR(32) NOT NULL DEFAULT 'NONE',
security_descriptor_reference VARCHAR(255),
- stack_id BIGINT NOT NULL,
content VARCHAR(MAX) NOT NULL,
CONSTRAINT PK_blueprintv2 PRIMARY KEY (blueprint_name),
CONSTRAINT FK_blueprintv2_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id));
@@ -565,8 +564,7 @@ CREATE TABLE hostgroup (
blueprint_name VARCHAR(255) NOT NULL,
NAME VARCHAR(255) NOT NULL,
cardinality VARCHAR(255) NOT NULL,
- CONSTRAINT PK_hostgroup PRIMARY KEY CLUSTERED (blueprint_name, NAME),
- CONSTRAINT FK_hg_blueprint_name FOREIGN KEY (blueprint_name) REFERENCES blueprint(blueprint_name));
+ CONSTRAINT PK_hostgroup PRIMARY KEY CLUSTERED (blueprint_name, NAME));
CREATE TABLE hostgroup_component (
blueprint_name VARCHAR(255) NOT NULL,
http://git-wip-us.apache.org/repos/asf/ambari/blob/6837c196/ambari-server/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/META-INF/persistence.xml b/ambari-server/src/main/resources/META-INF/persistence.xml
index 698ab27..009ecd5 100644
--- a/ambari-server/src/main/resources/META-INF/persistence.xml
+++ b/ambari-server/src/main/resources/META-INF/persistence.xml
@@ -23,6 +23,7 @@
<class>org.apache.ambari.server.orm.entities.BlueprintConfigEntity</class>
<class>org.apache.ambari.server.orm.entities.BlueprintSettingEntity</class>
<class>org.apache.ambari.server.orm.entities.BlueprintEntity</class>
+ <class>org.apache.ambari.server.orm.entities.BlueprintV2Entity</class>
<class>org.apache.ambari.server.orm.entities.ClusterConfigEntity</class>
<class>org.apache.ambari.server.orm.entities.ClusterEntity</class>
<class>org.apache.ambari.server.orm.entities.ServiceGroupEntity</class>
http://git-wip-us.apache.org/repos/asf/ambari/blob/6837c196/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index a995049..225bd9e 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -375,9 +375,10 @@
"host_groups",
"host_groups/components",
"host_groups/cardinality",
- "configurations",
+ "service_groups",
+ "repository_versions",
"validate_topology",
- "settings"
+ "cluster_settings"
],
"Recommendation":[
"Recommendation/id",
http://git-wip-us.apache.org/repos/asf/ambari/blob/6837c196/ambari-server/src/test/resources/blueprintv2/blueprintv2.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/blueprintv2/blueprintv2.json b/ambari-server/src/test/resources/blueprintv2/blueprintv2.json
index b6b4e8d..c5e2541 100644
--- a/ambari-server/src/test/resources/blueprintv2/blueprintv2.json
+++ b/ambari-server/src/test/resources/blueprintv2/blueprintv2.json
@@ -5,7 +5,7 @@
"type": "NONE"
}
},
- "cluster-settings": {
+ "cluster_settings": {
"deployment_settings": [
{"skip_failure":"true"}
],