use of org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderContext in project hadoop by apache.
the class FlowRunEntityReader method parseEntity.
@Override
protected TimelineEntity parseEntity(Result result) throws IOException {
TimelineReaderContext context = getContext();
FlowRunEntity flowRun = new FlowRunEntity();
flowRun.setUser(context.getUserId());
flowRun.setName(context.getFlowName());
if (isSingleEntityRead()) {
flowRun.setRunId(context.getFlowRunId());
} else {
FlowRunRowKey rowKey = FlowRunRowKey.parseRowKey(result.getRow());
flowRun.setRunId(rowKey.getFlowRunId());
}
// read the start time
Long startTime = (Long) FlowRunColumn.MIN_START_TIME.readResult(result);
if (startTime != null) {
flowRun.setStartTime(startTime.longValue());
}
// read the end time if available
Long endTime = (Long) FlowRunColumn.MAX_END_TIME.readResult(result);
if (endTime != null) {
flowRun.setMaxEndTime(endTime.longValue());
}
// read the flow version
String version = (String) FlowRunColumn.FLOW_VERSION.readResult(result);
if (version != null) {
flowRun.setVersion(version);
}
// fieldsToRetrieve.
if (isSingleEntityRead() || hasField(getDataToRetrieve().getFieldsToRetrieve(), Field.METRICS)) {
readMetrics(flowRun, result, FlowRunColumnPrefix.METRIC);
}
// set the id
flowRun.setId(flowRun.getId());
return flowRun;
}
use of org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderContext in project hadoop by apache.
the class GenericEntityReader method getResults.
@Override
protected ResultScanner getResults(Configuration hbaseConf, Connection conn, FilterList filterList) throws IOException {
// Scan through part of the table to find the entities belong to one app
// and one type
Scan scan = new Scan();
TimelineReaderContext context = getContext();
RowKeyPrefix<EntityRowKey> entityRowKeyPrefix = new EntityRowKeyPrefix(context.getClusterId(), context.getUserId(), context.getFlowName(), context.getFlowRunId(), context.getAppId(), context.getEntityType());
scan.setRowPrefixFilter(entityRowKeyPrefix.getRowKeyPrefix());
scan.setMaxVersions(getDataToRetrieve().getMetricsLimit());
if (filterList != null && !filterList.getFilters().isEmpty()) {
scan.setFilter(filterList);
}
return getTable().getResultScanner(hbaseConf, conn, scan);
}
use of org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderContext in project hadoop by apache.
the class GenericEntityReader method getResult.
@Override
protected Result getResult(Configuration hbaseConf, Connection conn, FilterList filterList) throws IOException {
TimelineReaderContext context = getContext();
byte[] rowKey = new EntityRowKey(context.getClusterId(), context.getUserId(), context.getFlowName(), context.getFlowRunId(), context.getAppId(), context.getEntityType(), context.getEntityId()).getRowKey();
Get get = new Get(rowKey);
get.setMaxVersions(getDataToRetrieve().getMetricsLimit());
if (filterList != null && !filterList.getFilters().isEmpty()) {
get.setFilter(filterList);
}
return getTable().getResult(hbaseConf, conn, get);
}
use of org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderContext in project hadoop by apache.
the class TestFileSystemTimelineReaderImpl method testGetEntitiesWithLimit.
@Test
public void testGetEntitiesWithLimit() throws Exception {
Set<TimelineEntity> result = reader.getEntities(new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1", "app", null), new TimelineEntityFilters(2L, null, null, null, null, null, null, null, null), new TimelineDataToRetrieve());
Assert.assertEquals(2, result.size());
// based on created time, descending.
for (TimelineEntity entity : result) {
if (!entity.getId().equals("id_1") && !entity.getId().equals("id_4")) {
Assert.fail("Entity not sorted by created time");
}
}
result = reader.getEntities(new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1", "app", null), new TimelineEntityFilters(3L, null, null, null, null, null, null, null, null), new TimelineDataToRetrieve());
// Even though 2 entities out of 4 have same created time, one entity
// is left out due to limit
Assert.assertEquals(3, result.size());
}
use of org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderContext in project hadoop by apache.
the class TestFileSystemTimelineReaderImpl method testGetEntityCustomFields.
@Test
public void testGetEntityCustomFields() throws Exception {
// Specified fields in addition to default view will be returned.
TimelineEntity result = reader.getEntity(new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1", "app", "id_1"), new TimelineDataToRetrieve(null, null, EnumSet.of(Field.INFO, Field.CONFIGS, Field.METRICS), null));
Assert.assertEquals((new TimelineEntity.Identifier("app", "id_1")).toString(), result.getIdentifier().toString());
Assert.assertEquals((Long) 1425016502000L, result.getCreatedTime());
Assert.assertEquals(3, result.getConfigs().size());
Assert.assertEquals(3, result.getMetrics().size());
Assert.assertEquals(2, result.getInfo().size());
// No events will be returned
Assert.assertEquals(0, result.getEvents().size());
}
Aggregations