YARN-6237. Move UID constant to TimelineReaderUtils (Rohith Sharma K S via Varun Saxena)
This commit is contained in:
parent
c3bd8d6ad3
commit
18b3a80df7
|
@ -657,7 +657,7 @@ public class TestTimelineReaderWebServicesHBaseStorage
|
||||||
List<String> listFlowUIDs = new ArrayList<String>();
|
List<String> listFlowUIDs = new ArrayList<String>();
|
||||||
for (FlowActivityEntity entity : flowEntities) {
|
for (FlowActivityEntity entity : flowEntities) {
|
||||||
String flowUID =
|
String flowUID =
|
||||||
(String)entity.getInfo().get(TimelineReaderManager.UID_KEY);
|
(String) entity.getInfo().get(TimelineReaderUtils.UID_KEY);
|
||||||
listFlowUIDs.add(flowUID);
|
listFlowUIDs.add(flowUID);
|
||||||
assertEquals(TimelineUIDConverter.FLOW_UID.encodeUID(
|
assertEquals(TimelineUIDConverter.FLOW_UID.encodeUID(
|
||||||
new TimelineReaderContext(entity.getCluster(), entity.getUser(),
|
new TimelineReaderContext(entity.getCluster(), entity.getUser(),
|
||||||
|
@ -681,7 +681,7 @@ public class TestTimelineReaderWebServicesHBaseStorage
|
||||||
assertNotNull(frEntities);
|
assertNotNull(frEntities);
|
||||||
for (FlowRunEntity entity : frEntities) {
|
for (FlowRunEntity entity : frEntities) {
|
||||||
String flowRunUID =
|
String flowRunUID =
|
||||||
(String)entity.getInfo().get(TimelineReaderManager.UID_KEY);
|
(String) entity.getInfo().get(TimelineReaderUtils.UID_KEY);
|
||||||
listFlowRunUIDs.add(flowRunUID);
|
listFlowRunUIDs.add(flowRunUID);
|
||||||
assertEquals(TimelineUIDConverter.FLOWRUN_UID.encodeUID(
|
assertEquals(TimelineUIDConverter.FLOWRUN_UID.encodeUID(
|
||||||
new TimelineReaderContext("cluster1", entity.getUser(),
|
new TimelineReaderContext("cluster1", entity.getUser(),
|
||||||
|
@ -713,7 +713,7 @@ public class TestTimelineReaderWebServicesHBaseStorage
|
||||||
assertNotNull(appEntities);
|
assertNotNull(appEntities);
|
||||||
for (TimelineEntity entity : appEntities) {
|
for (TimelineEntity entity : appEntities) {
|
||||||
String appUID =
|
String appUID =
|
||||||
(String)entity.getInfo().get(TimelineReaderManager.UID_KEY);
|
(String) entity.getInfo().get(TimelineReaderUtils.UID_KEY);
|
||||||
listAppUIDs.add(appUID);
|
listAppUIDs.add(appUID);
|
||||||
assertEquals(TimelineUIDConverter.APPLICATION_UID.encodeUID(
|
assertEquals(TimelineUIDConverter.APPLICATION_UID.encodeUID(
|
||||||
new TimelineReaderContext(context.getClusterId(),
|
new TimelineReaderContext(context.getClusterId(),
|
||||||
|
@ -746,7 +746,7 @@ public class TestTimelineReaderWebServicesHBaseStorage
|
||||||
assertNotNull(entities);
|
assertNotNull(entities);
|
||||||
for (TimelineEntity entity : entities) {
|
for (TimelineEntity entity : entities) {
|
||||||
String entityUID =
|
String entityUID =
|
||||||
(String)entity.getInfo().get(TimelineReaderManager.UID_KEY);
|
(String) entity.getInfo().get(TimelineReaderUtils.UID_KEY);
|
||||||
listEntityUIDs.add(entityUID);
|
listEntityUIDs.add(entityUID);
|
||||||
assertEquals(TimelineUIDConverter.GENERIC_ENTITY_UID.encodeUID(
|
assertEquals(TimelineUIDConverter.GENERIC_ENTITY_UID.encodeUID(
|
||||||
new TimelineReaderContext(context.getClusterId(),
|
new TimelineReaderContext(context.getClusterId(),
|
||||||
|
@ -827,7 +827,7 @@ public class TestTimelineReaderWebServicesHBaseStorage
|
||||||
assertNotNull(entity.getInfo());
|
assertNotNull(entity.getInfo());
|
||||||
assertEquals(2, entity.getInfo().size());
|
assertEquals(2, entity.getInfo().size());
|
||||||
String uid =
|
String uid =
|
||||||
(String) entity.getInfo().get(TimelineReaderManager.UID_KEY);
|
(String) entity.getInfo().get(TimelineReaderUtils.UID_KEY);
|
||||||
assertNotNull(uid);
|
assertNotNull(uid);
|
||||||
assertTrue(uid.equals(appUIDWithFlowInfo + "!type1!0!entity1")
|
assertTrue(uid.equals(appUIDWithFlowInfo + "!type1!0!entity1")
|
||||||
|| uid.equals(appUIDWithFlowInfo + "!type1!0!entity2"));
|
|| uid.equals(appUIDWithFlowInfo + "!type1!0!entity2"));
|
||||||
|
@ -855,7 +855,7 @@ public class TestTimelineReaderWebServicesHBaseStorage
|
||||||
assertNotNull(entity.getInfo());
|
assertNotNull(entity.getInfo());
|
||||||
assertEquals(2, entity.getInfo().size());
|
assertEquals(2, entity.getInfo().size());
|
||||||
String uid =
|
String uid =
|
||||||
(String) entity.getInfo().get(TimelineReaderManager.UID_KEY);
|
(String) entity.getInfo().get(TimelineReaderUtils.UID_KEY);
|
||||||
assertNotNull(uid);
|
assertNotNull(uid);
|
||||||
assertTrue(uid.equals(appUIDWithoutFlowInfo + "!type1!0!entity1")
|
assertTrue(uid.equals(appUIDWithoutFlowInfo + "!type1!0!entity1")
|
||||||
|| uid.equals(appUIDWithoutFlowInfo + "!type1!0!entity2"));
|
|| uid.equals(appUIDWithoutFlowInfo + "!type1!0!entity2"));
|
||||||
|
|
|
@ -32,8 +32,6 @@ import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntityType;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.yarn.server.timelineservice.storage.TimelineReader;
|
import org.apache.hadoop.yarn.server.timelineservice.storage.TimelineReader;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class wraps over the timeline reader store implementation. It does some
|
* This class wraps over the timeline reader store implementation. It does some
|
||||||
* non trivial manipulation of the timeline data before or after getting
|
* non trivial manipulation of the timeline data before or after getting
|
||||||
|
@ -43,8 +41,6 @@ import com.google.common.annotations.VisibleForTesting;
|
||||||
@Unstable
|
@Unstable
|
||||||
public class TimelineReaderManager extends AbstractService {
|
public class TimelineReaderManager extends AbstractService {
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
public static final String UID_KEY = "UID";
|
|
||||||
private TimelineReader reader;
|
private TimelineReader reader;
|
||||||
|
|
||||||
public TimelineReaderManager(TimelineReader timelineReader) {
|
public TimelineReaderManager(TimelineReader timelineReader) {
|
||||||
|
@ -94,18 +90,18 @@ public class TimelineReaderManager extends AbstractService {
|
||||||
FlowActivityEntity activityEntity = (FlowActivityEntity)entity;
|
FlowActivityEntity activityEntity = (FlowActivityEntity)entity;
|
||||||
context.setUserId(activityEntity.getUser());
|
context.setUserId(activityEntity.getUser());
|
||||||
context.setFlowName(activityEntity.getFlowName());
|
context.setFlowName(activityEntity.getFlowName());
|
||||||
entity.setUID(UID_KEY,
|
entity.setUID(TimelineReaderUtils.UID_KEY,
|
||||||
TimelineUIDConverter.FLOW_UID.encodeUID(context));
|
TimelineUIDConverter.FLOW_UID.encodeUID(context));
|
||||||
return;
|
return;
|
||||||
case YARN_FLOW_RUN:
|
case YARN_FLOW_RUN:
|
||||||
FlowRunEntity runEntity = (FlowRunEntity)entity;
|
FlowRunEntity runEntity = (FlowRunEntity)entity;
|
||||||
context.setFlowRunId(runEntity.getRunId());
|
context.setFlowRunId(runEntity.getRunId());
|
||||||
entity.setUID(UID_KEY,
|
entity.setUID(TimelineReaderUtils.UID_KEY,
|
||||||
TimelineUIDConverter.FLOWRUN_UID.encodeUID(context));
|
TimelineUIDConverter.FLOWRUN_UID.encodeUID(context));
|
||||||
return;
|
return;
|
||||||
case YARN_APPLICATION:
|
case YARN_APPLICATION:
|
||||||
context.setAppId(entity.getId());
|
context.setAppId(entity.getId());
|
||||||
entity.setUID(UID_KEY,
|
entity.setUID(TimelineReaderUtils.UID_KEY,
|
||||||
TimelineUIDConverter.APPLICATION_UID.encodeUID(context));
|
TimelineUIDConverter.APPLICATION_UID.encodeUID(context));
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
@ -115,7 +111,7 @@ public class TimelineReaderManager extends AbstractService {
|
||||||
context.setEntityType(entity.getType());
|
context.setEntityType(entity.getType());
|
||||||
context.setEntityIdPrefix(entity.getIdPrefix());
|
context.setEntityIdPrefix(entity.getIdPrefix());
|
||||||
context.setEntityId(entity.getId());
|
context.setEntityId(entity.getId());
|
||||||
entity.setUID(UID_KEY,
|
entity.setUID(TimelineReaderUtils.UID_KEY,
|
||||||
TimelineUIDConverter.GENERIC_ENTITY_UID.encodeUID(context));
|
TimelineUIDConverter.GENERIC_ENTITY_UID.encodeUID(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,9 @@ public final class TimelineReaderUtils {
|
||||||
|
|
||||||
public static final String FROMID_KEY = "FROM_ID";
|
public static final String FROMID_KEY = "FROM_ID";
|
||||||
|
|
||||||
|
@VisibleForTesting
|
||||||
|
public static final String UID_KEY = "UID";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Split the passed string along the passed delimiter character while looking
|
* Split the passed string along the passed delimiter character while looking
|
||||||
* for escape char to interpret the splitted parts correctly. For delimiter or
|
* for escape char to interpret the splitted parts correctly. For delimiter or
|
||||||
|
|
|
@ -238,7 +238,7 @@ public class TestTimelineReaderWebServices {
|
||||||
assertEquals(3, entity.getConfigs().size());
|
assertEquals(3, entity.getConfigs().size());
|
||||||
assertEquals(3, entity.getMetrics().size());
|
assertEquals(3, entity.getMetrics().size());
|
||||||
assertTrue("UID should be present",
|
assertTrue("UID should be present",
|
||||||
entity.getInfo().containsKey(TimelineReaderManager.UID_KEY));
|
entity.getInfo().containsKey(TimelineReaderUtils.UID_KEY));
|
||||||
// Includes UID.
|
// Includes UID.
|
||||||
assertEquals(3, entity.getInfo().size());
|
assertEquals(3, entity.getInfo().size());
|
||||||
// No events will be returned as events are not part of fields.
|
// No events will be returned as events are not part of fields.
|
||||||
|
@ -265,7 +265,7 @@ public class TestTimelineReaderWebServices {
|
||||||
assertEquals(3, entity.getConfigs().size());
|
assertEquals(3, entity.getConfigs().size());
|
||||||
assertEquals(3, entity.getMetrics().size());
|
assertEquals(3, entity.getMetrics().size());
|
||||||
assertTrue("UID should be present",
|
assertTrue("UID should be present",
|
||||||
entity.getInfo().containsKey(TimelineReaderManager.UID_KEY));
|
entity.getInfo().containsKey(TimelineReaderUtils.UID_KEY));
|
||||||
// Includes UID.
|
// Includes UID.
|
||||||
assertEquals(3, entity.getInfo().size());
|
assertEquals(3, entity.getInfo().size());
|
||||||
assertEquals(2, entity.getEvents().size());
|
assertEquals(2, entity.getEvents().size());
|
||||||
|
|
Loading…
Reference in New Issue