You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2018/04/04 13:57:45 UTC
[ambari] branch branch-feature-AMBARI-14714 updated: [AMBARI-23441]
API Addition for Upgrade Plan for Config Changes
This is an automated email from the ASF dual-hosted git repository.
ncole pushed a commit to branch branch-feature-AMBARI-14714
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-feature-AMBARI-14714 by this push:
new 7755bff [AMBARI-23441] API Addition for Upgrade Plan for Config Changes
7755bff is described below
commit 7755bff45cbc1c00852569720e8bd10064a4f0d3
Author: Nate Cole <nc...@hortonworks.com>
AuthorDate: Tue Apr 3 15:04:58 2018 -0400
[AMBARI-23441] API Addition for Upgrade Plan for Config Changes
---
.../ambari/server/agent/HeartBeatHandler.java | 2 +-
.../internal/UpgradePlanResourceProvider.java | 99 ++++++++++++++--
.../orm/entities/UpgradePlanConfigEntity.java | 131 +++++++++++++++++++++
.../orm/entities/UpgradePlanDetailEntity.java | 29 ++++-
.../src/main/resources/Ambari-DDL-Derby-CREATE.sql | 13 ++
.../src/main/resources/Ambari-DDL-MySQL-CREATE.sql | 11 ++
.../main/resources/Ambari-DDL-Oracle-CREATE.sql | 21 +++-
.../main/resources/Ambari-DDL-Postgres-CREATE.sql | 13 ++
.../resources/Ambari-DDL-SQLAnywhere-CREATE.sql | 12 ++
.../main/resources/Ambari-DDL-SQLServer-CREATE.sql | 12 ++
.../src/main/resources/META-INF/persistence.xml | 1 +
.../internal/UpgradePlanResourceProviderTest.java | 25 +++-
12 files changed, 348 insertions(+), 21 deletions(-)
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
index f6dea9b..94cea4b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/HeartBeatHandler.java
@@ -246,7 +246,7 @@ public class HeartBeatHandler {
response.setRecoveryConfig(rc);
if (response.getRecoveryConfig() != null) {
- LOG.info("Recovery configuration set to {}", response.getRecoveryConfig());
+ LOG.debug("Recovery configuration set to {}", response.getRecoveryConfig());
}
}
}
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradePlanResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradePlanResourceProvider.java
index 13117cb..eaad55f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradePlanResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradePlanResourceProvider.java
@@ -26,6 +26,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.StaticallyInject;
@@ -40,7 +41,12 @@ import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
import org.apache.ambari.server.controller.spi.SystemException;
import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.orm.dao.MpackDAO;
+import org.apache.ambari.server.orm.dao.ServiceGroupDAO;
import org.apache.ambari.server.orm.dao.UpgradePlanDAO;
+import org.apache.ambari.server.orm.entities.MpackEntity;
+import org.apache.ambari.server.orm.entities.ServiceGroupEntity;
+import org.apache.ambari.server.orm.entities.UpgradePlanConfigEntity;
import org.apache.ambari.server.orm.entities.UpgradePlanDetailEntity;
import org.apache.ambari.server.orm.entities.UpgradePlanEntity;
import org.apache.ambari.server.security.authorization.RoleAuthorization;
@@ -50,6 +56,7 @@ import org.apache.ambari.server.state.stack.upgrade.UpgradeType;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
+import org.codehaus.jackson.annotate.JsonProperty;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
@@ -107,6 +114,12 @@ public class UpgradePlanResourceProvider extends AbstractControllerResourceProvi
@Inject
private static UpgradePlanDAO s_upgradePlanDAO;
+ @Inject
+ private static ServiceGroupDAO s_serviceGroupDAO;
+
+ @Inject
+ private static MpackDAO s_mpackDAO;
+
/**
* Constructor.
*
@@ -145,10 +158,12 @@ public class UpgradePlanResourceProvider extends AbstractControllerResourceProvi
s_upgradePlanDAO.create(entity);
+ // cannot be null since toEntity() checks for it
+ String clusterName = propertyMap.get(UPGRADE_PLAN_CLUSTER_NAME).toString();
+
notifyCreate(Resource.Type.UpgradePlan, request);
- Resource res = new ResourceImpl(Resource.Type.UpgradePlan);
- res.setProperty(UPGRADE_PLAN_ID, entity.getId());
+ Resource res = toResource(entity, PROPERTY_IDS, clusterName);
return new RequestStatusImpl(null, Collections.singleton(res));
}
@@ -279,19 +294,37 @@ public class UpgradePlanResourceProvider extends AbstractControllerResourceProvi
entity.setSkipServiceChecks(skip);
}
+ Long clusterId = cluster.getClusterId();
List<UpgradePlanDetailEntity> details = new ArrayList<>();
- serviceGroupJsons.forEach(serviceGroupJson -> {
- if (null == serviceGroupJson.mpackTargetId || null == serviceGroupJson.serviceGroupId) {
- return;
- }
+ serviceGroupJsons.stream()
+ .filter(sgJson -> sgJson.mpackTargetId != null && sgJson.serviceGroupId != null)
+ .forEach(sgJson -> {
+
+ ServiceGroupEntity sgEntity = s_serviceGroupDAO.findByClusterAndServiceGroupIds(
+ clusterId, sgJson.serviceGroupId);
+ if (null == sgEntity) {
+ throw new IllegalArgumentException(
+ String.format("Cannot find service group identified by %s", sgJson.serviceGroupId));
+ }
+
+ MpackEntity mpackEntity = s_mpackDAO.findById(sgJson.mpackTargetId);
+ if (null == mpackEntity) {
+ throw new IllegalArgumentException(
+ String.format("Cannot find mpack identified by %s", sgJson.mpackTargetId));
+ }
+
+ UpgradePlanDetailEntity detail = new UpgradePlanDetailEntity();
+ detail.setServiceGroupId(sgJson.serviceGroupId);
+ detail.setMpackTargetId(sgJson.mpackTargetId);
- UpgradePlanDetailEntity detail = new UpgradePlanDetailEntity();
- detail.setMpackTargetId(serviceGroupJson.mpackTargetId);
- detail.setServiceGroupId(serviceGroupJson.serviceGroupId);
+ // !!! TODO During create, we have to resolve the config changes and persist them
+ // to allow the user to override them. Ignore passed-in values, this has to come
+ // from the mpack
+
+ details.add(detail);
+ });
- details.add(detail);
- });
entity.setDetails(details);
@@ -320,22 +353,64 @@ public class UpgradePlanResourceProvider extends AbstractControllerResourceProvi
setResourceProperty(resource, UPGRADE_PLAN_SKIP_PREREQUISITE_CHECKS, upgradePlan.isSkipPrerequisiteChecks(), requestedIds);
setResourceProperty(resource, UPGRADE_PLAN_SKIP_SERVICE_CHECK_FAILURES, upgradePlan.isSkipServiceCheckFailures(), requestedIds);
setResourceProperty(resource, UPGRADE_PLAN_SKIP_SERVICE_CHECKS, upgradePlan.isSkipServiceChecks(), requestedIds);
- setResourceProperty(resource, UPGRADE_PLAN_SERVICE_GROUPS, upgradePlan.getDetails(), requestedIds);
+ setResourceProperty(resource, UPGRADE_PLAN_SERVICE_GROUPS, toResourceObject(upgradePlan.getDetails()), requestedIds);
return resource;
}
+ private List<ServiceGroupJson> toResourceObject(List<UpgradePlanDetailEntity> details) {
+ return details.stream().map(ServiceGroupJson::new).collect(Collectors.toList());
+ }
/**
* An object representing the service groups in a request.
*/
private static class ServiceGroupJson {
+
@SerializedName("service_group_id")
+ @JsonProperty("service_group_id")
private Long serviceGroupId;
@SerializedName("mpack_target_id")
+ @JsonProperty("mpack_target_id")
private Long mpackTargetId;
+ @SerializedName("configuration_changes")
+ @JsonProperty("configuration_changes")
+ private List<ConfigurationChangeJson> config_changes;
+
+ private ServiceGroupJson(UpgradePlanDetailEntity detail) {
+ serviceGroupId = detail.getServiceGroupId();
+ mpackTargetId = detail.getMpackTargetId();
+
+ config_changes = detail.getConfigChanges().stream()
+ .map(ConfigurationChangeJson::new).collect(Collectors.toList());
+ }
+ }
+
+ /**
+ * An object representing a service group's configuration changes
+ */
+ private static class ConfigurationChangeJson {
+ @SerializedName("config_type")
+ @JsonProperty("config_type")
+ private String type;
+
+ @SerializedName("config_key")
+ @JsonProperty("config_key")
+ private String key;
+
+ @SerializedName("config_value")
+ @JsonProperty("config_value")
+ private String value;
+
+ private ConfigurationChangeJson(UpgradePlanConfigEntity change) {
+ type = change.getType();
+ key = change.getKey();
+ value = change.getNewValue();
+ }
+
}
+
}
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradePlanConfigEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradePlanConfigEntity.java
new file mode 100644
index 0000000..89bdfb8
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradePlanConfigEntity.java
@@ -0,0 +1,131 @@
+/*
+ * 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.orm.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+
+/**
+ * Holds config changes for an entity.
+ */
+@Table(name = "upgrade_plan_config")
+@Entity
+@TableGenerator(name = "upgrade_plan_config_id_generator",
+ table = "ambari_sequences", pkColumnName = "sequence_name", valueColumnName = "sequence_value",
+ pkColumnValue = "upgrade_plan_config_id_seq",
+ initialValue = 0)
+public class UpgradePlanConfigEntity {
+
+ @Id
+ @Column(name = "id", nullable = false, insertable = true, updatable = false)
+ @GeneratedValue(strategy = GenerationType.TABLE, generator = "upgrade_plan_config_id_generator")
+ private Long id;
+
+ @Column(name = "config_type", nullable = false, insertable = true, updatable = false)
+ private String type;
+
+ @Column(name = "key", nullable = false, insertable = true, updatable = false)
+ private String key;
+
+ @Column(name="new_value", insertable = true, updatable = false)
+ private String newValue;
+
+ @Column(name="remove")
+ private short remove = (short) 0;
+
+ @ManyToOne
+ @JoinColumn(name = "upgrade_plan_detail_id", referencedColumnName = "id", nullable = false)
+ private UpgradePlanDetailEntity upgradePlanDetailEntity;
+
+
+ /**
+ * @param detail
+ * the plan detail
+ */
+ void setPlanDetail(UpgradePlanDetailEntity detail) {
+ upgradePlanDetailEntity = detail;
+ }
+
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @param configType
+ * the type
+ */
+ public void setType(String configType) {
+ type = configType;
+ }
+
+ /**
+ * @return the key
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * @param configKey
+ * the key
+ */
+ public void setKey(String configKey) {
+ key = configKey;
+ }
+
+ /**
+ * @return the new value
+ */
+ public String getNewValue() {
+ return newValue;
+ }
+
+ /**
+ * @param value
+ * the new value
+ */
+ public void setNewValue(String value) {
+ newValue = value;
+ }
+
+ /**
+ * @return if the {{@link #getKey()} is to be removed
+ */
+ public boolean isRemove() {
+ return remove != 0;
+ }
+
+ /**
+ * @param toRemove
+ * {@code true} to remove property of the specified key
+ */
+ public void setRemove(boolean toRemove) {
+ remove = toRemove ? (short) 1 : (short) 0;
+ }
+
+}
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradePlanDetailEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradePlanDetailEntity.java
index 7b7c501..d25e471 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradePlanDetailEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/UpgradePlanDetailEntity.java
@@ -17,6 +17,10 @@
*/
package org.apache.ambari.server.orm.entities;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -24,10 +28,11 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
-import com.google.common.base.Objects;
+import com.google.common.base.MoreObjects;
/**
* Models a single upgrade plan that can be used to invoke an Upgrade.
@@ -58,6 +63,9 @@ public class UpgradePlanDetailEntity {
@JoinColumn(name = "upgrade_plan_id", referencedColumnName = "id", nullable = false)
private UpgradePlanEntity upgradePlanEntity;
+ @OneToMany(mappedBy = "upgradePlanDetailEntity", cascade = { CascadeType.ALL })
+ private List<UpgradePlanConfigEntity> upgradePlanConfigs = new ArrayList<>();
+
/**
* @return the id
*/
@@ -107,10 +115,27 @@ public class UpgradePlanDetailEntity {
upgradePlanEntity = plan;
}
+ /**
+ * @param changes
+ * the changes for this detail
+ */
+ public void setConfigChanges(List<UpgradePlanConfigEntity> changes) {
+ changes.forEach(change -> change.setPlanDetail(this));
+
+ upgradePlanConfigs = changes;
+ }
+
+ /**
+ * @return the config changes
+ */
+ public List<UpgradePlanConfigEntity> getConfigChanges() {
+ return upgradePlanConfigs;
+ }
+
@Override
public String toString() {
- return Objects.toStringHelper(this).omitNullValues()
+ return MoreObjects.toStringHelper(this).omitNullValues()
.add("id", id)
.toString();
}
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 8047efc..0429d32 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@ -1066,6 +1066,17 @@ CREATE TABLE upgrade_plan_detail (
CONSTRAINT FK_upgrade_det_upgrade_plan FOREIGN KEY (upgrade_plan_id) REFERENCES upgrade_plan (id)
);
+CREATE TABLE upgrade_plan_config (
+ id BIGINT NOT NULL,
+ upgrade_plan_detail_id BIGINT NOT NULL,
+ config_type VARCHAR(255) NOT NULL,
+ key VARCHAR(255) NOT NULL,
+ new_value VARCHAR(3000),
+ remove SMALLINT DEFAULT 0 NOT NULL,
+ CONSTRAINT PK_upgrade_plan_config PRIMARY KEY (id),
+ CONSTRAINT FK_up_conf_up_detail FOREIGN KEY (upgrade_plan_detail_id) REFERENCES upgrade_plan_detail (id)
+);
+
CREATE TABLE ambari_operation_history(
id BIGINT NOT NULL,
from_version VARCHAR(255) NOT NULL,
@@ -1343,6 +1354,8 @@ INSERT INTO ambari_sequences (sequence_name, sequence_value)
union all
select 'upgrade_plan_id_seq', 0 FROM SYSIBM.SYSDUMMY1
union all
+ select 'upgrade_plan_config_id_seq', 0 FROM SYSIBM.SYSDUMMY1
+ union all
select 'upgrade_plan_detail_id_seq', 0 FROM SYSIBM.SYSDUMMY1
union all
select 'widget_id_seq', 0 FROM SYSIBM.SYSDUMMY1
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 bf635cb..24d0a73 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -1083,6 +1083,16 @@ CREATE TABLE upgrade_plan_detail (
CONSTRAINT FK_upgrade_det_upgrade_plan FOREIGN KEY (upgrade_plan_id) REFERENCES upgrade_plan (id)
);
+CREATE TABLE upgrade_plan_config (
+ id BIGINT NOT NULL,
+ upgrade_plan_detail_id BIGINT NOT NULL,
+ config_type VARCHAR(255) NOT NULL,
+ key VARCHAR(255) NOT NULL,
+ new_value LONGTEXT,
+ remove SMALLINT DEFAULT 0 NOT NULL,
+ CONSTRAINT PK_upgrade_plan_config PRIMARY KEY (id),
+ CONSTRAINT FK_up_conf_up_detail FOREIGN KEY (upgrade_plan_detail_id) REFERENCES upgrade_plan_detail (id)
+);
CREATE TABLE ambari_operation_history(
id BIGINT NOT NULL,
@@ -1317,6 +1327,7 @@ INSERT INTO ambari_sequences(sequence_name, sequence_value) VALUES
('upgrade_group_id_seq', 0),
('upgrade_item_id_seq', 0),
('upgrade_plan_id_seq', 0),
+ ('upgrade_plan_config_id_seq', 0),
('upgrade_plan_detail_id_seq', 0),
('stack_id_seq', 0),
('mpack_id_seq', 0),
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 9f747a1..e2acdfc 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -1044,11 +1044,11 @@ CREATE TABLE upgrade_plan (
cluster_id NUMBER(19) NOT NULL,
upgrade_type VARCHAR2(255) DEFAULT 'ROLLING' NOT NULL,
direction VARCHAR2(255) DEFAULT 'UPGRADE' NOT NULL,
- skip_failures SMALLINT DEFAULT 0 NOT NULL,
- skip_sc_failures SMALLINT DEFAULT 0 NOT NULL,
- skip_prechecks SMALLINT DEFAULT 0 NOT NULL,
- fail_on_precheck_warnings SMALLINT DEFAULT 0 NOT NULL,
- skip_service_checks SMALLINT DEFAULT 0 NOT NULL,
+ skip_failures NUMBER(1) DEFAULT 0 NOT NULL,
+ skip_sc_failures NUMBER(1) DEFAULT 0 NOT NULL,
+ skip_prechecks NUMBER(1) DEFAULT 0 NOT NULL,
+ fail_on_precheck_warnings NUMBER(1) DEFAULT 0 NOT NULL,
+ skip_service_checks NUMBER(1) DEFAULT 0 NOT NULL,
CONSTRAINT PK_upgrade_plan PRIMARY KEY (id)
);
@@ -1061,6 +1061,16 @@ CREATE TABLE upgrade_plan_detail (
CONSTRAINT FK_upgrade_det_upgrade_plan FOREIGN KEY (upgrade_plan_id) REFERENCES upgrade_plan (id)
);
+CREATE TABLE upgrade_plan_config (
+ id NUMBER(19) NOT NULL,
+ upgrade_plan_detail_id NUMBER(19) NOT NULL,
+ config_type VARCHAR2(255) NOT NULL,
+ key VARCHAR2(255) NOT NULL,
+ new_value CLOB,
+ remove NUMBER(1) DEFAULT 0 NOT NULL,
+ CONSTRAINT PK_upgrade_plan_config PRIMARY KEY (id),
+ CONSTRAINT FK_up_conf_up_detail FOREIGN KEY (upgrade_plan_detail_id) REFERENCES upgrade_plan_detail (id)
+);
CREATE TABLE ambari_operation_history(
id NUMBER(19) NOT NULL,
@@ -1295,6 +1305,7 @@ INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_id_
INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_group_id_seq', 0);
INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_item_id_seq', 0);
INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_plan_id_seq', 0);
+INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_plan_config_id_seq', 0);
INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_plan_detail_id_seq', 0);
INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('stack_id_seq', 0);
INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('mpack_id_seq', 0);
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 4317fad..d1b0bf0 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -1066,6 +1066,18 @@ CREATE TABLE upgrade_plan_detail (
CONSTRAINT FK_upgrade_det_upgrade_plan FOREIGN KEY (upgrade_plan_id) REFERENCES upgrade_plan (id)
);
+CREATE TABLE upgrade_plan_config (
+ id BIGINT NOT NULL,
+ upgrade_plan_detail_id BIGINT NOT NULL,
+ config_type VARCHAR(255) NOT NULL,
+ key VARCHAR(255) NOT NULL,
+ new_value TEXT,
+ remove SMALLINT DEFAULT 0 NOT NULL,
+ CONSTRAINT PK_upgrade_plan_config PRIMARY KEY (id),
+ CONSTRAINT FK_up_conf_up_detail FOREIGN KEY (upgrade_plan_detail_id) REFERENCES upgrade_plan_detail (id)
+);
+
+
CREATE TABLE ambari_operation_history(
id BIGINT NOT NULL,
from_version VARCHAR(255) NOT NULL,
@@ -1296,6 +1308,7 @@ INSERT INTO ambari_sequences (sequence_name, sequence_value) VALUES
('upgrade_group_id_seq', 0),
('upgrade_item_id_seq', 0),
('upgrade_plan_id_seq', 0),
+ ('upgrade_plan_config_id_seq', 0),
('upgrade_plan_detail_id_seq', 0),
('widget_id_seq', 0),
('widget_layout_id_seq', 0),
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 9b7747d..5c0d7ea 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -1062,6 +1062,17 @@ CREATE TABLE upgrade_plan_detail (
CONSTRAINT FK_upgrade_det_upgrade_plan FOREIGN KEY (upgrade_plan_id) REFERENCES upgrade_plan (id)
);
+CREATE TABLE upgrade_plan_config (
+ id NUMERIC(19) NOT NULL,
+ upgrade_plan_detail_id NUMERIC(19) NOT NULL,
+ config_type VARCHAR(255) NOT NULL,
+ key VARCHAR(255) NOT NULL,
+ new_value TEXT,
+ remove SMALLINT DEFAULT 0 NOT NULL,
+ CONSTRAINT PK_upgrade_plan_config PRIMARY KEY (id),
+ CONSTRAINT FK_up_conf_up_detail FOREIGN KEY (upgrade_plan_detail_id) REFERENCES upgrade_plan_detail (id)
+);
+
CREATE TABLE ambari_operation_history(
id NUMERIC(19) NOT NULL,
@@ -1296,6 +1307,7 @@ INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_id_
INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_group_id_seq', 0);
INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_item_id_seq', 0);
INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_plan_id_seq', 0);
+INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_plan_config_id_seq', 0);
INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('upgrade_plan_detail_id_seq', 0);
INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('stack_id_seq', 0);
INSERT INTO ambari_sequences(sequence_name, sequence_value) values ('mpack_id_seq', 0);
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 52649a7..def6392 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -1084,6 +1084,17 @@ CREATE TABLE upgrade_plan_detail (
CONSTRAINT FK_upgrade_det_upgrade_plan FOREIGN KEY (upgrade_plan_id) REFERENCES upgrade_plan (id)
);
+CREATE TABLE upgrade_plan_config (
+ id BIGINT NOT NULL,
+ upgrade_plan_detail_id BIGINT NOT NULL,
+ config_type VARCHAR(255) NOT NULL,
+ key VARCHAR(255) NOT NULL,
+ new_value TEXT,
+ remove SMALLINT NOT NULL DEFAULT 0,
+ CONSTRAINT PK_upgrade_plan_config PRIMARY KEY (id),
+ CONSTRAINT FK_up_conf_up_detail FOREIGN KEY (upgrade_plan_detail_id) REFERENCES upgrade_plan_detail (id)
+);
+
CREATE TABLE ambari_operation_history(
id BIGINT NOT NULL,
from_version VARCHAR(255) NOT NULL,
@@ -1323,6 +1334,7 @@ BEGIN TRANSACTION
('upgrade_group_id_seq', 0),
('upgrade_item_id_seq', 0),
('upgrade_plan_id_seq', 0),
+ ('upgrade_plan_config_id_seq', 0),
('upgrade_plan_detail_id_seq', 0),
('widget_id_seq', 0),
('widget_layout_id_seq', 0),
diff --git a/ambari-server/src/main/resources/META-INF/persistence.xml b/ambari-server/src/main/resources/META-INF/persistence.xml
index 19efd06..2c33227 100644
--- a/ambari-server/src/main/resources/META-INF/persistence.xml
+++ b/ambari-server/src/main/resources/META-INF/persistence.xml
@@ -88,6 +88,7 @@
<class>org.apache.ambari.server.orm.entities.UpgradeItemEntity</class>
<class>org.apache.ambari.server.orm.entities.UpgradeHistoryEntity</class>
<class>org.apache.ambari.server.orm.entities.UpgradePlanEntity</class>
+ <class>org.apache.ambari.server.orm.entities.UpgradePlanConfigEntity</class>
<class>org.apache.ambari.server.orm.entities.UpgradePlanDetailEntity</class>
<class>org.apache.ambari.server.orm.entities.UserEntity</class>
<class>org.apache.ambari.server.orm.entities.UserAuthenticationEntity</class>
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradePlanResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradePlanResourceProviderTest.java
index 2063642..89886b4 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradePlanResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UpgradePlanResourceProviderTest.java
@@ -35,13 +35,18 @@ import org.apache.ambari.server.controller.spi.Resource;
import org.apache.ambari.server.controller.utilities.PropertyHelper;
import org.apache.ambari.server.orm.GuiceJpaInitializer;
import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
+import org.apache.ambari.server.orm.dao.MpackDAO;
+import org.apache.ambari.server.orm.dao.ServiceGroupDAO;
import org.apache.ambari.server.orm.dao.UpgradePlanDAO;
+import org.apache.ambari.server.orm.entities.MpackEntity;
+import org.apache.ambari.server.orm.entities.ServiceGroupEntity;
import org.apache.ambari.server.orm.entities.UpgradePlanDetailEntity;
import org.apache.ambari.server.orm.entities.UpgradePlanEntity;
import org.apache.ambari.server.state.Cluster;
import org.apache.ambari.server.state.Clusters;
import org.apache.ambari.server.state.stack.upgrade.Direction;
import org.apache.ambari.server.state.stack.upgrade.UpgradeType;
+import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -60,9 +65,12 @@ import com.google.inject.util.Modules;
public class UpgradePlanResourceProviderTest {
private Injector injector;
- private AmbariManagementController amc;
private UpgradePlanDAO planDAO;
+ private AmbariManagementController amc;
+ private MpackDAO mpackDAO;
+ private ServiceGroupDAO serviceGroupDAO;
+
@Before
public void before() throws Exception {
Cluster cluster = createNiceMock(Cluster.class);
@@ -73,6 +81,8 @@ public class UpgradePlanResourceProviderTest {
expect(clusters.getCluster(anyString())).andReturn(cluster).atLeastOnce();
amc = createNiceMock(AmbariManagementController.class);
+ mpackDAO = createNiceMock(MpackDAO.class);
+ serviceGroupDAO = createNiceMock(ServiceGroupDAO.class);
expect(amc.getClusters()).andReturn(clusters).atLeastOnce();
@@ -93,6 +103,14 @@ public class UpgradePlanResourceProviderTest {
@Test
public void testCreateResources() throws Exception {
+ ServiceGroupEntity randomServiceGroup = createNiceMock(ServiceGroupEntity.class);
+ expect(serviceGroupDAO.findByClusterAndServiceGroupIds(EasyMock.anyLong(),
+ EasyMock.anyLong())).andReturn(randomServiceGroup).atLeastOnce();
+
+ MpackEntity randomMpack = createNiceMock(MpackEntity.class);
+ expect(mpackDAO.findById(EasyMock.anyLong())).andReturn(randomMpack).atLeastOnce();
+
+ replay(serviceGroupDAO, mpackDAO);
UpgradePlanResourceProvider provider = createProvider(amc);
@@ -125,6 +143,9 @@ public class UpgradePlanResourceProviderTest {
UpgradePlanDetailEntity detail = entity.getDetails().iterator().next();
assertEquals(4L, detail.getServiceGroupId());
assertEquals(2L, detail.getMpackTargetId());
+ assertNotNull(detail.getConfigChanges());
+ // !!! TODO when more thorough code is added, we'll be able to test more assertions
+ assertEquals(0, detail.getConfigChanges().size());
}
@@ -143,6 +164,8 @@ public class UpgradePlanResourceProviderTest {
@Override
public void configure(Binder binder) {
binder.bind(AmbariManagementController.class).toInstance(amc);
+ binder.bind(MpackDAO.class).toInstance(mpackDAO);
+ binder.bind(ServiceGroupDAO.class).toInstance(serviceGroupDAO);
}
}
}
--
To stop receiving notification emails like this one, please contact
ncole@apache.org.