Search in sources :

Example 1 with AppToFlowRowKey

use of org.apache.hadoop.yarn.server.timelineservice.storage.apptoflow.AppToFlowRowKey in project hadoop by apache.

the class HBaseTimelineWriterImpl method write.

/**
   * Stores the entire information in TimelineEntities to the timeline store.
   */
@Override
public TimelineWriteResponse write(String clusterId, String userId, String flowName, String flowVersion, long flowRunId, String appId, TimelineEntities data) throws IOException {
    TimelineWriteResponse putStatus = new TimelineWriteResponse();
    // defensive coding to avoid NPE during row key construction
    if ((flowName == null) || (appId == null) || (clusterId == null) || (userId == null)) {
        LOG.warn("Found null for one of: flowName=" + flowName + " appId=" + appId + " userId=" + userId + " clusterId=" + clusterId + " . Not proceeding with writing to hbase");
        return putStatus;
    }
    for (TimelineEntity te : data.getEntities()) {
        // a set can have at most 1 null
        if (te == null) {
            continue;
        }
        // if the entity is the application, the destination is the application
        // table
        boolean isApplication = isApplicationEntity(te);
        byte[] rowKey;
        if (isApplication) {
            ApplicationRowKey applicationRowKey = new ApplicationRowKey(clusterId, userId, flowName, flowRunId, appId);
            rowKey = applicationRowKey.getRowKey();
        } else {
            EntityRowKey entityRowKey = new EntityRowKey(clusterId, userId, flowName, flowRunId, appId, te.getType(), te.getId());
            rowKey = entityRowKey.getRowKey();
        }
        storeInfo(rowKey, te, flowVersion, isApplication);
        storeEvents(rowKey, te.getEvents(), isApplication);
        storeConfig(rowKey, te.getConfigs(), isApplication);
        storeMetrics(rowKey, te.getMetrics(), isApplication);
        storeRelations(rowKey, te, isApplication);
        if (isApplication) {
            TimelineEvent event = getApplicationEvent(te, ApplicationMetricsConstants.CREATED_EVENT_TYPE);
            FlowRunRowKey flowRunRowKey = new FlowRunRowKey(clusterId, userId, flowName, flowRunId);
            if (event != null) {
                AppToFlowRowKey appToFlowRowKey = new AppToFlowRowKey(clusterId, appId);
                onApplicationCreated(flowRunRowKey, appToFlowRowKey, appId, userId, flowVersion, te, event.getTimestamp());
            }
            // if it's an application entity, store metrics
            storeFlowMetricsAppRunning(flowRunRowKey, appId, te);
            // if application has finished, store it's finish time and write final
            // values of all metrics
            event = getApplicationEvent(te, ApplicationMetricsConstants.FINISHED_EVENT_TYPE);
            if (event != null) {
                onApplicationFinished(flowRunRowKey, flowVersion, appId, te, event.getTimestamp());
            }
        }
    }
    return putStatus;
}
Also used : TimelineEvent(org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent) EntityRowKey(org.apache.hadoop.yarn.server.timelineservice.storage.entity.EntityRowKey) TimelineWriteResponse(org.apache.hadoop.yarn.api.records.timelineservice.TimelineWriteResponse) ApplicationRowKey(org.apache.hadoop.yarn.server.timelineservice.storage.application.ApplicationRowKey) FlowRunRowKey(org.apache.hadoop.yarn.server.timelineservice.storage.flow.FlowRunRowKey) TimelineEntity(org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity) AppToFlowRowKey(org.apache.hadoop.yarn.server.timelineservice.storage.apptoflow.AppToFlowRowKey)

Example 2 with AppToFlowRowKey

use of org.apache.hadoop.yarn.server.timelineservice.storage.apptoflow.AppToFlowRowKey in project hadoop by apache.

the class TestRowKeys method testAppToFlowRowKey.

/**
   * Tests the converters indirectly through the public methods of the
   * corresponding rowkey.
   */
