YARN-1850. Introduced the ability to optionally disable sending out timeline-events in the TimelineClient. Contributed by Zhijie Shen.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1581189 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9db6f98e0b
commit
09f383254c
|
@ -323,6 +323,9 @@ Release 2.4.0 - UNRELEASED
|
||||||
YARN-1536. Cleanup: Get rid of ResourceManager#get*SecretManager() methods
|
YARN-1536. Cleanup: Get rid of ResourceManager#get*SecretManager() methods
|
||||||
and use the RMContext methods instead. (Anubhav Dhoot via kasha)
|
and use the RMContext methods instead. (Anubhav Dhoot via kasha)
|
||||||
|
|
||||||
|
YARN-1850. Introduced the ability to optionally disable sending out timeline-
|
||||||
|
events in the TimelineClient. (Zhijie Shen via vinodkv)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
YARN-1771. Reduce the number of NameNode operations during localization of
|
YARN-1771. Reduce the number of NameNode operations during localization of
|
||||||
|
|
|
@ -1095,6 +1095,11 @@ public class YarnConfiguration extends Configuration {
|
||||||
public static final String DEFAULT_FS_APPLICATION_HISTORY_STORE_COMPRESSION_TYPE =
|
public static final String DEFAULT_FS_APPLICATION_HISTORY_STORE_COMPRESSION_TYPE =
|
||||||
"none";
|
"none";
|
||||||
|
|
||||||
|
/** The setting that controls whether timeline service is enabled or not. */
|
||||||
|
public static final String TIMELINE_SERVICE_ENABLED =
|
||||||
|
TIMELINE_SERVICE_PREFIX + "enabled";
|
||||||
|
public static final boolean DEFAULT_TIMELINE_SERVICE_ENABLED = true;
|
||||||
|
|
||||||
/** host:port address for timeline service RPC APIs. */
|
/** host:port address for timeline service RPC APIs. */
|
||||||
public static final String TIMELINE_SERVICE_ADDRESS =
|
public static final String TIMELINE_SERVICE_ADDRESS =
|
||||||
TIMELINE_SERVICE_PREFIX + "address";
|
TIMELINE_SERVICE_PREFIX + "address";
|
||||||
|
|
|
@ -55,6 +55,7 @@ public class TimelineClientImpl extends TimelineClient {
|
||||||
|
|
||||||
private Client client;
|
private Client client;
|
||||||
private URI resURI;
|
private URI resURI;
|
||||||
|
private boolean isEnabled;
|
||||||
|
|
||||||
public TimelineClientImpl() {
|
public TimelineClientImpl() {
|
||||||
super(TimelineClientImpl.class.getName());
|
super(TimelineClientImpl.class.getName());
|
||||||
|
@ -64,24 +65,38 @@ public class TimelineClientImpl extends TimelineClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void serviceInit(Configuration conf) throws Exception {
|
protected void serviceInit(Configuration conf) throws Exception {
|
||||||
if (YarnConfiguration.useHttps(conf)) {
|
isEnabled = conf.getBoolean(
|
||||||
resURI = URI
|
YarnConfiguration.TIMELINE_SERVICE_ENABLED,
|
||||||
.create(JOINER.join("https://", conf.get(
|
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_ENABLED);
|
||||||
YarnConfiguration.TIMELINE_SERVICE_WEBAPP_HTTPS_ADDRESS,
|
if (!isEnabled) {
|
||||||
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_WEBAPP_HTTPS_ADDRESS),
|
LOG.info("Timeline service is not enabled");
|
||||||
RESOURCE_URI_STR));
|
|
||||||
} else {
|
} else {
|
||||||
resURI = URI.create(JOINER.join("http://", conf.get(
|
if (YarnConfiguration.useHttps(conf)) {
|
||||||
YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS,
|
resURI = URI
|
||||||
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_WEBAPP_ADDRESS), RESOURCE_URI_STR));
|
.create(JOINER.join("https://", conf.get(
|
||||||
|
YarnConfiguration.TIMELINE_SERVICE_WEBAPP_HTTPS_ADDRESS,
|
||||||
|
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_WEBAPP_HTTPS_ADDRESS),
|
||||||
|
RESOURCE_URI_STR));
|
||||||
|
} else {
|
||||||
|
resURI = URI.create(JOINER.join("http://", conf.get(
|
||||||
|
YarnConfiguration.TIMELINE_SERVICE_WEBAPP_ADDRESS,
|
||||||
|
YarnConfiguration.DEFAULT_TIMELINE_SERVICE_WEBAPP_ADDRESS),
|
||||||
|
RESOURCE_URI_STR));
|
||||||
|
}
|
||||||
|
LOG.info("Timeline service address: " + resURI);
|
||||||
}
|
}
|
||||||
LOG.info("Timeline service address: " + resURI);
|
|
||||||
super.serviceInit(conf);
|
super.serviceInit(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TimelinePutResponse putEntities(
|
public TimelinePutResponse putEntities(
|
||||||
TimelineEntity... entities) throws IOException, YarnException {
|
TimelineEntity... entities) throws IOException, YarnException {
|
||||||
|
if (!isEnabled) {
|
||||||
|
if (LOG.isDebugEnabled()) {
|
||||||
|
LOG.debug("Nothing will be put because timeline service is not enabled");
|
||||||
|
}
|
||||||
|
return new TimelinePutResponse();
|
||||||
|
}
|
||||||
TimelineEntities entitiesContainer = new TimelineEntities();
|
TimelineEntities entitiesContainer = new TimelineEntities();
|
||||||
entitiesContainer.addEntities(Arrays.asList(entities));
|
entitiesContainer.addEntities(Arrays.asList(entities));
|
||||||
ClientResponse resp;
|
ClientResponse resp;
|
||||||
|
|
|
@ -49,19 +49,19 @@ public class TestTimelineClient {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
client = spy((TimelineClientImpl) TimelineClient.createTimelineClient());
|
client = createTimelineClient(new YarnConfiguration());
|
||||||
client.init(new YarnConfiguration());
|
|
||||||
client.start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
client.stop();
|
if (client != null) {
|
||||||
|
client.stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPostEntities() throws Exception {
|
public void testPostEntities() throws Exception {
|
||||||
mockClientResponse(ClientResponse.Status.OK, false, false);
|
mockClientResponse(client, ClientResponse.Status.OK, false, false);
|
||||||
try {
|
try {
|
||||||
TimelinePutResponse response = client.putEntities(generateEntity());
|
TimelinePutResponse response = client.putEntities(generateEntity());
|
||||||
Assert.assertEquals(0, response.getErrors().size());
|
Assert.assertEquals(0, response.getErrors().size());
|
||||||
|
@ -72,7 +72,7 @@ public class TestTimelineClient {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPostEntitiesWithError() throws Exception {
|
public void testPostEntitiesWithError() throws Exception {
|
||||||
mockClientResponse(ClientResponse.Status.OK, true, false);
|
mockClientResponse(client, ClientResponse.Status.OK, true, false);
|
||||||
try {
|
try {
|
||||||
TimelinePutResponse response = client.putEntities(generateEntity());
|
TimelinePutResponse response = client.putEntities(generateEntity());
|
||||||
Assert.assertEquals(1, response.getErrors().size());
|
Assert.assertEquals(1, response.getErrors().size());
|
||||||
|
@ -90,7 +90,7 @@ public class TestTimelineClient {
|
||||||
@Test
|
@Test
|
||||||
public void testPostEntitiesNoResponse() throws Exception {
|
public void testPostEntitiesNoResponse() throws Exception {
|
||||||
mockClientResponse(
|
mockClientResponse(
|
||||||
ClientResponse.Status.INTERNAL_SERVER_ERROR, false, false);
|
client, ClientResponse.Status.INTERNAL_SERVER_ERROR, false, false);
|
||||||
try {
|
try {
|
||||||
client.putEntities(generateEntity());
|
client.putEntities(generateEntity());
|
||||||
Assert.fail("Exception is expected");
|
Assert.fail("Exception is expected");
|
||||||
|
@ -102,7 +102,7 @@ public class TestTimelineClient {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPostEntitiesConnectionRefused() throws Exception {
|
public void testPostEntitiesConnectionRefused() throws Exception {
|
||||||
mockClientResponse(null, false, true);
|
mockClientResponse(client, null, false, true);
|
||||||
try {
|
try {
|
||||||
client.putEntities(generateEntity());
|
client.putEntities(generateEntity());
|
||||||
Assert.fail("RuntimeException is expected");
|
Assert.fail("RuntimeException is expected");
|
||||||
|
@ -111,8 +111,24 @@ public class TestTimelineClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClientResponse mockClientResponse(ClientResponse.Status status,
|
@Test
|
||||||
boolean hasError, boolean hasRuntimeError) {
|
public void testPostEntitiesTimelineServiceNotEnabled() throws Exception {
|
||||||
|
YarnConfiguration conf = new YarnConfiguration();
|
||||||
|
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, false);
|
||||||
|
TimelineClientImpl client = createTimelineClient(conf);
|
||||||
|
mockClientResponse(
|
||||||
|
client, ClientResponse.Status.INTERNAL_SERVER_ERROR, false, false);
|
||||||
|
try {
|
||||||
|
TimelinePutResponse response = client.putEntities(generateEntity());
|
||||||
|
Assert.assertEquals(0, response.getErrors().size());
|
||||||
|
} catch (YarnException e) {
|
||||||
|
Assert.fail(
|
||||||
|
"putEntities should already return before throwing the exception");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ClientResponse mockClientResponse(TimelineClientImpl client,
|
||||||
|
ClientResponse.Status status, boolean hasError, boolean hasRuntimeError) {
|
||||||
ClientResponse response = mock(ClientResponse.class);
|
ClientResponse response = mock(ClientResponse.class);
|
||||||
if (hasRuntimeError) {
|
if (hasRuntimeError) {
|
||||||
doThrow(new ClientHandlerException(new ConnectException())).when(client)
|
doThrow(new ClientHandlerException(new ConnectException())).when(client)
|
||||||
|
@ -157,4 +173,13 @@ public class TestTimelineClient {
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static TimelineClientImpl createTimelineClient(
|
||||||
|
YarnConfiguration conf) {
|
||||||
|
TimelineClientImpl client =
|
||||||
|
spy((TimelineClientImpl) TimelineClient.createTimelineClient());
|
||||||
|
client.init(conf);
|
||||||
|
client.start();
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1087,6 +1087,14 @@
|
||||||
|
|
||||||
<!-- Timeline Service's Configuration-->
|
<!-- Timeline Service's Configuration-->
|
||||||
|
|
||||||
|
<property>
|
||||||
|
<description>Indicate to clients whether timeline service is enabled or not.
|
||||||
|
If enabled, clients will put entities and events to the timeline server.
|
||||||
|
</description>
|
||||||
|
<name>yarn.timeline-service.enabled</name>
|
||||||
|
<value>true</value>
|
||||||
|
</property>
|
||||||
|
|
||||||
<property>
|
<property>
|
||||||
<description>The hostname of the timeline service web application.</description>
|
<description>The hostname of the timeline service web application.</description>
|
||||||
<name>yarn.timeline-service.hostname</name>
|
<name>yarn.timeline-service.hostname</name>
|
||||||
|
|
Loading…
Reference in New Issue