Search in sources :

Example 11 with AddDependencyToLeaves

use of org.apache.hadoop.hive.ql.exec.repl.util.AddDependencyToLeaves in project hive by apache.

the class IncrementalLoadTasksBuilder method addUpdateReplStateTasks.

private List<Task<?>> addUpdateReplStateTasks(UpdatedMetaDataTracker updatedMetaDataTracker, List<Task<?>> importTasks) throws SemanticException {
    // If no import tasks generated by the event then no need to update the repl state to any object.
    if (importTasks.isEmpty()) {
        log.debug("No objects need update of repl state: 0 import tasks");
        return importTasks;
    }
    // Create a barrier task for dependency collection of import tasks
    Task<?> barrierTask = TaskFactory.get(new DependencyCollectionWork(), conf);
    List<Task<?>> tasks = new ArrayList<>();
    Task<?> updateReplIdTask;
    HashMap<String, Integer> dbS = new HashMap<>();
    for (UpdatedMetaDataTracker.UpdateMetaData updateMetaData : updatedMetaDataTracker.getUpdateMetaDataList()) {
        String replState = updateMetaData.getReplState();
        String dbName = updateMetaData.getDbName();
        if (dbS.get(dbName) != null) {
            if (Integer.parseInt(replState) > dbS.get(dbName)) {
                dbS.put(dbName, Integer.parseInt(replState));
            }
        } else {
            dbS.put(dbName, Integer.parseInt(replState));
        }
    }
    for (Map.Entry<String, Integer> entry : dbS.entrySet()) {
        updateReplIdTask = dbUpdateReplStateTask(dbName, String.valueOf(entry.getValue()), barrierTask);
        tasks.add(updateReplIdTask);
    }
    if (tasks.isEmpty()) {
        log.debug("No objects need update of repl state: 0 update tracker tasks");
        return importTasks;
    }
    // Link import tasks to the barrier task which will in-turn linked with repl state update tasks
    DAGTraversal.traverse(importTasks, new AddDependencyToLeaves(barrierTask));
    // At least one task would have been added to update the repl state
    return tasks;
}
Also used : Task(org.apache.hadoop.hive.ql.exec.Task) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UpdatedMetaDataTracker(org.apache.hadoop.hive.ql.parse.repl.load.UpdatedMetaDataTracker) DependencyCollectionWork(org.apache.hadoop.hive.ql.plan.DependencyCollectionWork) HashMap(java.util.HashMap) Map(java.util.Map) AddDependencyToLeaves(org.apache.hadoop.hive.ql.exec.repl.util.AddDependencyToLeaves)

Aggregations

AddDependencyToLeaves (org.apache.hadoop.hive.ql.exec.repl.util.AddDependencyToLeaves)11 Task (org.apache.hadoop.hive.ql.exec.Task)6 Path (org.apache.hadoop.fs.Path)5 HashMap (java.util.HashMap)4 AlterDatabase (org.apache.hadoop.hive.ql.exec.repl.bootstrap.load.LoadDatabase.AlterDatabase)4 ArrayList (java.util.ArrayList)3 Database (org.apache.hadoop.hive.metastore.api.Database)3 LoadDatabase (org.apache.hadoop.hive.ql.exec.repl.bootstrap.load.LoadDatabase)3 TaskTracker (org.apache.hadoop.hive.ql.exec.repl.util.TaskTracker)3 SemanticException (org.apache.hadoop.hive.ql.parse.SemanticException)3 DependencyCollectionWork (org.apache.hadoop.hive.ql.plan.DependencyCollectionWork)3 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 DDLWork (org.apache.hadoop.hive.ql.ddl.DDLWork)2 ReplStateLogWork (org.apache.hadoop.hive.ql.exec.repl.ReplStateLogWork)2 Hive (org.apache.hadoop.hive.ql.metadata.Hive)2 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)2 TException (org.apache.thrift.TException)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1