Search in sources :

Example 1 with Flow

use of com.twitter.hraven.Flow in project ambrose by twitter.

the class HRavenWorkflowIndexReadService method getWorkflows.

@Override
public PaginatedList<WorkflowSummary> getWorkflows(String cluster, Status status, String username, int numResults, byte[] nextPageStart) throws IOException {
    List<WorkflowSummary> workflowSummaryList = Lists.newArrayList();
    PaginatedResult<Flow> flows = flowQueueService.getPaginatedFlowsForStatus(cluster, convertStatus(status), numResults, username, nextPageStart);
    for (Flow flow : flows.getValues()) {
        workflowSummaryList.add(toWorkflowSummary(flow));
    }
    PaginatedList<WorkflowSummary> paginatedList = new PaginatedList<WorkflowSummary>(workflowSummaryList);
    if (flows.getNextStartRow() != null) {
        paginatedList.setNextPageStart(new String(Base64.encode(flows.getNextStartRow())));
    }
    return paginatedList;
}
Also used : WorkflowSummary(com.twitter.ambrose.model.WorkflowSummary) PaginatedList(com.twitter.ambrose.model.PaginatedList) Flow(com.twitter.hraven.Flow)

Example 2 with Flow

use of com.twitter.hraven.Flow in project ambrose by twitter.

the class HRavenStatsWriteService method updateFlowQueue.

private void updateFlowQueue(FlowQueueKey key, Integer progress) throws IOException {
    Flow flow = new Flow(flowKey);
    if (progress != null) {
        flow.setProgress(progress);
    }
    flow.setQueueKey(key);
    flow.setFlowName(appId);
    flow.setUserName(username);
    flow.setJobGraphJSON(JSONUtil.toJson(dagNodeNameMap));
    hRavenPool.submit(new HRavenQueueRunnable(flowQueueService, flowQueueKey, flow));
}
Also used : Flow(com.twitter.hraven.Flow)

Example 3 with Flow

use of com.twitter.hraven.Flow in project ambrose by twitter.

the class HRavenStatsReadService method getDagNodeNameMap.

/**
 * Gets the dag nodes for this workflowId. Returns null if the workflow does not exist.
 *
 * @param workflowId the id of the workflow
 * @return a map of nodeIds to DAGNodes
 * @throws IOException
 */
@SuppressWarnings("rawtypes")
@Override
public Map<String, DAGNode> getDagNodeNameMap(String workflowId) throws IOException {
    WorkflowId id = WorkflowId.parseString(workflowId);
    Flow flow = flowQueueService.getFlowFromQueue(id.getCluster(), id.getTimestamp(), id.getFlowId());
    if (flow == null) {
        return null;
    }
    // TODO This may not work nicely with multiple type of jobs
    // See: https://github.com/twitter/ambrose/pull/131
    Map<String, DAGNode> dagMap = JSONUtil.toObject(flow.getJobGraphJSON(), new TypeReference<Map<String, DAGNode>>() {
    });
    return dagMap;
}
Also used : WorkflowId(com.twitter.ambrose.model.WorkflowId) DAGNode(com.twitter.ambrose.model.DAGNode) Map(java.util.Map) Flow(com.twitter.hraven.Flow)

Aggregations

Flow (com.twitter.hraven.Flow)3 DAGNode (com.twitter.ambrose.model.DAGNode)1 PaginatedList (com.twitter.ambrose.model.PaginatedList)1 WorkflowId (com.twitter.ambrose.model.WorkflowId)1 WorkflowSummary (com.twitter.ambrose.model.WorkflowSummary)1 Map (java.util.Map)1