Skip to content

Commit

Permalink
add some docs(mostly from the disscussion) for the implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sunhelly committed Oct 10, 2022
1 parent 0d9020c commit 1ec4292
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2406,6 +2406,10 @@ private void startActiveMasterManager(int infoPort) throws KeeperException {
Threads.sleep(timeout);
}
}

// Here for the master startup process, we use TaskGroup to monitor the whole progress.
// The UI is similar to how Hadoop designed the startup page for the NameNode.
// See HBASE-21521 for more details.
boolean ignoreClearStartupStatus =
conf.getBoolean("hbase.master.ignore.clear.startup.status", true);
startupTaskGroup = TaskGroup.createTaskGroup(ignoreClearStartupStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,24 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* The {@link TaskGroup} can be seen as a big {@link MonitoredTask}, which contains a list of sub
* monitored tasks. The monitored tasks in the group are still be managed by the
* {@link TaskMonitor}, but whether to clear/expire the monitored tasks in a task group is optional.
* Since the monitored task already has journals, which mark the phases in a task, we still also
* need a task group to monitor a big task/process because the journals in a task is serial but the
* tasks in the task group can be parallel, then we have more flexible ability to monitor the
* process. Grouping the tasks is not strictly necessary but it is cleaner for presentation to
* operators. We might want to display the tasks in a group in a list view where each task can be
* collapsed (probably by default) or expanded.
*/
@InterfaceAudience.Private
public class TaskGroup extends MonitoredTaskImpl {
private static final Logger LOG = LoggerFactory.getLogger(TaskGroup.class);

private final ConcurrentLinkedDeque<MonitoredTask> tasks = new ConcurrentLinkedDeque<>();

/** Whether to clear/expire the monitored tasks by {@link TaskMonitor} */
private final boolean ignoreClearStatus;

public TaskGroup(boolean ignoreClearStatus) {
Expand All @@ -48,6 +61,12 @@ public synchronized MonitoredTask addTask(String description) {
return addTask(description, true);
}

/**
* add a new task to the group, and before that might complete the last task in the group
* @param description the description of the new task
* @param withCompleteLast whether to complete the last task in the group
* @return the added new task
*/
public synchronized MonitoredTask addTask(String description, boolean withCompleteLast) {
if (withCompleteLast) {
MonitoredTask previousTask = this.tasks.peekLast();
Expand Down

0 comments on commit 1ec4292

Please sign in to comment.