ambari git commit: AMBARI-11744. Ambari Server deadlocks when adding service / adding host. (swagle)
Repository: ambari Updated Branches: refs/heads/branch-2.0.maint 7c439a268 - d9cffc309 AMBARI-11744. Ambari Server deadlocks when adding service / adding host. (swagle) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d9cffc30 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d9cffc30 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d9cffc30 Branch: refs/heads/branch-2.0.maint Commit: d9cffc309a55861bf6cd70401afed6889dd42ea4 Parents: 7c439a2 Author: Siddharth Wagle swa...@hortonworks.com Authored: Fri Jun 5 20:33:33 2015 -0700 Committer: Siddharth Wagle swa...@hortonworks.com Committed: Fri Jun 5 20:33:33 2015 -0700 -- .../internal/ConfigGroupResourceProvider.java | 4 +- .../state/configgroup/ConfigGroupImpl.java | 113 ++- 2 files changed, 61 insertions(+), 56 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/d9cffc30/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java index 3fcb84b..f4893cd 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java @@ -523,9 +523,7 @@ public class ConfigGroupResourceProvider extends return configGroupResponses; } - private synchronized void updateConfigGroups -(SetConfigGroupRequest requests) throws AmbariException { - + private synchronized void updateConfigGroups (SetConfigGroupRequest requests) throws AmbariException { if (requests.isEmpty()) { LOG.warn(Received an empty requests set); return; http://git-wip-us.apache.org/repos/asf/ambari/blob/d9cffc30/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java index 9ec0370..ea3c406 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java @@ -312,18 +312,23 @@ public class ConfigGroupImpl implements ConfigGroup { @Override public void persist() { -readWriteLock.writeLock().lock(); +cluster.getClusterGlobalLock().writeLock().lock(); try { - if (!isPersisted) { -persistEntities(); -refresh(); -cluster.refresh(); -isPersisted = true; - } else { -saveIfPersisted(); + readWriteLock.writeLock().lock(); + try { +if (!isPersisted) { + persistEntities(); + refresh(); + cluster.refresh(); + isPersisted = true; +} else { + saveIfPersisted(); +} + } finally { +readWriteLock.writeLock().unlock(); } } finally { - readWriteLock.writeLock().unlock(); + cluster.getClusterGlobalLock().writeLock().unlock(); } } @@ -413,19 +418,11 @@ public class ConfigGroupImpl implements ConfigGroup { clusterConfigEntity.setAttributes(gson.toJson(config.getPropertiesAttributes())); } clusterConfigEntity.setTimestamp(System.currentTimeMillis()); - - - // TODO: Is locking necessary and functional ? - cluster.getClusterGlobalLock().writeLock().lock(); - try { -clusterDAO.createConfig(clusterConfigEntity); -clusterEntity.getClusterConfigEntities().add(clusterConfigEntity); -cluster.addConfig(config); -clusterDAO.merge(clusterEntity); -cluster.refresh(); - } finally { -cluster.getClusterGlobalLock().writeLock().unlock(); - } + clusterDAO.createConfig(clusterConfigEntity); + clusterEntity.getClusterConfigEntities().add(clusterConfigEntity); + cluster.addConfig(config); + clusterDAO.merge(clusterEntity); + cluster.refresh(); } ConfigGroupConfigMappingEntity configMappingEntity = @@ -460,15 +457,20 @@ public class ConfigGroupImpl implements ConfigGroup { @Override @Transactional public void delete() { -readWriteLock.writeLock().lock(); +
ambari git commit: AMBARI-11744. Ambari Server deadlocks when adding service / adding host. (swagle)
Repository: ambari Updated Branches: refs/heads/branch-2.0-maint [created] d9cffc309 AMBARI-11744. Ambari Server deadlocks when adding service / adding host. (swagle) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d9cffc30 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d9cffc30 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d9cffc30 Branch: refs/heads/branch-2.0-maint Commit: d9cffc309a55861bf6cd70401afed6889dd42ea4 Parents: 7c439a2 Author: Siddharth Wagle swa...@hortonworks.com Authored: Fri Jun 5 20:33:33 2015 -0700 Committer: Siddharth Wagle swa...@hortonworks.com Committed: Fri Jun 5 20:33:33 2015 -0700 -- .../internal/ConfigGroupResourceProvider.java | 4 +- .../state/configgroup/ConfigGroupImpl.java | 113 ++- 2 files changed, 61 insertions(+), 56 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/d9cffc30/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java index 3fcb84b..f4893cd 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java @@ -523,9 +523,7 @@ public class ConfigGroupResourceProvider extends return configGroupResponses; } - private synchronized void updateConfigGroups -(SetConfigGroupRequest requests) throws AmbariException { - + private synchronized void updateConfigGroups (SetConfigGroupRequest requests) throws AmbariException { if (requests.isEmpty()) { LOG.warn(Received an empty requests set); return; http://git-wip-us.apache.org/repos/asf/ambari/blob/d9cffc30/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java index 9ec0370..ea3c406 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java @@ -312,18 +312,23 @@ public class ConfigGroupImpl implements ConfigGroup { @Override public void persist() { -readWriteLock.writeLock().lock(); +cluster.getClusterGlobalLock().writeLock().lock(); try { - if (!isPersisted) { -persistEntities(); -refresh(); -cluster.refresh(); -isPersisted = true; - } else { -saveIfPersisted(); + readWriteLock.writeLock().lock(); + try { +if (!isPersisted) { + persistEntities(); + refresh(); + cluster.refresh(); + isPersisted = true; +} else { + saveIfPersisted(); +} + } finally { +readWriteLock.writeLock().unlock(); } } finally { - readWriteLock.writeLock().unlock(); + cluster.getClusterGlobalLock().writeLock().unlock(); } } @@ -413,19 +418,11 @@ public class ConfigGroupImpl implements ConfigGroup { clusterConfigEntity.setAttributes(gson.toJson(config.getPropertiesAttributes())); } clusterConfigEntity.setTimestamp(System.currentTimeMillis()); - - - // TODO: Is locking necessary and functional ? - cluster.getClusterGlobalLock().writeLock().lock(); - try { -clusterDAO.createConfig(clusterConfigEntity); -clusterEntity.getClusterConfigEntities().add(clusterConfigEntity); -cluster.addConfig(config); -clusterDAO.merge(clusterEntity); -cluster.refresh(); - } finally { -cluster.getClusterGlobalLock().writeLock().unlock(); - } + clusterDAO.createConfig(clusterConfigEntity); + clusterEntity.getClusterConfigEntities().add(clusterConfigEntity); + cluster.addConfig(config); + clusterDAO.merge(clusterEntity); + cluster.refresh(); } ConfigGroupConfigMappingEntity configMappingEntity = @@ -460,15 +457,20 @@ public class ConfigGroupImpl implements ConfigGroup { @Override @Transactional public void delete() { -readWriteLock.writeLock().lock(); +
ambari git commit: AMBARI-11744. Ambari Server deadlocks when adding service / adding host. (swagle)
Repository: ambari Updated Branches: refs/heads/trunk cf6cb47c3 - f2e12158f AMBARI-11744. Ambari Server deadlocks when adding service / adding host. (swagle) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f2e12158 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f2e12158 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f2e12158 Branch: refs/heads/trunk Commit: f2e12158f82df38b256ee6b3fcc4989ce6751c5a Parents: cf6cb47 Author: Siddharth Wagle swa...@hortonworks.com Authored: Sat Jun 6 15:47:44 2015 -0700 Committer: Siddharth Wagle swa...@hortonworks.com Committed: Sat Jun 6 15:47:44 2015 -0700 -- .../internal/ConfigGroupResourceProvider.java | 4 +- .../state/configgroup/ConfigGroupImpl.java | 113 ++- 2 files changed, 61 insertions(+), 56 deletions(-) -- http://git-wip-us.apache.org/repos/asf/ambari/blob/f2e12158/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java index 68bad38..2bbb9e7 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java @@ -535,9 +535,7 @@ public class ConfigGroupResourceProvider extends return configGroupResponses; } - private synchronized void updateConfigGroups -(SetConfigGroupRequest requests) throws AmbariException { - + private synchronized void updateConfigGroups (SetConfigGroupRequest requests) throws AmbariException { if (requests.isEmpty()) { LOG.warn(Received an empty requests set); return; http://git-wip-us.apache.org/repos/asf/ambari/blob/f2e12158/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java -- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java index 656c452..6bab661 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/state/configgroup/ConfigGroupImpl.java @@ -317,18 +317,23 @@ public class ConfigGroupImpl implements ConfigGroup { @Override public void persist() { -readWriteLock.writeLock().lock(); +cluster.getClusterGlobalLock().writeLock().lock(); try { - if (!isPersisted) { -persistEntities(); -refresh(); -cluster.refresh(); -isPersisted = true; - } else { -saveIfPersisted(); + readWriteLock.writeLock().lock(); + try { +if (!isPersisted) { + persistEntities(); + refresh(); + cluster.refresh(); + isPersisted = true; +} else { + saveIfPersisted(); +} + } finally { +readWriteLock.writeLock().unlock(); } } finally { - readWriteLock.writeLock().unlock(); + cluster.getClusterGlobalLock().writeLock().unlock(); } } @@ -420,19 +425,11 @@ public class ConfigGroupImpl implements ConfigGroup { clusterConfigEntity.setAttributes(gson.toJson(config.getPropertiesAttributes())); } clusterConfigEntity.setTimestamp(System.currentTimeMillis()); - - - // TODO: Is locking necessary and functional ? - cluster.getClusterGlobalLock().writeLock().lock(); - try { -clusterDAO.createConfig(clusterConfigEntity); -clusterEntity.getClusterConfigEntities().add(clusterConfigEntity); -cluster.addConfig(config); -clusterDAO.merge(clusterEntity); -cluster.refresh(); - } finally { -cluster.getClusterGlobalLock().writeLock().unlock(); - } + clusterDAO.createConfig(clusterConfigEntity); + clusterEntity.getClusterConfigEntities().add(clusterConfigEntity); + cluster.addConfig(config); + clusterDAO.merge(clusterEntity); + cluster.refresh(); } ConfigGroupConfigMappingEntity configMappingEntity = @@ -467,15 +464,20 @@ public class ConfigGroupImpl implements ConfigGroup { @Override @Transactional public void delete() { -readWriteLock.writeLock().lock(); +cluster.getClusterGlobalLock().writeLock().lock();