You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2015/09/19 16:36:52 UTC
[3/3] ambari git commit: AMBARI-13144. Error during update service
configurations while kerberizing cluster post Ambari upgrade (aonishuk)
AMBARI-13144. Error during update service configurations while kerberizing cluster post Ambari upgrade (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/43a6bdd9
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/43a6bdd9
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/43a6bdd9
Branch: refs/heads/branch-2.1.2
Commit: 43a6bdd9906ca0acae91f7a090564bff5d816b27
Parents: b53dae2
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Sat Sep 19 17:36:29 2015 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Sat Sep 19 17:36:29 2015 +0300
----------------------------------------------------------------------
.../ambari/server/orm/dao/ServiceConfigDAO.java | 8 ++++++++
.../apache/ambari/server/state/ServiceImpl.java | 20 ++++++++++++++++++++
2 files changed, 28 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/43a6bdd9/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
index 1063c3f..128fef0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ServiceConfigDAO.java
@@ -67,6 +67,14 @@ public class ServiceConfigDAO {
"WHERE scv.serviceName=?1 AND scv.version=?2", ServiceConfigEntity.class);
return daoUtils.selectOne(query, serviceName, version);
}
+
+ @RequiresSession
+ public List<ServiceConfigEntity> findByService(Long clusterId, String serviceName) {
+ TypedQuery<ServiceConfigEntity> query = entityManagerProvider.get().
+ createQuery("SELECT scv FROM ServiceConfigEntity scv " +
+ "WHERE scv.clusterId=?1 AND scv.serviceName=?2", ServiceConfigEntity.class);
+ return daoUtils.selectList(query, clusterId, serviceName);
+ }
@RequiresSession
public List<ServiceConfigEntity> getLastServiceConfigVersionsForGroups(Collection<Long> configGroupIds) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/43a6bdd9/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
index 34c7b81..c210557 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
@@ -19,6 +19,7 @@
package org.apache.ambari.server.state;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -33,12 +34,14 @@ import org.apache.ambari.server.events.ServiceRemovedEvent;
import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
import org.apache.ambari.server.orm.dao.ClusterDAO;
import org.apache.ambari.server.orm.dao.ClusterServiceDAO;
+import org.apache.ambari.server.orm.dao.ServiceConfigDAO;
import org.apache.ambari.server.orm.dao.ServiceDesiredStateDAO;
import org.apache.ambari.server.orm.dao.StackDAO;
import org.apache.ambari.server.orm.entities.ClusterEntity;
import org.apache.ambari.server.orm.entities.ClusterServiceEntity;
import org.apache.ambari.server.orm.entities.ClusterServiceEntityPK;
import org.apache.ambari.server.orm.entities.ServiceComponentDesiredStateEntity;
+import org.apache.ambari.server.orm.entities.ServiceConfigEntity;
import org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity;
import org.apache.ambari.server.orm.entities.StackEntity;
import org.slf4j.Logger;
@@ -68,6 +71,8 @@ public class ServiceImpl implements Service {
private final boolean isClientOnlyService;
@Inject
+ private ServiceConfigDAO serviceConfigDAO;
+ @Inject
private ClusterServiceDAO clusterServiceDAO;
@Inject
private ServiceDesiredStateDAO serviceDesiredStateDAO;
@@ -537,6 +542,20 @@ public class ServiceImpl implements Service {
}
}
+ @Transactional
+ void deleteAllServiceConfigs() throws AmbariException {
+ LOG.info("Deleting all serviceconfigs for service"
+ + ", clusterName=" + cluster.getClusterName()
+ + ", serviceName=" + getName());
+
+ List<ServiceConfigEntity> serviceConfigEntities = serviceConfigDAO.findByService(cluster.getClusterId(), getName());
+
+ for (ServiceConfigEntity serviceConfigEntity : serviceConfigEntities) {
+ serviceConfigDAO.remove(serviceConfigEntity);
+ }
+
+ }
+
@Override
@Transactional
public void deleteAllComponents() throws AmbariException {
@@ -616,6 +635,7 @@ public class ServiceImpl implements Service {
readWriteLock.writeLock().lock();
try {
deleteAllComponents();
+ deleteAllServiceConfigs();
if (persisted) {
removeEntities();