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 2016/03/14 15:08:30 UTC
[1/2] ambari git commit: AMBARI-15391. Ambari upgrade to 2.2.2 failed
(aonishuk)
Repository: ambari
Updated Branches:
refs/heads/branch-2.2 1760ef283 -> e1b90e838
refs/heads/trunk 3b3c66046 -> 070babc0f
AMBARI-15391. Ambari upgrade to 2.2.2 failed (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/070babc0
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/070babc0
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/070babc0
Branch: refs/heads/trunk
Commit: 070babc0f023c7ce1e1abced20bdf78a139f3542
Parents: 3b3c660
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Mon Mar 14 16:08:22 2016 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Mon Mar 14 16:08:22 2016 +0200
----------------------------------------------------------------------
.../server/upgrade/UpgradeCatalog222.java | 16 ++++--
.../server/upgrade/UpgradeCatalog222Test.java | 52 +++++++++++++++++++-
2 files changed, 62 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/070babc0/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
index b3ae237..b79d778 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
@@ -381,11 +381,21 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
for (final Cluster cluster : clusterMap.values()) {
long clusterID = cluster.getClusterId();
+ StackId stackId = cluster.getDesiredStackVersion();
+ Map<String, Object> widgetDescriptor = null;
+ StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(), stackId.getStackVersion());
+ ServiceInfo serviceInfo = stackInfo.getService("HDFS");
+ if (serviceInfo == null) {
+ LOG.info("Skipping updating HDFS widget definition, because HDFS service is not present in cluster " +
+ "cluster_name= " + cluster.getClusterName());
+ continue;
+ }
+
for (String widgetName : HDFS_WIDGETS_TO_UPDATE) {
List<WidgetEntity> widgetEntities = widgetDAO.findByName(clusterID,
widgetName, "ambari", "HDFS_SUMMARY");
- if (widgetEntities != null) {
+ if (widgetEntities != null && widgetEntities.size() > 0) {
WidgetEntity entityToUpdate = null;
if (widgetEntities.size() > 1) {
LOG.info("Found more that 1 entity with name = "+ widgetName +
@@ -397,10 +407,6 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
LOG.info("Updating widget: " + entityToUpdate.getWidgetName());
// Get the definition from widgets.json file
WidgetLayoutInfo targetWidgetLayoutInfo = null;
- StackId stackId = cluster.getDesiredStackVersion();
- Map<String, Object> widgetDescriptor = null;
- StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(), stackId.getStackVersion());
- ServiceInfo serviceInfo = stackInfo.getService("HDFS");
File widgetDescriptorFile = serviceInfo.getWidgetsDescriptorFile();
if (widgetDescriptorFile != null && widgetDescriptorFile.exists()) {
try {
http://git-wip-us.apache.org/repos/asf/ambari/blob/070babc0/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
index 2c09aa8..cae6d96 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
@@ -353,6 +353,56 @@ public class UpgradeCatalog222Test {
}
@Test
+ public void testHDFSWidgetUpdateWithOnlyZkService() throws Exception {
+ final Clusters clusters = createNiceMock(Clusters.class);
+ final Cluster cluster = createNiceMock(Cluster.class);
+ final AmbariManagementController controller = createNiceMock(AmbariManagementController.class);
+ final Gson gson = new Gson();
+ final WidgetDAO widgetDAO = createNiceMock(WidgetDAO.class);
+ final AmbariMetaInfo metaInfo = createNiceMock(AmbariMetaInfo.class);
+ StackInfo stackInfo = createNiceMock(StackInfo.class);
+ StackId stackId = new StackId("HDP", "2.0.0");
+
+ String widgetStr = "{\"layouts\":[{\"layout_name\":\"default_hdfs_dashboard\",\"display_name\":\"Standard HDFS Dashboard\",\"section_name\":\"HDFS_SUMMARY\",\"widgetLayoutInfo\":[{\"widget_name\":\"NameNode RPC\",\"metrics\":[],\"values\":[]}]}]}";
+
+ File dataDirectory = temporaryFolder.newFolder();
+ File file = new File(dataDirectory, "hdfs_widget.json");
+ FileUtils.writeStringToFile(file, widgetStr);
+
+ final Injector mockInjector = Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ bind(EntityManager.class).toInstance(createNiceMock(EntityManager.class));
+ bind(AmbariManagementController.class).toInstance(controller);
+ bind(Clusters.class).toInstance(clusters);
+ bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
+ bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+ bind(Gson.class).toInstance(gson);
+ bind(WidgetDAO.class).toInstance(widgetDAO);
+ bind(StackManagerFactory.class).toInstance(createNiceMock(StackManagerFactory.class));
+ bind(AmbariMetaInfo.class).toInstance(metaInfo);
+ }
+ });
+ expect(controller.getClusters()).andReturn(clusters).anyTimes();
+ expect(clusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
+ put("normal", cluster);
+ }}).anyTimes();
+ expect(cluster.getClusterId()).andReturn(1L).anyTimes();
+ expect(stackInfo.getService("HDFS")).andReturn(null);
+ expect(cluster.getDesiredStackVersion()).andReturn(stackId);
+ expect(metaInfo.getStack("HDP", "2.0.0")).andReturn(stackInfo);
+
+ replay(clusters, cluster, controller, widgetDAO, metaInfo, stackInfo);
+
+ UpgradeCatalog222 upgradeCatalog222 = createMockBuilder(UpgradeCatalog222.class)
+ .withConstructor(Injector.class)
+ .withArgs(mockInjector)
+ .createMock();
+ upgradeCatalog222.updateHDFSWidgetDefinition();
+
+ }
+
+ @Test
public void testHDFSWidgetUpdate() throws Exception {
final Clusters clusters = createNiceMock(Clusters.class);
final Cluster cluster = createNiceMock(Cluster.class);
@@ -390,11 +440,11 @@ public class UpgradeCatalog222Test {
put("normal", cluster);
}}).anyTimes();
expect(cluster.getClusterId()).andReturn(1L).anyTimes();
+ expect(stackInfo.getService("HDFS")).andReturn(serviceInfo);
expect(widgetDAO.findByName(1L, "NameNode RPC", "ambari", "HDFS_SUMMARY"))
.andReturn(Collections.singletonList(widgetEntity));
expect(cluster.getDesiredStackVersion()).andReturn(stackId);
expect(metaInfo.getStack("HDP", "2.0.0")).andReturn(stackInfo);
- expect(stackInfo.getService("HDFS")).andReturn(serviceInfo);
expect(serviceInfo.getWidgetsDescriptorFile()).andReturn(file);
expect(widgetDAO.merge(widgetEntity)).andReturn(null);
expect(widgetEntity.getWidgetName()).andReturn("Namenode RPC").anyTimes();
[2/2] ambari git commit: AMBARI-15391. Ambari upgrade to 2.2.2 failed
(aonishuk)
Posted by ao...@apache.org.
AMBARI-15391. Ambari upgrade to 2.2.2 failed (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e1b90e83
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e1b90e83
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e1b90e83
Branch: refs/heads/branch-2.2
Commit: e1b90e838730878a95370394b585af50cb7a2c20
Parents: 1760ef2
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Mon Mar 14 16:08:25 2016 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Mon Mar 14 16:08:25 2016 +0200
----------------------------------------------------------------------
.../server/upgrade/UpgradeCatalog222.java | 16 ++++--
.../server/upgrade/UpgradeCatalog222Test.java | 52 +++++++++++++++++++-
2 files changed, 62 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1b90e83/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
index b3ae237..b79d778 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog222.java
@@ -381,11 +381,21 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
for (final Cluster cluster : clusterMap.values()) {
long clusterID = cluster.getClusterId();
+ StackId stackId = cluster.getDesiredStackVersion();
+ Map<String, Object> widgetDescriptor = null;
+ StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(), stackId.getStackVersion());
+ ServiceInfo serviceInfo = stackInfo.getService("HDFS");
+ if (serviceInfo == null) {
+ LOG.info("Skipping updating HDFS widget definition, because HDFS service is not present in cluster " +
+ "cluster_name= " + cluster.getClusterName());
+ continue;
+ }
+
for (String widgetName : HDFS_WIDGETS_TO_UPDATE) {
List<WidgetEntity> widgetEntities = widgetDAO.findByName(clusterID,
widgetName, "ambari", "HDFS_SUMMARY");
- if (widgetEntities != null) {
+ if (widgetEntities != null && widgetEntities.size() > 0) {
WidgetEntity entityToUpdate = null;
if (widgetEntities.size() > 1) {
LOG.info("Found more that 1 entity with name = "+ widgetName +
@@ -397,10 +407,6 @@ public class UpgradeCatalog222 extends AbstractUpgradeCatalog {
LOG.info("Updating widget: " + entityToUpdate.getWidgetName());
// Get the definition from widgets.json file
WidgetLayoutInfo targetWidgetLayoutInfo = null;
- StackId stackId = cluster.getDesiredStackVersion();
- Map<String, Object> widgetDescriptor = null;
- StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(), stackId.getStackVersion());
- ServiceInfo serviceInfo = stackInfo.getService("HDFS");
File widgetDescriptorFile = serviceInfo.getWidgetsDescriptorFile();
if (widgetDescriptorFile != null && widgetDescriptorFile.exists()) {
try {
http://git-wip-us.apache.org/repos/asf/ambari/blob/e1b90e83/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
index 3712994..091cad9 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog222Test.java
@@ -354,6 +354,56 @@ public class UpgradeCatalog222Test {
}
@Test
+ public void testHDFSWidgetUpdateWithOnlyZkService() throws Exception {
+ final Clusters clusters = createNiceMock(Clusters.class);
+ final Cluster cluster = createNiceMock(Cluster.class);
+ final AmbariManagementController controller = createNiceMock(AmbariManagementController.class);
+ final Gson gson = new Gson();
+ final WidgetDAO widgetDAO = createNiceMock(WidgetDAO.class);
+ final AmbariMetaInfo metaInfo = createNiceMock(AmbariMetaInfo.class);
+ StackInfo stackInfo = createNiceMock(StackInfo.class);
+ StackId stackId = new StackId("HDP", "2.0.0");
+
+ String widgetStr = "{\"layouts\":[{\"layout_name\":\"default_hdfs_dashboard\",\"display_name\":\"Standard HDFS Dashboard\",\"section_name\":\"HDFS_SUMMARY\",\"widgetLayoutInfo\":[{\"widget_name\":\"NameNode RPC\",\"metrics\":[],\"values\":[]}]}]}";
+
+ File dataDirectory = temporaryFolder.newFolder();
+ File file = new File(dataDirectory, "hdfs_widget.json");
+ FileUtils.writeStringToFile(file, widgetStr);
+
+ final Injector mockInjector = Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ bind(EntityManager.class).toInstance(createNiceMock(EntityManager.class));
+ bind(AmbariManagementController.class).toInstance(controller);
+ bind(Clusters.class).toInstance(clusters);
+ bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class));
+ bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
+ bind(Gson.class).toInstance(gson);
+ bind(WidgetDAO.class).toInstance(widgetDAO);
+ bind(StackManagerFactory.class).toInstance(createNiceMock(StackManagerFactory.class));
+ bind(AmbariMetaInfo.class).toInstance(metaInfo);
+ }
+ });
+ expect(controller.getClusters()).andReturn(clusters).anyTimes();
+ expect(clusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{
+ put("normal", cluster);
+ }}).anyTimes();
+ expect(cluster.getClusterId()).andReturn(1L).anyTimes();
+ expect(stackInfo.getService("HDFS")).andReturn(null);
+ expect(cluster.getDesiredStackVersion()).andReturn(stackId);
+ expect(metaInfo.getStack("HDP", "2.0.0")).andReturn(stackInfo);
+
+ replay(clusters, cluster, controller, widgetDAO, metaInfo, stackInfo);
+
+ UpgradeCatalog222 upgradeCatalog222 = createMockBuilder(UpgradeCatalog222.class)
+ .withConstructor(Injector.class)
+ .withArgs(mockInjector)
+ .createMock();
+ upgradeCatalog222.updateHDFSWidgetDefinition();
+
+ }
+
+ @Test
public void testHDFSWidgetUpdate() throws Exception {
final Clusters clusters = createNiceMock(Clusters.class);
final Cluster cluster = createNiceMock(Cluster.class);
@@ -391,11 +441,11 @@ public class UpgradeCatalog222Test {
put("normal", cluster);
}}).anyTimes();
expect(cluster.getClusterId()).andReturn(1L).anyTimes();
+ expect(stackInfo.getService("HDFS")).andReturn(serviceInfo);
expect(widgetDAO.findByName(1L, "NameNode RPC", "ambari", "HDFS_SUMMARY"))
.andReturn(Collections.singletonList(widgetEntity));
expect(cluster.getDesiredStackVersion()).andReturn(stackId);
expect(metaInfo.getStack("HDP", "2.0.0")).andReturn(stackInfo);
- expect(stackInfo.getService("HDFS")).andReturn(serviceInfo);
expect(serviceInfo.getWidgetsDescriptorFile()).andReturn(file);
expect(widgetDAO.merge(widgetEntity)).andReturn(null);
expect(widgetEntity.getWidgetName()).andReturn("Namenode RPC").anyTimes();