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 2017/07/14 18:31:43 UTC
ambari git commit: AMBARI-21450. Fix non-python porting issues that
resulted in deployment failure (ncole)
Repository: ambari
Updated Branches:
refs/heads/branch-feature-AMBARI-21450 48f7fb22a -> ae3ce90cf
AMBARI-21450. Fix non-python porting issues that resulted in deployment failure (ncole)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ae3ce90c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ae3ce90c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ae3ce90c
Branch: refs/heads/branch-feature-AMBARI-21450
Commit: ae3ce90cf03aa46726c14b4632fed2a76aaf5501
Parents: 48f7fb2
Author: Nate Cole <nc...@hortonworks.com>
Authored: Fri Jul 14 14:31:36 2017 -0400
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Fri Jul 14 14:31:36 2017 -0400
----------------------------------------------------------------------
.../commands/StackAdvisorCommand.java | 12 +-
.../checks/DatabaseConsistencyCheckHelper.java | 2 -
.../controller/ResourceProviderFactory.java | 5 +-
.../AbstractControllerResourceProvider.java | 2 +-
.../internal/UpgradeResourceProvider.java | 4 -
.../controller/utilities/DatabaseChecker.java | 83 ++++----
.../entities/ClusterConfigMappingEntity.java | 207 -------------------
.../entities/ClusterConfigMappingEntityPK.java | 83 --------
.../server/orm/entities/ClusterEntity.java | 11 -
.../HostComponentDesiredStateEntity.java | 21 --
.../orm/entities/HostComponentStateEntity.java | 31 +--
.../server/orm/entities/HostVersionEntity.java | 78 ++++---
.../resources/Ambari-DDL-Postgres-CREATE.sql | 69 ++-----
.../src/main/resources/META-INF/persistence.xml | 2 +-
.../app/controllers/wizard/step8_controller.js | 13 +-
15 files changed, 139 insertions(+), 484 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
index adcb5b5..5440462 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
@@ -348,13 +348,13 @@ public abstract class StackAdvisorCommand<T extends StackAdvisorResponse> extend
return file.isDirectory() && !FileUtils.isFileNewer(file, cutoffDate);
}
});
-
+
if(oldDirectories.length > 0) {
LOG.info(String.format("Deleting old directories %s from %s", StringUtils.join(oldDirectories, ", "), recommendationsDir));
}
-
+
for(String oldDirectory:oldDirectories) {
- FileUtils.deleteDirectory(new File(recommendationsDir, oldDirectory));
+ FileUtils.deleteQuietly(new File(recommendationsDir, oldDirectory));
}
}
@@ -392,7 +392,7 @@ public abstract class StackAdvisorCommand<T extends StackAdvisorResponse> extend
private Collection<String> getUnregisteredHosts(String hostsJSON, List<String> hosts)
throws StackAdvisorException {
ObjectMapper mapper = new ObjectMapper();
- List<String> registeredHosts = new ArrayList<String>();
+ List<String> registeredHosts = new ArrayList<>();
try {
JsonNode root = mapper.readTree(hostsJSON);
@@ -434,12 +434,12 @@ public abstract class StackAdvisorCommand<T extends StackAdvisorResponse> extend
}
private ResourceInstance createHostResource() {
- Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+ Map<Resource.Type, String> mapIds = new HashMap<>();
return createResource(Resource.Type.Host, mapIds);
}
private ResourceInstance createStackVersionResource(String stackName, String stackVersion) {
- Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+ Map<Resource.Type, String> mapIds = new HashMap<>();
mapIds.put(Resource.Type.Stack, stackName);
mapIds.put(Resource.Type.StackVersion, stackVersion);
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
index 256e7b0..613dbe7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/checks/DatabaseConsistencyCheckHelper.java
@@ -736,7 +736,6 @@ public class DatabaseConsistencyCheckHelper {
stateEntity.setHostEntity(hostComponentDesiredStateEntity.getHostEntity());
stateEntity.setCurrentState(State.UNKNOWN);
stateEntity.setUpgradeState(UpgradeState.NONE);
- stateEntity.setCurrentStack(hostComponentDesiredStateEntity.getDesiredStack());
stateEntity.setSecurityState(SecurityState.UNKNOWN);
stateEntity.setServiceComponentDesiredStateEntity(hostComponentDesiredStateEntity.getServiceComponentDesiredStateEntity());
@@ -752,7 +751,6 @@ public class DatabaseConsistencyCheckHelper {
stateEntity.setServiceName(missedHostComponentState.getServiceName());
stateEntity.setHostEntity(missedHostComponentState.getHostEntity());
stateEntity.setDesiredState(State.UNKNOWN);
- stateEntity.setDesiredStack(missedHostComponentState.getCurrentStack());
stateEntity.setServiceComponentDesiredStateEntity(missedHostComponentState.getServiceComponentDesiredStateEntity());
LOG.error("Trying to add missing record in hostcomponentdesiredstate: {}", stateEntity);
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/ambari-server/src/main/java/org/apache/ambari/server/controller/ResourceProviderFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ResourceProviderFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ResourceProviderFactory.java
index 3ec38c2..fb8742b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ResourceProviderFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ResourceProviderFactory.java
@@ -28,7 +28,6 @@ import org.apache.ambari.server.controller.spi.Resource.Type;
import org.apache.ambari.server.controller.spi.ResourceProvider;
import com.google.inject.name.Named;
-import java.util.Set;
public interface ResourceProviderFactory {
@Named("host")
@@ -42,9 +41,7 @@ public interface ResourceProviderFactory {
AmbariManagementController managementController);
@Named("service")
- ResourceProvider getServiceResourceProvider(Set<String> propertyIds,
- Map<Type, String> keyPropertyIds,
- AmbariManagementController managementController);
+ ResourceProvider getServiceResourceProvider(AmbariManagementController managementController);
@Named("component")
ResourceProvider getComponentResourceProvider(Set<String> propertyIds,
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
index 5036bf4..eba1816 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
@@ -130,7 +130,7 @@ public abstract class AbstractControllerResourceProvider extends AbstractAuthori
case Cluster:
return new ClusterResourceProvider(managementController);
case Service:
- return resourceProviderFactory.getServiceResourceProvider(propertyIds, keyPropertyIds, managementController);
+ return resourceProviderFactory.getServiceResourceProvider(managementController);
case Component:
return resourceProviderFactory.getComponentResourceProvider(propertyIds, keyPropertyIds, managementController);
case Host:
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
index 5d02de3..a712d82 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UpgradeResourceProvider.java
@@ -642,10 +642,6 @@ public class UpgradeResourceProvider extends AbstractControllerResourceProvider
List<UpgradeGroupHolder> groups = s_upgradeHelper.createSequence(pack, upgradeContext);
- if (1 == 1 || groups.isEmpty()) {
- throw new AmbariException("There are no groupings available");
- }
-
// Non Rolling Upgrades require a group with name "UPDATE_DESIRED_STACK_ID".
// This is needed as a marker to indicate which version to use when an upgrade is paused.
if (pack.getType() == UpgradeType.NON_ROLLING) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java
index d35fc1a..1bc2221 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DatabaseChecker.java
@@ -32,7 +32,6 @@ import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.orm.dao.ClusterDAO;
import org.apache.ambari.server.orm.dao.MetainfoDAO;
import org.apache.ambari.server.orm.entities.ClusterConfigEntity;
-import org.apache.ambari.server.orm.entities.ClusterConfigMappingEntity;
import org.apache.ambari.server.orm.entities.ClusterEntity;
import org.apache.ambari.server.orm.entities.ClusterServiceEntity;
import org.apache.ambari.server.orm.entities.ClusterStateEntity;
@@ -193,57 +192,49 @@ public class DatabaseChecker {
List<ClusterEntity> clusters = clusterDAO.findAll();
if (clusters != null) {
for (ClusterEntity clusterEntity : clusters) {
- Collection<ClusterConfigMappingEntity> configMappingEntities = clusterEntity.getConfigMappingEntities();
- Collection<ClusterConfigEntity> clusterConfigEntities = clusterEntity.getClusterConfigEntities();
- if (configMappingEntities != null) {
- Map<String, Integer> selectedCountForType = new HashMap<>();
- for (ClusterConfigMappingEntity clusterConfigMappingEntity : configMappingEntities) {
- String typeName = clusterConfigMappingEntity.getType();
- if (clusterConfigMappingEntity.isSelected() > 0) {
- int selectedCount = selectedCountForType.get(typeName) != null ? selectedCountForType.get(typeName) : 0;
- selectedCountForType.put(typeName, selectedCount + 1);
-
- // Check that ClusterConfig contains type_name and tag from ClusterConfigMapping
- if (!clusterConfigsContainTypeAndTag(clusterConfigEntities, typeName, clusterConfigMappingEntity.getTag())) {
- checkPassed = false;
- LOG.error("ClusterConfig does not contain mapping for type_name=" + typeName + " tag="
- + clusterConfigMappingEntity.getTag());
- }
- } else {
- if (!selectedCountForType.containsKey(typeName)) {
- selectedCountForType.put(typeName, 0);
- }
+ Collection<ClusterConfigEntity> clusterConfigEntities = clusterEntity.getClusterConfigEntities();
+ Map<String, Integer> selectedCountForType = new HashMap<>();
+
+ for (ClusterConfigEntity configEntity : clusterConfigEntities) {
+ String typeName = configEntity.getType();
+ if (configEntity.isSelected()) {
+ int selectedCount = selectedCountForType.get(typeName) != null
+ ? selectedCountForType.get(typeName) : 0;
+ selectedCountForType.put(typeName, selectedCount + 1);
+ } else {
+ if (!selectedCountForType.containsKey(typeName)) {
+ selectedCountForType.put(typeName, 0);
}
}
+ }
- // Check that every config type from stack is presented in ClusterConfigMapping
- Collection<ClusterServiceEntity> clusterServiceEntities = clusterEntity.getClusterServiceEntities();
- ClusterStateEntity clusterStateEntity = clusterEntity.getClusterStateEntity();
- if (clusterStateEntity != null) {
- StackEntity currentStack = clusterStateEntity.getCurrentStack();
- StackInfo stack = ambariMetaInfo.getStack(currentStack.getStackName(), currentStack.getStackVersion());
-
- for (ClusterServiceEntity clusterServiceEntity : clusterServiceEntities) {
- if (!State.INIT.equals(clusterServiceEntity.getServiceDesiredStateEntity().getDesiredState())) {
- String serviceName = clusterServiceEntity.getServiceName();
- ServiceInfo serviceInfo = ambariMetaInfo.getService(stack.getName(), stack.getVersion(), serviceName);
- for (String configTypeName : serviceInfo.getConfigTypeAttributes().keySet()) {
- if (selectedCountForType.get(configTypeName) == null) {
+ // Check that every config type from stack is presented in ClusterConfigMapping
+ Collection<ClusterServiceEntity> clusterServiceEntities = clusterEntity.getClusterServiceEntities();
+ ClusterStateEntity clusterStateEntity = clusterEntity.getClusterStateEntity();
+ if (clusterStateEntity != null) {
+ StackEntity currentStack = clusterStateEntity.getCurrentStack();
+ StackInfo stack = ambariMetaInfo.getStack(currentStack.getStackName(), currentStack.getStackVersion());
+
+ for (ClusterServiceEntity clusterServiceEntity : clusterServiceEntities) {
+ if (!State.INIT.equals(clusterServiceEntity.getServiceDesiredStateEntity().getDesiredState())) {
+ String serviceName = clusterServiceEntity.getServiceName();
+ ServiceInfo serviceInfo = ambariMetaInfo.getService(stack.getName(), stack.getVersion(), serviceName);
+ for (String configTypeName : serviceInfo.getConfigTypeAttributes().keySet()) {
+ if (selectedCountForType.get(configTypeName) == null) {
+ checkPassed = false;
+ LOG.error("ClusterConfigMapping does not contain mapping for service=" + serviceName + " type_name="
+ + configTypeName);
+ } else {
+ // Check that for each config type exactly one is selected
+ if (selectedCountForType.get(configTypeName) == 0) {
checkPassed = false;
- LOG.error("ClusterConfigMapping does not contain mapping for service=" + serviceName + " type_name="
+ LOG.error("ClusterConfigMapping selected count is 0 for service=" + serviceName + " type_name="
+ configTypeName);
- } else {
- // Check that for each config type exactly one is selected
- if (selectedCountForType.get(configTypeName) == 0) {
- checkPassed = false;
- LOG.error("ClusterConfigMapping selected count is 0 for service=" + serviceName + " type_name="
- + configTypeName);
- } else if (selectedCountForType.get(configTypeName) > 1) {
- checkPassed = false;
- LOG.error("ClusterConfigMapping selected count is more than 1 for service=" + serviceName
- + " type_name=" + configTypeName);
- }
+ } else if (selectedCountForType.get(configTypeName) > 1) {
+ checkPassed = false;
+ LOG.error("ClusterConfigMapping selected count is more than 1 for service=" + serviceName
+ + " type_name=" + configTypeName);
}
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java
deleted file mode 100644
index 5748dc9..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntity.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * 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.Id;
-import javax.persistence.IdClass;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.NamedQueries;
-import javax.persistence.NamedQuery;
-import javax.persistence.Table;
-
-import com.google.common.base.Objects;
-
-/**
- * Entity that maps to a cluster config mapping.
- */
-@Entity
-@Table(name = "clusterconfigmapping")
-@IdClass(ClusterConfigMappingEntityPK.class)
-@NamedQueries({ @NamedQuery(
- name = "ClusterConfigMappingEntity.findLatestClusterConfigMappingsByType",
- query = "SELECT mapping FROM ClusterConfigMappingEntity mapping WHERE mapping.clusterId = :clusterId AND mapping.selectedInd > 0 AND mapping.typeName = :typeName") })
-
-public class ClusterConfigMappingEntity {
-
- @Id
- @Column(name = "cluster_id", insertable = false, updatable = false, nullable = false)
- private Long clusterId;
-
- @Id
- @Column(name = "type_name", insertable = true, updatable = false, nullable = false)
- private String typeName;
-
- @Id
- @Column(name = "create_timestamp", insertable = true, updatable = false, nullable = false)
- private Long createTimestamp;
-
- @Column(name = "version_tag", insertable = true, updatable = false, nullable = false)
- private String tag;
-
- @Column(name = "selected", insertable = true, updatable = true, nullable = false)
- private int selectedInd = 0;
-
- @Column(name = "user_name", insertable = true, updatable = true, nullable = false)
- private String user;
-
- @ManyToOne
- @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false)
- private ClusterEntity clusterEntity;
-
- public Long getClusterId() {
- return clusterId;
- }
-
- public void setClusterId(Long id) {
- clusterId = id;
- }
-
- public String getType() {
- return typeName;
- }
-
- public void setType(String type) {
- typeName = type;
- }
-
- public Long getCreateTimestamp() {
- return createTimestamp;
- }
-
- public void setCreateTimestamp(Long timestamp) {
- createTimestamp = timestamp;
- }
-
- public String getTag() {
- return tag;
- }
-
- public void setTag(String version) {
- tag = version;
- }
-
- public int isSelected() {
- return selectedInd;
- }
-
- public void setSelected(int selected) {
- selectedInd = selected;
- }
-
- /**
- * @return the user
- */
- public String getUser() {
- return user;
- }
-
- /**
- * @param userName the user
- */
- public void setUser(String userName) {
- user = userName;
- }
-
- public ClusterEntity getClusterEntity() {
- return clusterEntity;
- }
-
- public void setClusterEntity(ClusterEntity entity) {
- clusterEntity = entity;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((clusterId == null) ? 0 : clusterId.hashCode());
- result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
- result = prime * result + ((tag == null) ? 0 : tag.hashCode());
- result = prime * result + ((typeName == null) ? 0 : typeName.hashCode());
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (obj == null) {
- return false;
- }
-
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- ClusterConfigMappingEntity other = (ClusterConfigMappingEntity) obj;
- if (clusterId == null) {
- if (other.clusterId != null) {
- return false;
- }
- } else if (!clusterId.equals(other.clusterId)) {
- return false;
- }
-
- if (createTimestamp == null) {
- if (other.createTimestamp != null) {
- return false;
- }
- } else if (!createTimestamp.equals(other.createTimestamp)) {
- return false;
- }
-
- if (tag == null) {
- if (other.tag != null) {
- return false;
- }
- } else if (!tag.equals(other.tag)) {
- return false;
- }
-
- if (typeName == null) {
- if (other.typeName != null) {
- return false;
- }
- } else if (!typeName.equals(other.typeName)) {
- return false;
- }
-
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String toString() {
- return Objects.toStringHelper(this).add("clusterId", clusterId).add("type", typeName).add("tag",
- tag).add("selected", selectedInd).add("created", createTimestamp).toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntityPK.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntityPK.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntityPK.java
deleted file mode 100644
index e5ba5af..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterConfigMappingEntityPK.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * 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.Id;
-
-/**
- * PK class for cluster config mappings.
- */
-public class ClusterConfigMappingEntityPK {
- private Long clusterId;
- private String typeName;
- private Long createTimestamp;
-
- @Id
- @Column(name = "cluster_id", nullable = false, insertable = true, updatable = true, length = 10)
- public Long getClusterId() {
- return clusterId;
- }
-
- public void setClusterId(Long clusterId) {
- this.clusterId = clusterId;
- }
-
- @Id
- @Column(name = "type_name", nullable = false, insertable = true, updatable = false)
- public String getType() {
- return typeName;
- }
-
- public void setType(String type) {
- typeName = type;
- }
-
- @Id
- @Column(name = "create_timestamp", nullable = false, insertable = true, updatable = false)
- public Long getCreateTimestamp() {
- return createTimestamp;
- }
-
- public void setCreateTimestamp(Long timestamp) {
- createTimestamp = timestamp;
- }
-
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- ClusterConfigMappingEntityPK that = (ClusterConfigMappingEntityPK) o;
-
- if (clusterId != null ? !clusterId.equals(that.clusterId) : that.clusterId != null) return false;
- if (typeName != null ? !typeName.equals(that.typeName) : that.typeName != null) return false;
- if (createTimestamp != null ? !createTimestamp.equals (that.createTimestamp) : that.createTimestamp != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = clusterId !=null ? clusterId.intValue() : 0;
- result = 31 * result + (typeName != null ? typeName.hashCode() : 0);
- result = 31 * result + createTimestamp.intValue();
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java
index 6aad574..0f8f336 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterEntity.java
@@ -114,9 +114,6 @@ public class ClusterEntity {
@OneToMany(mappedBy = "clusterEntity", cascade = CascadeType.ALL)
private Collection<ClusterConfigEntity> configEntities;
- @OneToMany(mappedBy = "clusterEntity", cascade = CascadeType.REMOVE)
- private Collection<ClusterConfigMappingEntity> configMappingEntities;
-
@OneToMany(mappedBy = "clusterEntity", cascade = CascadeType.ALL)
private Collection<ConfigGroupEntity> configGroupEntities;
@@ -297,14 +294,6 @@ public class ClusterEntity {
configEntities = entities;
}
- public Collection<ClusterConfigMappingEntity> getConfigMappingEntities() {
- return configMappingEntities;
- }
-
- public void setConfigMappingEntities(Collection<ClusterConfigMappingEntity> entities) {
- configMappingEntities = entities;
- }
-
public Collection<ConfigGroupEntity> getConfigGroupEntities() {
return configGroupEntities;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java
index ea2938b..2049969 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java
@@ -32,7 +32,6 @@ import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
-import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.UniqueConstraint;
@@ -100,13 +99,6 @@ public class HostComponentDesiredStateEntity {
@Enumerated(value = EnumType.STRING)
private SecurityState securityState = SecurityState.UNSECURED;
- /**
- * Unidirectional one-to-one association to {@link StackEntity}
- */
- @OneToOne
- @JoinColumn(name = "desired_stack_id", unique = false, nullable = false)
- private StackEntity desiredStack;
-
@Enumerated(value = EnumType.STRING)
@Column(name = "admin_state", nullable = true, insertable = true, updatable = true)
private HostComponentAdminState adminState;
@@ -176,14 +168,6 @@ public class HostComponentDesiredStateEntity {
this.securityState = securityState;
}
- public StackEntity getDesiredStack() {
- return desiredStack;
- }
-
- public void setDesiredStack(StackEntity desiredStack) {
- this.desiredStack = desiredStack;
- }
-
public HostComponentAdminState getAdminState() {
return adminState;
}
@@ -223,10 +207,6 @@ public class HostComponentDesiredStateEntity {
return false;
}
- if (!Objects.equal(desiredStack, that.desiredStack)) {
- return false;
- }
-
if (!Objects.equal(desiredState, that.desiredState)) {
return false;
}
@@ -249,7 +229,6 @@ public class HostComponentDesiredStateEntity {
result = 31 * result + (hostEntity != null ? hostEntity.hashCode() : 0);
result = 31 * result + (componentName != null ? componentName.hashCode() : 0);
result = 31 * result + (desiredState != null ? desiredState.hashCode() : 0);
- result = 31 * result + (desiredStack != null ? desiredStack.hashCode() : 0);
result = 31 * result + (serviceName != null ? serviceName.hashCode() : 0);
return result;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java
index 9d35e2a..2a63bba 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentStateEntity.java
@@ -1,4 +1,4 @@
-/**
+/*
* 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
@@ -30,7 +30,6 @@ import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
-import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
@@ -67,7 +66,12 @@ import com.google.common.base.Objects;
query = "SELECT hcs from HostComponentStateEntity hcs WHERE hcs.serviceName=:serviceName AND hcs.componentName=:componentName AND hcs.hostEntity.hostName=:hostName"),
@NamedQuery(
name = "HostComponentStateEntity.findByIndex",
- query = "SELECT hcs from HostComponentStateEntity hcs WHERE hcs.clusterId=:clusterId AND hcs.serviceName=:serviceName AND hcs.componentName=:componentName AND hcs.hostId=:hostId") })
+ query = "SELECT hcs from HostComponentStateEntity hcs WHERE hcs.clusterId=:clusterId AND hcs.serviceName=:serviceName AND hcs.componentName=:componentName AND hcs.hostId=:hostId"),
+ @NamedQuery(
+ name = "HostComponentStateEntity.findByServiceAndComponentAndNotVersion",
+ query = "SELECT hcs from HostComponentStateEntity hcs WHERE hcs.serviceName=:serviceName AND hcs.componentName=:componentName AND hcs.version != :version")
+})
+
public class HostComponentStateEntity {
@Id
@@ -105,13 +109,6 @@ public class HostComponentStateEntity {
@Column(name = "security_state", nullable = false, insertable = true, updatable = true)
private SecurityState securityState = SecurityState.UNSECURED;
- /**
- * Unidirectional one-to-one association to {@link StackEntity}
- */
- @OneToOne
- @JoinColumn(name = "current_stack_id", unique = false, nullable = false, insertable = true, updatable = true)
- private StackEntity currentStack;
-
@ManyToOne
@JoinColumns({
@JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false),
@@ -183,14 +180,6 @@ public class HostComponentStateEntity {
this.upgradeState = upgradeState;
}
- public StackEntity getCurrentStack() {
- return currentStack;
- }
-
- public void setCurrentStack(StackEntity currentStack) {
- this.currentStack = currentStack;
- }
-
public String getVersion() {
return version;
}
@@ -224,11 +213,6 @@ public class HostComponentStateEntity {
return false;
}
- if (currentStack != null ? !currentStack.equals(that.currentStack)
- : that.currentStack != null) {
- return false;
- }
-
if (currentState != null ? !currentState.equals(that.currentState)
: that.currentState != null) {
return false;
@@ -262,7 +246,6 @@ public class HostComponentStateEntity {
result = 31 * result + (componentName != null ? componentName.hashCode() : 0);
result = 31 * result + (currentState != null ? currentState.hashCode() : 0);
result = 31 * result + (upgradeState != null ? upgradeState.hashCode() : 0);
- result = 31 * result + (currentStack != null ? currentStack.hashCode() : 0);
result = 31 * result + (serviceName != null ? serviceName.hashCode() : 0);
result = 31 * result + (version != null ? version.hashCode() : 0);
return result;
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostVersionEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostVersionEntity.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostVersionEntity.java
index 4ed9617..4a030af 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostVersionEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostVersionEntity.java
@@ -1,4 +1,4 @@
-/**
+/*
* 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
@@ -35,13 +35,19 @@ import javax.persistence.UniqueConstraint;
import org.apache.ambari.server.state.RepositoryVersionState;
-@Table(name = "host_version", uniqueConstraints = @UniqueConstraint(name = "UQ_host_repo", columnNames = { "repo_version_id", "host_id" }))
@Entity
-@TableGenerator(name = "host_version_id_generator",
- table = "ambari_sequences", pkColumnName = "sequence_name", valueColumnName = "sequence_value"
- , pkColumnValue = "host_version_id_seq"
- , initialValue = 0
-)
+@Table(
+ name = "host_version",
+ uniqueConstraints = @UniqueConstraint(
+ name = "UQ_host_repo",
+ columnNames = { "host_id", "repo_version_id" }))
+@TableGenerator(
+ name = "host_version_id_generator",
+ table = "ambari_sequences",
+ pkColumnName = "sequence_name",
+ valueColumnName = "sequence_value",
+ pkColumnValue = "host_version_id_seq",
+ initialValue = 0)
@NamedQueries({
@NamedQuery(name = "hostVersionByClusterAndStackAndVersion", query =
"SELECT hostVersion FROM HostVersionEntity hostVersion JOIN hostVersion.hostEntity host JOIN host.clusterEntities clusters " +
@@ -55,6 +61,11 @@ import org.apache.ambari.server.state.RepositoryVersionState;
"SELECT hostVersion FROM HostVersionEntity hostVersion JOIN hostVersion.hostEntity host " +
"WHERE hostVersion.hostEntity.hostName=:hostName"),
+ @NamedQuery(
+ name = "findByClusterAndState",
+ query = "SELECT hostVersion FROM HostVersionEntity hostVersion JOIN hostVersion.hostEntity host JOIN host.clusterEntities clusters "
+ + "WHERE clusters.clusterName=:clusterName AND hostVersion.state=:state"),
+
@NamedQuery(name = "hostVersionByClusterHostnameAndState", query =
"SELECT hostVersion FROM HostVersionEntity hostVersion JOIN hostVersion.hostEntity host JOIN host.clusterEntities clusters " +
"WHERE clusters.clusterName=:clusterName AND hostVersion.hostEntity.hostName=:hostName AND hostVersion.state=:state"),
@@ -64,14 +75,19 @@ import org.apache.ambari.server.state.RepositoryVersionState;
"WHERE clusters.clusterName=:clusterName AND hostVersion.repositoryVersion.stack.stackName=:stackName AND hostVersion.repositoryVersion.stack.stackVersion=:stackVersion AND hostVersion.repositoryVersion.version=:version AND " +
"hostVersion.hostEntity.hostName=:hostName"),
- @NamedQuery(name = "hostVersionByClusterHostIdAndState", query =
- "SELECT hostVersion FROM HostVersionEntity hostVersion JOIN hostVersion.hostEntity host JOIN host.clusterEntities clusters " +
- "WHERE clusters.clusterId=:clusterId AND hostVersion.hostId=:hostId AND hostVersion.state=:state"),
+ @NamedQuery(
+ name = "findHostVersionByClusterAndRepository",
+ query = "SELECT hostVersion FROM HostVersionEntity hostVersion JOIN hostVersion.hostEntity host JOIN host.clusterEntities clusters "
+ + "WHERE clusters.clusterId = :clusterId AND hostVersion.repositoryVersion = :repositoryVersion"),
+
+ @NamedQuery(
+ name = "hostVersionByRepositoryAndStates",
+ query = "SELECT hostVersion FROM HostVersionEntity hostVersion WHERE hostVersion.repositoryVersion = :repositoryVersion AND hostVersion.state IN :states"),
+
+ @NamedQuery(
+ name = "findByHostAndRepository",
+ query = "SELECT hostVersion FROM HostVersionEntity hostVersion WHERE hostVersion.hostEntity = :host AND hostVersion.repositoryVersion = :repositoryVersion")
- @NamedQuery(name = "hostVersionByClusterStackVersionAndHostId", query =
- "SELECT hostVersion FROM HostVersionEntity hostVersion JOIN hostVersion.hostEntity host JOIN host.clusterEntities clusters " +
- "WHERE hostVersion.hostId=:hostId AND clusters.clusterId=:clusterId AND hostVersion.repositoryVersion.stack.stackName=:stackName " +
- "AND hostVersion.repositoryVersion.stack.stackVersion=:stackVersion AND hostVersion.repositoryVersion.version=:version")
})
public class HostVersionEntity {
@@ -115,9 +131,9 @@ public class HostVersionEntity {
* This constructor is mainly used by the unit tests in order to construct an object without the id.
*/
public HostVersionEntity(HostVersionEntity other) {
- this.hostEntity = other.hostEntity;
- this.repositoryVersion = other.repositoryVersion;
- this.state = other.state;
+ hostEntity = other.hostEntity;
+ repositoryVersion = other.repositoryVersion;
+ state = other.state;
}
public Long getId() {
@@ -169,15 +185,29 @@ public class HostVersionEntity {
@Override
public boolean equals(Object obj) {
- if (this == obj) return true;
- if (obj == null) return false;
- if (getClass() != obj.getClass()) return false;
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
HostVersionEntity other = (HostVersionEntity) obj;
- if (id != null ? id != other.id : other.id != null) return false;
- if (hostEntity != null ? !hostEntity.equals(other.hostEntity) : other.hostEntity != null) return false;
- if (repositoryVersion != null ? !repositoryVersion.equals(other.repositoryVersion) : other.repositoryVersion != null) return false;
- if (state != other.state) return false;
+ if (id != null ? id != other.id : other.id != null) {
+ return false;
+ }
+ if (hostEntity != null ? !hostEntity.equals(other.hostEntity) : other.hostEntity != null) {
+ return false;
+ }
+ if (repositoryVersion != null ? !repositoryVersion.equals(other.repositoryVersion) : other.repositoryVersion != null) {
+ return false;
+ }
+ if (state != other.state) {
+ return false;
+ }
return true;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/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 5baf964..037e540 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -72,26 +72,18 @@ CREATE TABLE clusterconfig (
type_name VARCHAR(255) NOT NULL,
cluster_id BIGINT NOT NULL,
stack_id BIGINT NOT NULL,
+ selected SMALLINT NOT NULL DEFAULT 0,
config_data TEXT NOT NULL,
config_attributes TEXT,
create_timestamp BIGINT NOT NULL,
service_deleted SMALLINT NOT NULL DEFAULT 0,
+ selected_timestamp BIGINT NOT NULL DEFAULT 0,
CONSTRAINT PK_clusterconfig PRIMARY KEY (config_id),
CONSTRAINT FK_clusterconfig_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
CONSTRAINT FK_clusterconfig_stack_id FOREIGN KEY (stack_id) REFERENCES stack(stack_id),
CONSTRAINT UQ_config_type_tag UNIQUE (cluster_id, type_name, version_tag),
CONSTRAINT UQ_config_type_version UNIQUE (cluster_id, type_name, version));
-CREATE TABLE clusterconfigmapping (
- cluster_id BIGINT NOT NULL,
- type_name VARCHAR(255) NOT NULL,
- version_tag VARCHAR(255) NOT NULL,
- create_timestamp BIGINT NOT NULL,
- selected INTEGER NOT NULL DEFAULT 0,
- user_name VARCHAR(255) NOT NULL DEFAULT '_db',
- CONSTRAINT PK_clusterconfigmapping PRIMARY KEY (cluster_id, type_name, create_timestamp),
- CONSTRAINT clusterconfigmappingcluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id));
-
CREATE TABLE serviceconfig (
service_config_id BIGINT NOT NULL,
cluster_id BIGINT NOT NULL,
@@ -171,37 +163,24 @@ CREATE TABLE repo_version (
CONSTRAINT UQ_repo_version_display_name UNIQUE (display_name),
CONSTRAINT UQ_repo_version_stack_id UNIQUE (stack_id, version));
-CREATE TABLE cluster_version (
- id BIGINT NOT NULL,
- repo_version_id BIGINT NOT NULL,
- cluster_id BIGINT NOT NULL,
- state VARCHAR(32) NOT NULL,
- start_time BIGINT NOT NULL,
- end_time BIGINT,
- user_name VARCHAR(32),
- CONSTRAINT PK_cluster_version PRIMARY KEY (id),
- CONSTRAINT FK_cluster_version_cluster_id FOREIGN KEY (cluster_id) REFERENCES clusters (cluster_id),
- CONSTRAINT FK_cluster_version_repovers_id FOREIGN KEY (repo_version_id) REFERENCES repo_version (repo_version_id));
-
CREATE TABLE servicecomponentdesiredstate (
id BIGINT NOT NULL,
component_name VARCHAR(255) NOT NULL,
cluster_id BIGINT NOT NULL,
- desired_stack_id BIGINT NOT NULL,
- desired_version VARCHAR(255) NOT NULL DEFAULT 'UNKNOWN',
+ desired_repo_version_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
recovery_enabled SMALLINT NOT NULL DEFAULT 0,
+ repo_state VARCHAR(255) NOT NULL DEFAULT 'NOT_REQUIRED',
CONSTRAINT pk_sc_desiredstate PRIMARY KEY (id),
CONSTRAINT UQ_scdesiredstate_name UNIQUE(component_name, service_name, cluster_id),
- CONSTRAINT FK_scds_desired_stack_id FOREIGN KEY (desired_stack_id) REFERENCES stack(stack_id),
+ CONSTRAINT FK_scds_desired_repo_id FOREIGN KEY (desired_repo_version_id) REFERENCES repo_version (repo_version_id),
CONSTRAINT srvccmponentdesiredstatesrvcnm FOREIGN KEY (service_name, cluster_id) REFERENCES clusterservices (service_name, cluster_id));
CREATE TABLE hostcomponentdesiredstate (
id BIGINT NOT NULL,
cluster_id BIGINT NOT NULL,
component_name VARCHAR(255) NOT NULL,
- desired_stack_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
host_id BIGINT NOT NULL,
service_name VARCHAR(255) NOT NULL,
@@ -212,7 +191,6 @@ CREATE TABLE hostcomponentdesiredstate (
CONSTRAINT PK_hostcomponentdesiredstate PRIMARY KEY (id),
CONSTRAINT UQ_hcdesiredstate_name UNIQUE (component_name, service_name, host_id, cluster_id),
CONSTRAINT FK_hcdesiredstate_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id),
- CONSTRAINT FK_hcds_desired_stack_id FOREIGN KEY (desired_stack_id) REFERENCES stack(stack_id),
CONSTRAINT hstcmpnntdesiredstatecmpnntnme FOREIGN KEY (component_name, service_name, cluster_id) REFERENCES servicecomponentdesiredstate (component_name, service_name, cluster_id));
CREATE TABLE hostcomponentstate (
@@ -220,14 +198,12 @@ CREATE TABLE hostcomponentstate (
cluster_id BIGINT NOT NULL,
component_name VARCHAR(255) NOT NULL,
version VARCHAR(32) NOT NULL DEFAULT 'UNKNOWN',
- current_stack_id BIGINT NOT NULL,
current_state VARCHAR(255) NOT NULL,
host_id BIGINT NOT NULL,
service_name VARCHAR(255) NOT NULL,
upgrade_state VARCHAR(32) NOT NULL DEFAULT 'NONE',
security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED',
CONSTRAINT pk_hostcomponentstate PRIMARY KEY (id),
- CONSTRAINT FK_hcs_current_stack_id FOREIGN KEY (current_stack_id) REFERENCES stack(stack_id),
CONSTRAINT FK_hostcomponentstate_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id),
CONSTRAINT hstcomponentstatecomponentname FOREIGN KEY (component_name, service_name, cluster_id) REFERENCES servicecomponentdesiredstate (component_name, service_name, cluster_id));
@@ -252,19 +228,19 @@ CREATE TABLE host_version (
CONSTRAINT PK_host_version PRIMARY KEY (id),
CONSTRAINT FK_host_version_host_id FOREIGN KEY (host_id) REFERENCES hosts (host_id),
CONSTRAINT FK_host_version_repovers_id FOREIGN KEY (repo_version_id) REFERENCES repo_version (repo_version_id),
- CONSTRAINT UQ_host_repo UNIQUE(repo_version_id, host_id));
+ CONSTRAINT UQ_host_repo UNIQUE(host_id, repo_version_id));
CREATE TABLE servicedesiredstate (
cluster_id BIGINT NOT NULL,
desired_host_role_mapping INTEGER NOT NULL,
- desired_stack_id BIGINT NOT NULL,
+ desired_repo_version_id BIGINT NOT NULL,
desired_state VARCHAR(255) NOT NULL,
service_name VARCHAR(255) NOT NULL,
maintenance_state VARCHAR(32) NOT NULL,
security_state VARCHAR(32) NOT NULL DEFAULT 'UNSECURED',
credential_store_enabled SMALLINT NOT NULL DEFAULT 0,
CONSTRAINT PK_servicedesiredstate PRIMARY KEY (cluster_id, service_name),
- CONSTRAINT FK_sds_desired_stack_id FOREIGN KEY (desired_stack_id) REFERENCES stack(stack_id),
+ CONSTRAINT FK_repo_version_id FOREIGN KEY (desired_repo_version_id) REFERENCES repo_version (repo_version_id),
CONSTRAINT servicedesiredstateservicename FOREIGN KEY (service_name, cluster_id) REFERENCES clusterservices (service_name, cluster_id));
CREATE TABLE adminprincipaltype (
@@ -830,11 +806,11 @@ CREATE TABLE upgrade (
upgrade_id BIGINT NOT NULL,
cluster_id BIGINT NOT NULL,
request_id BIGINT NOT NULL,
- from_repo_version_id BIGINT NOT NULL,
- to_repo_version_id BIGINT NOT NULL,
direction VARCHAR(255) DEFAULT 'UPGRADE' NOT NULL,
+ orchestration VARCHAR(255) DEFAULT 'STANDARD' NOT NULL,
upgrade_package VARCHAR(255) NOT NULL,
upgrade_type VARCHAR(32) NOT NULL,
+ repo_version_id BIGINT NOT NULL,
skip_failures SMALLINT DEFAULT 0 NOT NULL,
skip_sc_failures SMALLINT DEFAULT 0 NOT NULL,
downgrade_allowed SMALLINT DEFAULT 1 NOT NULL,
@@ -842,8 +818,7 @@ CREATE TABLE upgrade (
CONSTRAINT PK_upgrade PRIMARY KEY (upgrade_id),
FOREIGN KEY (cluster_id) REFERENCES clusters(cluster_id),
FOREIGN KEY (request_id) REFERENCES request(request_id),
- CONSTRAINT FK_upgrade_from_repo_id FOREIGN KEY (from_repo_version_id) REFERENCES repo_version (repo_version_id),
- CONSTRAINT FK_upgrade_to_repo_id FOREIGN KEY (to_repo_version_id) REFERENCES repo_version (repo_version_id)
+ FOREIGN KEY (repo_version_id) REFERENCES repo_version(repo_version_id)
);
CREATE TABLE upgrade_group (
@@ -867,17 +842,18 @@ CREATE TABLE upgrade_item (
FOREIGN KEY (upgrade_group_id) REFERENCES upgrade_group(upgrade_group_id)
);
-CREATE TABLE servicecomponent_history(
+CREATE TABLE upgrade_history(
id BIGINT NOT NULL,
- component_id BIGINT NOT NULL,
upgrade_id BIGINT NOT NULL,
- from_stack_id BIGINT NOT NULL,
- to_stack_id BIGINT NOT NULL,
- CONSTRAINT PK_sc_history PRIMARY KEY (id),
- CONSTRAINT FK_sc_history_component_id FOREIGN KEY (component_id) REFERENCES servicecomponentdesiredstate (id),
- CONSTRAINT FK_sc_history_upgrade_id FOREIGN KEY (upgrade_id) REFERENCES upgrade (upgrade_id),
- CONSTRAINT FK_sc_history_from_stack_id FOREIGN KEY (from_stack_id) REFERENCES stack (stack_id),
- CONSTRAINT FK_sc_history_to_stack_id FOREIGN KEY (to_stack_id) REFERENCES stack (stack_id)
+ service_name VARCHAR(255) NOT NULL,
+ component_name VARCHAR(255) NOT NULL,
+ from_repo_version_id BIGINT NOT NULL,
+ target_repo_version_id BIGINT NOT NULL,
+ CONSTRAINT PK_upgrade_hist PRIMARY KEY (id),
+ CONSTRAINT FK_upgrade_hist_upgrade_id FOREIGN KEY (upgrade_id) REFERENCES upgrade (upgrade_id),
+ CONSTRAINT FK_upgrade_hist_from_repo FOREIGN KEY (from_repo_version_id) REFERENCES repo_version (repo_version_id),
+ CONSTRAINT FK_upgrade_hist_target_repo FOREIGN KEY (target_repo_version_id) REFERENCES repo_version (repo_version_id),
+ CONSTRAINT UQ_upgrade_hist UNIQUE (upgrade_id, component_name, service_name)
);
CREATE TABLE servicecomponent_version(
@@ -1083,7 +1059,6 @@ INSERT INTO ambari_sequences (sequence_name, sequence_value) VALUES
('alert_current_id_seq', 0),
('config_id_seq', 1),
('repo_version_id_seq', 0),
- ('cluster_version_id_seq', 0),
('host_version_id_seq', 0),
('service_config_id_seq', 1),
('upgrade_id_seq', 0),
@@ -1104,7 +1079,7 @@ INSERT INTO ambari_sequences (sequence_name, sequence_value) VALUES
('setting_id_seq', 0),
('hostcomponentstate_id_seq', 0),
('servicecomponentdesiredstate_id_seq', 0),
- ('servicecomponent_history_id_seq', 0),
+ ('upgrade_history_id_seq', 0),
('blueprint_setting_id_seq', 0),
('ambari_operation_history_id_seq', 0),
('remote_cluster_id_seq', 0),
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/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 60c1f11..3369297 100644
--- a/ambari-server/src/main/resources/META-INF/persistence.xml
+++ b/ambari-server/src/main/resources/META-INF/persistence.xml
@@ -24,7 +24,6 @@
<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.ClusterConfigEntity</class>
- <class>org.apache.ambari.server.orm.entities.ClusterConfigMappingEntity</class>
<class>org.apache.ambari.server.orm.entities.ClusterEntity</class>
<class>org.apache.ambari.server.orm.entities.ClusterServiceEntity</class>
<class>org.apache.ambari.server.orm.entities.ClusterStateEntity</class>
@@ -73,6 +72,7 @@
<class>org.apache.ambari.server.orm.entities.StageEntity</class>
<class>org.apache.ambari.server.orm.entities.UpgradeEntity</class>
<class>org.apache.ambari.server.orm.entities.UpgradeGroupEntity</class>
+ <class>org.apache.ambari.server.orm.entities.UpgradeHistoryEntity</class>
<class>org.apache.ambari.server.orm.entities.UpgradeItemEntity</class>
<class>org.apache.ambari.server.orm.entities.UserEntity</class>
<class>org.apache.ambari.server.orm.entities.WidgetEntity</class>
http://git-wip-us.apache.org/repos/asf/ambari/blob/ae3ce90c/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 24d8ec7..41a4aaf 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -914,6 +914,9 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
installerController.postVersionDefinitionFileStep8(versionData.isXMLdata, versionData.data).done(function (versionInfo) {
if (versionInfo.id && versionInfo.stackName && versionInfo.stackVersion) {
var selectedStack = App.Stack.find().findProperty('isSelected', true);
+ if (selectedStack) {
+ selectedStack.set('versionInfoId', versionInfo.id);
+ }
installerController.updateRepoOSInfo(versionInfo, selectedStack).done(function() {
self._startDeploy();
});
@@ -1012,9 +1015,13 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
* @method createSelectedServicesData
*/
createSelectedServicesData: function () {
- return this.get('selectedServices').map(function (_service) {
- return {"ServiceInfo": { "service_name": _service.get('serviceName') }};
- });
+ var selectedStack;
+ if (this.get('isInstaller')) {
+ selectedStack = App.Stack.find().findProperty('isSelected', true);
+ }
+ return this.get('selectedServices').map(service => selectedStack ?
+ {"ServiceInfo": { "service_name": service.get('serviceName'), "desired_repository_version_id": selectedStack.get('versionInfoId') }} :
+ {"ServiceInfo": { "service_name": service.get('serviceName') }});
},
/**