Repository: ambari Updated Branches: refs/heads/branch-2.4 9987b97e9 -> 8ddb42740
Fix issues in Revert AMS-HA commit (avijayan) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8ddb4274 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8ddb4274 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8ddb4274 Branch: refs/heads/branch-2.4 Commit: 8ddb4274070ac4cde09a3799cb3e0deede92fbd7 Parents: 342c510 Author: Aravindan Vijayan <[email protected]> Authored: Thu May 19 13:44:19 2016 -0700 Committer: Aravindan Vijayan <[email protected]> Committed: Thu May 19 13:44:25 2016 -0700 ---------------------------------------------------------------------- .../TimelineMetricHAControllerTest.java | 107 ------------------- 1 file changed, 107 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/8ddb4274/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/availability/TimelineMetricHAControllerTest.java ---------------------------------------------------------------------- diff --git a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/availability/TimelineMetricHAControllerTest.java b/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/availability/TimelineMetricHAControllerTest.java deleted file mode 100644 index ecfa6bd..0000000 --- a/ambari-metrics/ambari-metrics-timelineservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/metrics/timeline/availability/TimelineMetricHAControllerTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * <p/> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p/> - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.availability; - -import junit.framework.Assert; -import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.AbstractMiniHBaseClusterTest; -import org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.TimelineMetricConfiguration; -import org.apache.helix.HelixManager; -import org.apache.helix.HelixManagerFactory; -import org.apache.helix.InstanceType; -import org.apache.helix.model.ExternalView; -import org.apache.helix.model.InstanceConfig; -import org.junit.Before; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.availability.TimelineMetricHAController.CLUSTER_NAME; -import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.availability.TimelineMetricHAController.METRIC_AGGREGATORS; -import static org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.availability.TimelineMetricHAController.STATE_MODEL_NAME; -import static org.easymock.EasyMock.createNiceMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; - -public class TimelineMetricHAControllerTest extends AbstractMiniHBaseClusterTest { - TimelineMetricConfiguration configuration; - - @Before - public void setup() throws Exception { - configuration = createNiceMock(TimelineMetricConfiguration.class); - - expect(configuration.getInstanceHostnameFromEnv()).andReturn("h1"); - expect(configuration.getInstancePort()).andReturn("12000"); - // jdbc:phoenix:localhost:52887:/hbase;test=true - String zkUrl = getUrl(); - String port = zkUrl.split(":")[3]; - String quorum = zkUrl.split(":")[2]; - - expect(configuration.getZKClientPort()).andReturn(port); - expect(configuration.getZKQuorum()).andReturn(quorum); - - replay(configuration); - } - - @Test(timeout = 180000) - public void testHAControllerDistributedAggregation() throws Exception { - TimelineMetricHAController haController = new TimelineMetricHAController(configuration); - haController.initializeHAController(); - // Wait for task assignment - Thread.sleep(10000); - - Assert.assertTrue(haController.isInitialized()); - Assert.assertEquals(1, haController.getLiveInstanceHostNames().size()); - Assert.assertTrue(haController.getAggregationTaskRunner().performsClusterAggregation()); - Assert.assertTrue(haController.getAggregationTaskRunner().performsHostAggregation()); - - // Add new instance - InstanceConfig instanceConfig2 = new InstanceConfig("h2_12001"); - haController.admin.addInstance(CLUSTER_NAME, instanceConfig2); - HelixManager manager2 = HelixManagerFactory.getZKHelixManager(CLUSTER_NAME, - instanceConfig2.getInstanceName(), - InstanceType.PARTICIPANT, haController.zkConnectUrl); - manager2.getStateMachineEngine().registerStateModelFactory(STATE_MODEL_NAME, - new OnlineOfflineStateModelFactory(instanceConfig2.getInstanceName(), - new AggregationTaskRunner(instanceConfig2.getInstanceName(), ""))); - manager2.connect(); - haController.admin.rebalance(CLUSTER_NAME, METRIC_AGGREGATORS, 1); - - // Wait on re-assignment of partitions - Thread.sleep(10000); - Assert.assertEquals(2, haController.getLiveInstanceHostNames().size()); - - ExternalView view = haController.admin.getResourceExternalView(CLUSTER_NAME, METRIC_AGGREGATORS); - - Map<String, String> partitionInstanceMap = new HashMap<>(); - - for (String partition : view.getPartitionSet()) { - Map<String, String> states = view.getStateMap(partition); - // (instance, state) pairs - for (Map.Entry<String, String> stateEntry : states.entrySet()) { - partitionInstanceMap.put(partition, stateEntry.getKey()); - Assert.assertEquals("ONLINE", stateEntry.getValue()); - } - } - // Re-assigned partitions - Assert.assertEquals(2, partitionInstanceMap.size()); - - haController.getAggregationTaskRunner().stop(); - haController.manager.disconnect(); - } -}
