@Test public void testInitializeStromAndKafkaWidgets() throws AmbariException { String stormServiceName = "STORM"; String kafkaServiceName = "KAFKA"; String hbaseServiceName = "HBASE"; final AmbariManagementController controller = createStrictMock(AmbariManagementController.class); final Clusters clusters = createStrictMock(Clusters.class); final Cluster cluster = createStrictMock(Cluster.class); final Service stormService = createStrictMock(Service.class); final Service kafkaService = createStrictMock(Service.class); final Service hbaseService = createStrictMock(Service.class); final Map<String, Cluster> clusterMap = Collections.singletonMap("c1", cluster); final Map<String, Service> services = new TreeMap<>(); services.put(stormServiceName, stormService); services.put(kafkaServiceName, kafkaService); services.put(hbaseServiceName, hbaseService); Module module = new Module() { @Override public void configure(Binder binder) { binder.bind(AmbariManagementController.class).toInstance(controller); binder.bind(Clusters.class).toInstance(clusters); binder.bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class)); binder.bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class)); } }; expect(controller.getClusters()).andReturn(clusters).anyTimes(); expect(clusters.getClusters()).andReturn(clusterMap).anyTimes(); expect(cluster.getServices()).andReturn(services).once(); expect(stormService.getName()).andReturn(stormServiceName).atLeastOnce(); expect(kafkaService.getName()).andReturn(kafkaServiceName).atLeastOnce(); expect(hbaseService.getName()).andReturn(hbaseServiceName).atLeastOnce(); controller.initializeWidgetsAndLayouts(cluster, kafkaService); expectLastCall().once(); controller.initializeWidgetsAndLayouts(cluster, stormService); expectLastCall().once(); replay(controller, clusters, cluster, stormService, kafkaService, hbaseService); Injector injector = Guice.createInjector(module); injector.getInstance(UpgradeCatalog222.class).initializeStromAndKafkaWidgets(); verify(controller, clusters, cluster, stormService, kafkaService, hbaseService); }
protected void initializeStromAndKafkaWidgets() throws AmbariException { AmbariManagementController controller = injector.getInstance(AmbariManagementController.class); Clusters clusters = controller.getClusters(); if (clusters == null) { return; } Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { Map<String, Service> serviceMap = cluster.getServices(); if (serviceMap != null && !serviceMap.isEmpty()) { for (Service service : serviceMap.values()) { if ("STORM".equals(service.getName()) || "KAFKA".equals(service.getName())) { controller.initializeWidgetsAndLayouts(cluster, service); } } } } } }
UpgradeCatalog222 extends AbstractUpgradeCatalog { protected void initializeStromAndKafkaWidgets() throws AmbariException { AmbariManagementController controller = injector.getInstance(AmbariManagementController.class); Clusters clusters = controller.getClusters(); if (clusters == null) { return; } Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { Map<String, Service> serviceMap = cluster.getServices(); if (serviceMap != null && !serviceMap.isEmpty()) { for (Service service : serviceMap.values()) { if ("STORM".equals(service.getName()) || "KAFKA".equals(service.getName())) { controller.initializeWidgetsAndLayouts(cluster, service); } } } } } } }
UpgradeCatalog222 extends AbstractUpgradeCatalog { protected void initializeStromAndKafkaWidgets() throws AmbariException { AmbariManagementController controller = injector.getInstance(AmbariManagementController.class); Clusters clusters = controller.getClusters(); if (clusters == null) { return; } Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { Map<String, Service> serviceMap = cluster.getServices(); if (serviceMap != null && !serviceMap.isEmpty()) { for (Service service : serviceMap.values()) { if ("STORM".equals(service.getName()) || "KAFKA".equals(service.getName())) { controller.initializeWidgetsAndLayouts(cluster, service); } } } } } } @Inject  UpgradeCatalog222(Injector injector); }
UpgradeCatalog222 extends AbstractUpgradeCatalog { protected void initializeStromAndKafkaWidgets() throws AmbariException { AmbariManagementController controller = injector.getInstance(AmbariManagementController.class); Clusters clusters = controller.getClusters(); if (clusters == null) { return; } Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { Map<String, Service> serviceMap = cluster.getServices(); if (serviceMap != null && !serviceMap.isEmpty()) { for (Service service : serviceMap.values()) { if ("STORM".equals(service.getName()) || "KAFKA".equals(service.getName())) { controller.initializeWidgetsAndLayouts(cluster, service); } } } } } } @Inject  UpgradeCatalog222(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); }
UpgradeCatalog222 extends AbstractUpgradeCatalog { protected void initializeStromAndKafkaWidgets() throws AmbariException { AmbariManagementController controller = injector.getInstance(AmbariManagementController.class); Clusters clusters = controller.getClusters(); if (clusters == null) { return; } Map<String, Cluster> clusterMap = clusters.getClusters(); if (clusterMap != null && !clusterMap.isEmpty()) { for (Cluster cluster : clusterMap.values()) { Map<String, Service> serviceMap = cluster.getServices(); if (serviceMap != null && !serviceMap.isEmpty()) { for (Service service : serviceMap.values()) { if ("STORM".equals(service.getName()) || "KAFKA".equals(service.getName())) { controller.initializeWidgetsAndLayouts(cluster, service); } } } } } } @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; }