@Test public void testUpdateAlerts_AtlasAlert() { EasyMockSupport easyMockSupport = new EasyMockSupport(); final AmbariManagementController mockAmbariManagementController = easyMockSupport.createNiceMock(AmbariManagementController.class); final Clusters mockClusters = easyMockSupport.createStrictMock(Clusters.class); final Cluster mockClusterExpected = easyMockSupport.createNiceMock(Cluster.class); final AlertDefinitionDAO mockAlertDefinitionDAO = easyMockSupport.createNiceMock(AlertDefinitionDAO.class); final AlertDefinitionEntity atlasMetadataServerWebUIMock = easyMockSupport.createNiceMock(AlertDefinitionEntity.class); final Injector mockInjector = Guice.createInjector(new AbstractModule() { @Override protected void configure() { bind(AmbariManagementController.class).toInstance(mockAmbariManagementController); bind(Clusters.class).toInstance(mockClusters); bind(EntityManager.class).toInstance(entityManager); bind(AlertDefinitionDAO.class).toInstance(mockAlertDefinitionDAO); bind(DBAccessor.class).toInstance(createNiceMock(DBAccessor.class)); bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class)); } }); long clusterId = 1; expect(mockAmbariManagementController.getClusters()).andReturn(mockClusters).once(); expect(mockClusters.getClusters()).andReturn(new HashMap<String, Cluster>() {{ put("normal", mockClusterExpected); }}).atLeastOnce(); expect(mockClusterExpected.getClusterId()).andReturn(clusterId).anyTimes(); expect(mockAlertDefinitionDAO.findByName(eq(clusterId), eq("metadata_server_webui"))) .andReturn(atlasMetadataServerWebUIMock).atLeastOnce(); expect(atlasMetadataServerWebUIMock.getSource()).andReturn("{\"uri\": {\n" + " \"http\": \"{{hostname}}:{{application-properties/atlas.server.http.port}}\",\n" + " \"https\": \"{{hostname}}:{{application-properties/atlas.server.https.port}}\" } }"); atlasMetadataServerWebUIMock.setSource("{\"uri\":{\"http\":\"{{application-properties/atlas.server.http.port}}\",\"https\":\"{{application-properties/atlas.server.https.port}}\"}}"); expectLastCall().once(); easyMockSupport.replayAll(); mockInjector.getInstance(UpgradeCatalog222.class).updateAlerts(); easyMockSupport.verifyAll(); }
protected void updateAlerts() { LOG.info("Updating alert definitions."); AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); AlertDefinitionDAO alertDefinitionDAO = injector.getInstance(AlertDefinitionDAO.class); Clusters clusters = ambariManagementController.getClusters(); Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters); for (final Cluster cluster : clusterMap.values()) { long clusterID = cluster.getClusterId(); final AlertDefinitionEntity regionserverHealthSummaryDefinitionEntity = alertDefinitionDAO.findByName( clusterID, "regionservers_health_summary"); final AlertDefinitionEntity atsWebAlert = alertDefinitionDAO.findByName( clusterID, "yarn_app_timeline_server_webui"); if (regionserverHealthSummaryDefinitionEntity != null) { alertDefinitionDAO.remove(regionserverHealthSummaryDefinitionEntity); } if (atsWebAlert != null) { String source = atsWebAlert.getSource(); JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject(); JsonObject uriJson = sourceJson.get("uri").getAsJsonObject(); uriJson.remove("http"); uriJson.remove("https"); uriJson.addProperty("http", "{{yarn-site/yarn.timeline-service.webapp.address}}/ws/v1/timeline"); uriJson.addProperty("https", "{{yarn-site/yarn.timeline-service.webapp.https.address}}/ws/v1/timeline"); atsWebAlert.setSource(sourceJson.toString()); alertDefinitionDAO.merge(atsWebAlert); } final AlertDefinitionEntity atlasMetadataServerWebUI = alertDefinitionDAO.findByName( clusterID, "metadata_server_webui"); if (atlasMetadataServerWebUI != null) { String source = atlasMetadataServerWebUI.getSource(); JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject(); JsonObject uriJson = sourceJson.get("uri").getAsJsonObject(); uriJson.remove("http"); uriJson.remove("https"); uriJson.addProperty("http", "{{application-properties/atlas.server.http.port}}"); uriJson.addProperty("https", "{{application-properties/atlas.server.https.port}}"); atlasMetadataServerWebUI.setSource(sourceJson.toString()); alertDefinitionDAO.merge(atlasMetadataServerWebUI); } } }
UpgradeCatalog222 extends AbstractUpgradeCatalog { protected void updateAlerts() { LOG.info("Updating alert definitions."); AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); AlertDefinitionDAO alertDefinitionDAO = injector.getInstance(AlertDefinitionDAO.class); Clusters clusters = ambariManagementController.getClusters(); Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters); for (final Cluster cluster : clusterMap.values()) { long clusterID = cluster.getClusterId(); final AlertDefinitionEntity regionserverHealthSummaryDefinitionEntity = alertDefinitionDAO.findByName( clusterID, "regionservers_health_summary"); final AlertDefinitionEntity atsWebAlert = alertDefinitionDAO.findByName( clusterID, "yarn_app_timeline_server_webui"); if (regionserverHealthSummaryDefinitionEntity != null) { alertDefinitionDAO.remove(regionserverHealthSummaryDefinitionEntity); } if (atsWebAlert != null) { String source = atsWebAlert.getSource(); JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject(); JsonObject uriJson = sourceJson.get("uri").getAsJsonObject(); uriJson.remove("http"); uriJson.remove("https"); uriJson.addProperty("http", "{{yarn-site/yarn.timeline-service.webapp.address}}/ws/v1/timeline"); uriJson.addProperty("https", "{{yarn-site/yarn.timeline-service.webapp.https.address}}/ws/v1/timeline"); atsWebAlert.setSource(sourceJson.toString()); alertDefinitionDAO.merge(atsWebAlert); } final AlertDefinitionEntity atlasMetadataServerWebUI = alertDefinitionDAO.findByName( clusterID, "metadata_server_webui"); if (atlasMetadataServerWebUI != null) { String source = atlasMetadataServerWebUI.getSource(); JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject(); JsonObject uriJson = sourceJson.get("uri").getAsJsonObject(); uriJson.remove("http"); uriJson.remove("https"); uriJson.addProperty("http", "{{application-properties/atlas.server.http.port}}"); uriJson.addProperty("https", "{{application-properties/atlas.server.https.port}}"); atlasMetadataServerWebUI.setSource(sourceJson.toString()); alertDefinitionDAO.merge(atlasMetadataServerWebUI); } } } }
UpgradeCatalog222 extends AbstractUpgradeCatalog { protected void updateAlerts() { LOG.info("Updating alert definitions."); AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); AlertDefinitionDAO alertDefinitionDAO = injector.getInstance(AlertDefinitionDAO.class); Clusters clusters = ambariManagementController.getClusters(); Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters); for (final Cluster cluster : clusterMap.values()) { long clusterID = cluster.getClusterId(); final AlertDefinitionEntity regionserverHealthSummaryDefinitionEntity = alertDefinitionDAO.findByName( clusterID, "regionservers_health_summary"); final AlertDefinitionEntity atsWebAlert = alertDefinitionDAO.findByName( clusterID, "yarn_app_timeline_server_webui"); if (regionserverHealthSummaryDefinitionEntity != null) { alertDefinitionDAO.remove(regionserverHealthSummaryDefinitionEntity); } if (atsWebAlert != null) { String source = atsWebAlert.getSource(); JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject(); JsonObject uriJson = sourceJson.get("uri").getAsJsonObject(); uriJson.remove("http"); uriJson.remove("https"); uriJson.addProperty("http", "{{yarn-site/yarn.timeline-service.webapp.address}}/ws/v1/timeline"); uriJson.addProperty("https", "{{yarn-site/yarn.timeline-service.webapp.https.address}}/ws/v1/timeline"); atsWebAlert.setSource(sourceJson.toString()); alertDefinitionDAO.merge(atsWebAlert); } final AlertDefinitionEntity atlasMetadataServerWebUI = alertDefinitionDAO.findByName( clusterID, "metadata_server_webui"); if (atlasMetadataServerWebUI != null) { String source = atlasMetadataServerWebUI.getSource(); JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject(); JsonObject uriJson = sourceJson.get("uri").getAsJsonObject(); uriJson.remove("http"); uriJson.remove("https"); uriJson.addProperty("http", "{{application-properties/atlas.server.http.port}}"); uriJson.addProperty("https", "{{application-properties/atlas.server.https.port}}"); atlasMetadataServerWebUI.setSource(sourceJson.toString()); alertDefinitionDAO.merge(atlasMetadataServerWebUI); } } } @Inject  UpgradeCatalog222(Injector injector); }
UpgradeCatalog222 extends AbstractUpgradeCatalog { protected void updateAlerts() { LOG.info("Updating alert definitions."); AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); AlertDefinitionDAO alertDefinitionDAO = injector.getInstance(AlertDefinitionDAO.class); Clusters clusters = ambariManagementController.getClusters(); Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters); for (final Cluster cluster : clusterMap.values()) { long clusterID = cluster.getClusterId(); final AlertDefinitionEntity regionserverHealthSummaryDefinitionEntity = alertDefinitionDAO.findByName( clusterID, "regionservers_health_summary"); final AlertDefinitionEntity atsWebAlert = alertDefinitionDAO.findByName( clusterID, "yarn_app_timeline_server_webui"); if (regionserverHealthSummaryDefinitionEntity != null) { alertDefinitionDAO.remove(regionserverHealthSummaryDefinitionEntity); } if (atsWebAlert != null) { String source = atsWebAlert.getSource(); JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject(); JsonObject uriJson = sourceJson.get("uri").getAsJsonObject(); uriJson.remove("http"); uriJson.remove("https"); uriJson.addProperty("http", "{{yarn-site/yarn.timeline-service.webapp.address}}/ws/v1/timeline"); uriJson.addProperty("https", "{{yarn-site/yarn.timeline-service.webapp.https.address}}/ws/v1/timeline"); atsWebAlert.setSource(sourceJson.toString()); alertDefinitionDAO.merge(atsWebAlert); } final AlertDefinitionEntity atlasMetadataServerWebUI = alertDefinitionDAO.findByName( clusterID, "metadata_server_webui"); if (atlasMetadataServerWebUI != null) { String source = atlasMetadataServerWebUI.getSource(); JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject(); JsonObject uriJson = sourceJson.get("uri").getAsJsonObject(); uriJson.remove("http"); uriJson.remove("https"); uriJson.addProperty("http", "{{application-properties/atlas.server.http.port}}"); uriJson.addProperty("https", "{{application-properties/atlas.server.https.port}}"); atlasMetadataServerWebUI.setSource(sourceJson.toString()); alertDefinitionDAO.merge(atlasMetadataServerWebUI); } } } @Inject  UpgradeCatalog222(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); }
UpgradeCatalog222 extends AbstractUpgradeCatalog { protected void updateAlerts() { LOG.info("Updating alert definitions."); AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class); AlertDefinitionDAO alertDefinitionDAO = injector.getInstance(AlertDefinitionDAO.class); Clusters clusters = ambariManagementController.getClusters(); Map<String, Cluster> clusterMap = getCheckedClusterMap(clusters); for (final Cluster cluster : clusterMap.values()) { long clusterID = cluster.getClusterId(); final AlertDefinitionEntity regionserverHealthSummaryDefinitionEntity = alertDefinitionDAO.findByName( clusterID, "regionservers_health_summary"); final AlertDefinitionEntity atsWebAlert = alertDefinitionDAO.findByName( clusterID, "yarn_app_timeline_server_webui"); if (regionserverHealthSummaryDefinitionEntity != null) { alertDefinitionDAO.remove(regionserverHealthSummaryDefinitionEntity); } if (atsWebAlert != null) { String source = atsWebAlert.getSource(); JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject(); JsonObject uriJson = sourceJson.get("uri").getAsJsonObject(); uriJson.remove("http"); uriJson.remove("https"); uriJson.addProperty("http", "{{yarn-site/yarn.timeline-service.webapp.address}}/ws/v1/timeline"); uriJson.addProperty("https", "{{yarn-site/yarn.timeline-service.webapp.https.address}}/ws/v1/timeline"); atsWebAlert.setSource(sourceJson.toString()); alertDefinitionDAO.merge(atsWebAlert); } final AlertDefinitionEntity atlasMetadataServerWebUI = alertDefinitionDAO.findByName( clusterID, "metadata_server_webui"); if (atlasMetadataServerWebUI != null) { String source = atlasMetadataServerWebUI.getSource(); JsonObject sourceJson = new JsonParser().parse(source).getAsJsonObject(); JsonObject uriJson = sourceJson.get("uri").getAsJsonObject(); uriJson.remove("http"); uriJson.remove("https"); uriJson.addProperty("http", "{{application-properties/atlas.server.http.port}}"); uriJson.addProperty("https", "{{application-properties/atlas.server.https.port}}"); atlasMetadataServerWebUI.setSource(sourceJson.toString()); alertDefinitionDAO.merge(atlasMetadataServerWebUI); } } } @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; }