@Test public void testYARNWidgetUpdate() 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); WidgetEntity widgetEntity = createNiceMock(WidgetEntity.class); WidgetEntity widgetEntity2 = createNiceMock(WidgetEntity.class); StackId stackId = new StackId("HDP", "2.0.0"); StackInfo stackInfo = createNiceMock(StackInfo.class); ServiceInfo serviceInfo = createNiceMock(ServiceInfo.class); String widgetStr = "{\n" + " \"layouts\": [\n" + " {\n" + " \"layout_name\": \"default_yarn_dashboard\",\n" + " \"display_name\": \"Standard YARN Dashboard\",\n" + " \"section_name\": \"YARN_SUMMARY\",\n" + " \"widgetLayoutInfo\": [\n" + " {\n" + " \"widget_name\": \"Container Failures\",\n" + " \"metrics\": [],\n" + " \"values\": []\n" + " }\n" + " ]\n" + " },\n" + " {\n" + " \"layout_name\": \"default_yarn_heatmap\",\n" + " \"display_name\": \"Standard YARN HeatMaps\",\n" + " \"section_name\": \"YARN_HEATMAPS\",\n" + " \"widgetLayoutInfo\": [\n" + " {\n" + " \"widget_name\": \"Container Failures\",\n" + " \"metrics\": [],\n" + " \"values\": []\n" + " }\n" + " ]\n" + " }\n" + " ]\n" + "}"; File dataDirectory = temporaryFolder.newFolder(); File file = new File(dataDirectory, "yarn_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("YARN")).andReturn(serviceInfo); expect(cluster.getDesiredStackVersion()).andReturn(stackId).anyTimes(); expect(metaInfo.getStack("HDP", "2.0.0")).andReturn(stackInfo).anyTimes(); expect(serviceInfo.getWidgetsDescriptorFile()).andReturn(file).anyTimes(); expect(widgetDAO.findByName(1L, "Container Failures", "ambari", "YARN_SUMMARY")) .andReturn(Collections.singletonList(widgetEntity)); expect(widgetDAO.merge(widgetEntity)).andReturn(null); expect(widgetEntity.getWidgetName()).andReturn("Container Failures").anyTimes(); expect(widgetDAO.findByName(1L, "Container Failures", "ambari", "YARN_HEATMAPS")) .andReturn(Collections.singletonList(widgetEntity2)); expect(widgetDAO.merge(widgetEntity2)).andReturn(null); expect(widgetEntity2.getWidgetName()).andReturn("Container Failures").anyTimes(); replay(clusters, cluster, controller, widgetDAO, metaInfo, widgetEntity, widgetEntity2, stackInfo, serviceInfo); mockInjector.getInstance(UpgradeCatalog222.class).updateYARNWidgetDefinition(); verify(clusters, cluster, controller, widgetDAO, widgetEntity, widgetEntity2, stackInfo, serviceInfo); }
protected void updateYARNWidgetDefinition() throws AmbariException { LOG.info("Updating YARN widget definition."); Map<String, List<String>> widgetMap = new HashMap<>(); Map<String, String> sectionLayoutMap = new HashMap<>(); List<String> yarnSummaryWidgets = new ArrayList<>(Arrays.asList("Container Failures", "App Failures", "Cluster Memory")); widgetMap.put("YARN_SUMMARY", yarnSummaryWidgets); sectionLayoutMap.put("YARN_SUMMARY", "default_yarn_dashboard"); List<String> yarnHeatmapWidgets = new ArrayList<>(Arrays.asList("Container Failures")); widgetMap.put("YARN_HEATMAPS", yarnHeatmapWidgets); sectionLayoutMap.put("YARN_HEATMAPS", "default_yarn_heatmap"); updateWidgetDefinitionsForService("YARN", widgetMap, sectionLayoutMap); }
UpgradeCatalog222 extends AbstractUpgradeCatalog { protected void updateYARNWidgetDefinition() throws AmbariException { LOG.info("Updating YARN widget definition."); Map<String, List<String>> widgetMap = new HashMap<>(); Map<String, String> sectionLayoutMap = new HashMap<>(); List<String> yarnSummaryWidgets = new ArrayList<>(Arrays.asList("Container Failures", "App Failures", "Cluster Memory")); widgetMap.put("YARN_SUMMARY", yarnSummaryWidgets); sectionLayoutMap.put("YARN_SUMMARY", "default_yarn_dashboard"); List<String> yarnHeatmapWidgets = new ArrayList<>(Arrays.asList("Container Failures")); widgetMap.put("YARN_HEATMAPS", yarnHeatmapWidgets); sectionLayoutMap.put("YARN_HEATMAPS", "default_yarn_heatmap"); updateWidgetDefinitionsForService("YARN", widgetMap, sectionLayoutMap); } }
UpgradeCatalog222 extends AbstractUpgradeCatalog { protected void updateYARNWidgetDefinition() throws AmbariException { LOG.info("Updating YARN widget definition."); Map<String, List<String>> widgetMap = new HashMap<>(); Map<String, String> sectionLayoutMap = new HashMap<>(); List<String> yarnSummaryWidgets = new ArrayList<>(Arrays.asList("Container Failures", "App Failures", "Cluster Memory")); widgetMap.put("YARN_SUMMARY", yarnSummaryWidgets); sectionLayoutMap.put("YARN_SUMMARY", "default_yarn_dashboard"); List<String> yarnHeatmapWidgets = new ArrayList<>(Arrays.asList("Container Failures")); widgetMap.put("YARN_HEATMAPS", yarnHeatmapWidgets); sectionLayoutMap.put("YARN_HEATMAPS", "default_yarn_heatmap"); updateWidgetDefinitionsForService("YARN", widgetMap, sectionLayoutMap); } @Inject  UpgradeCatalog222(Injector injector); }
UpgradeCatalog222 extends AbstractUpgradeCatalog { protected void updateYARNWidgetDefinition() throws AmbariException { LOG.info("Updating YARN widget definition."); Map<String, List<String>> widgetMap = new HashMap<>(); Map<String, String> sectionLayoutMap = new HashMap<>(); List<String> yarnSummaryWidgets = new ArrayList<>(Arrays.asList("Container Failures", "App Failures", "Cluster Memory")); widgetMap.put("YARN_SUMMARY", yarnSummaryWidgets); sectionLayoutMap.put("YARN_SUMMARY", "default_yarn_dashboard"); List<String> yarnHeatmapWidgets = new ArrayList<>(Arrays.asList("Container Failures")); widgetMap.put("YARN_HEATMAPS", yarnHeatmapWidgets); sectionLayoutMap.put("YARN_HEATMAPS", "default_yarn_heatmap"); updateWidgetDefinitionsForService("YARN", widgetMap, sectionLayoutMap); } @Inject  UpgradeCatalog222(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); }
UpgradeCatalog222 extends AbstractUpgradeCatalog { protected void updateYARNWidgetDefinition() throws AmbariException { LOG.info("Updating YARN widget definition."); Map<String, List<String>> widgetMap = new HashMap<>(); Map<String, String> sectionLayoutMap = new HashMap<>(); List<String> yarnSummaryWidgets = new ArrayList<>(Arrays.asList("Container Failures", "App Failures", "Cluster Memory")); widgetMap.put("YARN_SUMMARY", yarnSummaryWidgets); sectionLayoutMap.put("YARN_SUMMARY", "default_yarn_dashboard"); List<String> yarnHeatmapWidgets = new ArrayList<>(Arrays.asList("Container Failures")); widgetMap.put("YARN_HEATMAPS", yarnHeatmapWidgets); sectionLayoutMap.put("YARN_HEATMAPS", "default_yarn_heatmap"); updateWidgetDefinitionsForService("YARN", widgetMap, sectionLayoutMap); } @Inject  UpgradeCatalog222(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); static final String PRECISION_TABLE_TTL_PROPERTY; static final String CLUSTER_SECOND_TABLE_TTL_PROPERTY; static final String CLUSTER_MINUTE_TABLE_TTL_PROPERTY; static final String AMS_WEBAPP_ADDRESS_PROPERTY; static final String HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD_PROPERTY; static final String HBASE_RPC_TIMEOUT_PROPERTY; static final String PHOENIX_QUERY_TIMEOUT_PROPERTY; static final String PHOENIX_QUERY_KEEPALIVE_PROPERTY; static final String TIMELINE_METRICS_CLUSTER_AGGREGATOR_INTERPOLATION_ENABLED; static final String TIMELINE_METRICS_SINK_COLLECTION_PERIOD; static final String AMS_SERVICE_NAME; static final String AMS_COLLECTOR_COMPONENT_NAME; final static String HBASE_SITE_HBASE_COPROCESSOR_MASTER_CLASSES; final static String HBASE_SITE_HBASE_COPROCESSOR_REGION_CLASSES; final static String HBASE_SITE_HBASE_COPROCESSOR_REGIONSERVER_CLASSES; }