@Test
public void testAppToFlowRowKey() {
    byte[] byteRowKey = new AppToFlowRowKey(CLUSTER, APPLICATION_ID).getRowKey();
    AppToFlowRowKey rowKey = AppToFlowRowKey.parseRowKey(byteRowKey);
    assertEquals(CLUSTER, rowKey.getClusterId());
    assertEquals(APPLICATION_ID, rowKey.getAppId());
}
Also used : AppToFlowRowKey(org.apache.hadoop.yarn.server.timelineservice.storage.apptoflow.AppToFlowRowKey) Test(org.junit.Test)

Example 3 with AppToFlowRowKey

use of org.apache.hadoop.yarn.server.timelineservice.storage.apptoflow.AppToFlowRowKey in project hadoop by apache.

the class ApplicationEntityReader method augmentParams.

@Override
protected void augmentParams(Configuration hbaseConf, Connection conn) throws IOException {
    TimelineReaderContext context = getContext();
    if (isSingleEntityRead()) {
        // Get flow context information from AppToFlow table.
        if (context.getFlowName() == null || context.getFlowRunId() == null || context.getUserId() == null) {
            AppToFlowRowKey appToFlowRowKey = new AppToFlowRowKey(context.getClusterId(), context.getAppId());
            FlowContext flowContext = lookupFlowContext(appToFlowRowKey, hbaseConf, conn);
            context.setFlowName(flowContext.getFlowName());
            context.setFlowRunId(flowContext.getFlowRunId());
            context.setUserId(flowContext.getUserId());
        }
    }
    // Add configs/metrics to fields to retrieve if confsToRetrieve and/or
    // metricsToRetrieve are specified.
    getDataToRetrieve().addFieldsBasedOnConfsAndMetricsToRetrieve();
    if (!isSingleEntityRead()) {
        createFiltersIfNull();
    }
}
Also used : TimelineReaderContext(org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderContext) AppToFlowRowKey(org.apache.hadoop.yarn.server.timelineservice.storage.apptoflow.AppToFlowRowKey)

Example 4 with AppToFlowRowKey

use of org.apache.hadoop.yarn.server.timelineservice.storage.apptoflow.AppToFlowRowKey in project hadoop by apache.

the class GenericEntityReader method augmentParams.

@Override
protected void augmentParams(Configuration hbaseConf, Connection conn) throws IOException {
    TimelineReaderContext context = getContext();
    // In reality all three should be null or neither should be null
    if (context.getFlowName() == null || context.getFlowRunId() == null || context.getUserId() == null) {
        // Get flow context information from AppToFlow table.
        AppToFlowRowKey appToFlowRowKey = new AppToFlowRowKey(context.getClusterId(), context.getAppId());
        FlowContext flowContext = lookupFlowContext(appToFlowRowKey, hbaseConf, conn);
        context.setFlowName(flowContext.flowName);
        context.setFlowRunId(flowContext.flowRunId);
        context.setUserId(flowContext.userId);
    }
    // Add configs/metrics to fields to retrieve if confsToRetrieve and/or
    // metricsToRetrieve are specified.
    getDataToRetrieve().addFieldsBasedOnConfsAndMetricsToRetrieve();
    if (!isSingleEntityRead()) {
        createFiltersIfNull();
    }
}
Also used : TimelineReaderContext(org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderContext) AppToFlowRowKey(org.apache.hadoop.yarn.server.timelineservice.storage.apptoflow.AppToFlowRowKey)

Aggregations

AppToFlowRowKey (org.apache.hadoop.yarn.server.timelineservice.storage.apptoflow.AppToFlowRowKey)4 TimelineReaderContext (org.apache.hadoop.yarn.server.timelineservice.reader.TimelineReaderContext)2 TimelineEntity (org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity)1 TimelineEvent (org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent)1 TimelineWriteResponse (org.apache.hadoop.yarn.api.records.timelineservice.TimelineWriteResponse)1 ApplicationRowKey (org.apache.hadoop.yarn.server.timelineservice.storage.application.ApplicationRowKey)1 EntityRowKey (org.apache.hadoop.yarn.server.timelineservice.storage.entity.EntityRowKey)1 FlowRunRowKey (org.apache.hadoop.yarn.server.timelineservice.storage.flow.FlowRunRowKey)1 Test (org.junit.Test)1