mirror of
https://github.com/apache/druid.git
synced 2025-02-17 07:25:02 +00:00
Update ambari-metrics-common to version 2.6.1.0.0 (#10165)
* Switch to apache version of ambari-metrics-common * Add test * Fix intellij inspection * Fix intellij inspection
This commit is contained in:
parent
54a8fb827d
commit
b7f4ce70cc
@ -51,7 +51,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.ambari</groupId>
|
||||
<artifactId>ambari-metrics-common</artifactId>
|
||||
<version>2.4.1.0.22</version>
|
||||
<version>2.6.1.0.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
@ -159,12 +159,4 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>hortonworks</id>
|
||||
<name>hortonworks</name>
|
||||
<url>https://repo.hortonworks.com/content/repositories/releases</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
@ -31,6 +31,8 @@ import org.apache.hadoop.metrics2.sink.timeline.AbstractTimelineMetricsSink;
|
||||
import org.apache.hadoop.metrics2.sink.timeline.TimelineMetric;
|
||||
import org.apache.hadoop.metrics2.sink.timeline.TimelineMetrics;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executors;
|
||||
@ -141,9 +143,21 @@ public class AmbariMetricsEmitter extends AbstractTimelineMetricsSink implements
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCollectorUri()
|
||||
protected String getCollectorUri(String host)
|
||||
{
|
||||
return collectorURI;
|
||||
return constructTimelineMetricUri(getCollectorProtocol(), host, getCollectorPort());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCollectorProtocol()
|
||||
{
|
||||
return config.getProtocol();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCollectorPort()
|
||||
{
|
||||
return String.valueOf(config.getPort());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -152,6 +166,25 @@ public class AmbariMetricsEmitter extends AbstractTimelineMetricsSink implements
|
||||
return (int) (DEFAULT_FLUSH_TIMEOUT_MILLIS / 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getZookeeperQuorum()
|
||||
{
|
||||
//Ignoring Zk Fallback.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<String> getConfiguredCollectorHosts()
|
||||
{
|
||||
return Collections.singleton(config.getHostname());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getHostname()
|
||||
{
|
||||
return config.getHostname();
|
||||
}
|
||||
|
||||
private class ConsumerRunnable implements Runnable
|
||||
{
|
||||
@Override
|
||||
|
@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* 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.druid.emitter.ambari.metrics;
|
||||
|
||||
import com.fasterxml.jackson.databind.InjectableValues;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.druid.jackson.DefaultObjectMapper;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class AmbariMetricsEmitterTest
|
||||
{
|
||||
private final ObjectMapper mapper = new DefaultObjectMapper();
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
mapper.setInjectableValues(new InjectableValues.Std().addValue(
|
||||
ObjectMapper.class,
|
||||
new DefaultObjectMapper()
|
||||
));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerDeAmbariMetricsEmitterConfig()
|
||||
{
|
||||
AmbariMetricsEmitterConfig config = new AmbariMetricsEmitterConfig(
|
||||
"hostname",
|
||||
8080,
|
||||
"http",
|
||||
"truststore.path",
|
||||
"truststore.type",
|
||||
"truststore.password",
|
||||
1000,
|
||||
1000L,
|
||||
100,
|
||||
new SendAllTimelineEventConverter("prefix", "druid"),
|
||||
Collections.emptyList(),
|
||||
500L,
|
||||
400L
|
||||
);
|
||||
AmbariMetricsEmitter emitter = new AmbariMetricsEmitter(config, Collections.emptyList());
|
||||
Assert.assertEquals("8080", emitter.getCollectorPort());
|
||||
Assert.assertEquals("http", emitter.getCollectorProtocol());
|
||||
Assert.assertEquals("http://myHost:8080/ws/v1/timeline/metrics", emitter.getCollectorUri("myHost"));
|
||||
Assert.assertEquals("hostname", emitter.getHostname());
|
||||
Assert.assertNull(emitter.getZookeeperQuorum());
|
||||
Assert.assertEquals(Collections.singleton("hostname"), emitter.getConfiguredCollectorHosts());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user