use of org.apache.hadoop.yarn.server.timelineservice.storage.flow.FlowActivityRowKey in project hadoop by apache.
the class HBaseTimelineWriterImpl method onApplicationFinished.
/*
* updates the {@link FlowRunTable} and {@link FlowActivityTable} when an
* application has finished
*/
private void onApplicationFinished(FlowRunRowKey flowRunRowKey, String flowVersion, String appId, TimelineEntity te, long appFinishedTimeStamp) throws IOException {
// store in flow run table
storeAppFinishedInFlowRunTable(flowRunRowKey, appId, te, appFinishedTimeStamp);
// indicate in the flow activity table that the app has finished
byte[] rowKey = new FlowActivityRowKey(flowRunRowKey.getClusterId(), appFinishedTimeStamp, flowRunRowKey.getUserId(), flowRunRowKey.getFlowName()).getRowKey();
byte[] qualifier = longKeyConverter.encode(flowRunRowKey.getFlowRunId());
FlowActivityColumnPrefix.RUN_ID.store(rowKey, flowActivityTable, qualifier, null, flowVersion, AggregationCompactionDimension.APPLICATION_ID.getAttribute(appId));
}
use of org.apache.hadoop.yarn.server.timelineservice.storage.flow.FlowActivityRowKey in project hadoop by apache.
the class TestRowKeys method testFlowActivityRowKey.
@Test
public void testFlowActivityRowKey() {
Long ts = 1459900830000L;
Long dayTimestamp = HBaseTimelineStorageUtils.getTopOfTheDayTimestamp(ts);
byte[] byteRowKey = new FlowActivityRowKey(CLUSTER, ts, USER, FLOW_NAME).getRowKey();
FlowActivityRowKey rowKey = FlowActivityRowKey.parseRowKey(byteRowKey);
assertEquals(CLUSTER, rowKey.getClusterId());
assertEquals(dayTimestamp, rowKey.getDayTimestamp());
assertEquals(USER, rowKey.getUserId());
assertEquals(FLOW_NAME, rowKey.getFlowName());
byte[] byteRowKeyPrefix = new FlowActivityRowKeyPrefix(CLUSTER).getRowKeyPrefix();
byte[][] splits = Separator.QUALIFIERS.split(byteRowKeyPrefix, new int[] { Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE });
assertEquals(2, splits.length);
assertEquals(0, splits[1].length);
assertEquals(CLUSTER, Separator.QUALIFIERS.decode(Bytes.toString(splits[0])));
verifyRowPrefixBytes(byteRowKeyPrefix);
byteRowKeyPrefix = new FlowActivityRowKeyPrefix(CLUSTER, ts).getRowKeyPrefix();
splits = Separator.QUALIFIERS.split(byteRowKeyPrefix, new int[] { Separator.VARIABLE_SIZE, Bytes.SIZEOF_LONG, Separator.VARIABLE_SIZE });
assertEquals(3, splits.length);
assertEquals(0, splits[2].length);
assertEquals(CLUSTER, Separator.QUALIFIERS.decode(Bytes.toString(splits[0])));
assertEquals(ts, (Long) LongConverter.invertLong(Bytes.toLong(splits[1])));
verifyRowPrefixBytes(byteRowKeyPrefix);
}
use of org.apache.hadoop.yarn.server.timelineservice.storage.flow.FlowActivityRowKey in project hadoop by apache.
the class FlowActivityEntityReader method parseEntity.
@Override
protected TimelineEntity parseEntity(Result result) throws IOException {
FlowActivityRowKey rowKey = FlowActivityRowKey.parseRowKey(result.getRow());
Long time = rowKey.getDayTimestamp();
String user = rowKey.getUserId();
String flowName = rowKey.getFlowName();
FlowActivityEntity flowActivity = new FlowActivityEntity(getContext().getClusterId(), time, user, flowName);
// set the id
flowActivity.setId(flowActivity.getId());
// get the list of run ids along with the version that are associated with
// this flow on this day
Map<Long, Object> runIdsMap = FlowActivityColumnPrefix.RUN_ID.readResults(result, longKeyConverter);
for (Map.Entry<Long, Object> e : runIdsMap.entrySet()) {
Long runId = e.getKey();
String version = (String) e.getValue();
FlowRunEntity flowRun = new FlowRunEntity();
flowRun.setUser(user);
flowRun.setName(flowName);
flowRun.setRunId(runId);
flowRun.setVersion(version);
// set the id
flowRun.setId(flowRun.getId());
flowActivity.addFlowRun(flowRun);
}
return flowActivity;
}
use of org.apache.hadoop.yarn.server.timelineservice.storage.flow.FlowActivityRowKey in project hadoop by apache.
the class HBaseTimelineWriterImpl method onApplicationCreated.
private void onApplicationCreated(FlowRunRowKey flowRunRowKey, AppToFlowRowKey appToFlowRowKey, String appId, String userId, String flowVersion, TimelineEntity te, long appCreatedTimeStamp) throws IOException {
String flowName = flowRunRowKey.getFlowName();
Long flowRunId = flowRunRowKey.getFlowRunId();
// store in App to flow table
byte[] rowKey = appToFlowRowKey.getRowKey();
AppToFlowColumn.FLOW_ID.store(rowKey, appToFlowTable, null, flowName);
AppToFlowColumn.FLOW_RUN_ID.store(rowKey, appToFlowTable, null, flowRunId);
AppToFlowColumn.USER_ID.store(rowKey, appToFlowTable, null, userId);
// store in flow run table
storeAppCreatedInFlowRunTable(flowRunRowKey, appId, te);
// store in flow activity table
byte[] flowActivityRowKeyBytes = new FlowActivityRowKey(flowRunRowKey.getClusterId(), appCreatedTimeStamp, flowRunRowKey.getUserId(), flowName).getRowKey();
byte[] qualifier = longKeyConverter.encode(flowRunRowKey.getFlowRunId());
FlowActivityColumnPrefix.RUN_ID.store(flowActivityRowKeyBytes, flowActivityTable, qualifier, null, flowVersion, AggregationCompactionDimension.APPLICATION_ID.getAttribute(appId));
}
Aggregations