Improve Daemon console UI
Summary: Makes various fixes to the Daemon console UI: - Removes timeline, timeline cursors, and timeline-related controllers. This abstraction is all but dead and just waiting on an eventual cleanup effort with Facebook (see T2003). There's no need to inspect or debug it anymore. - Instead of showing the 15 most recently launched non-exited daemons, show all the running daemons. With the old rule, "dead" daemons tended to build up at the bottom of the list -- e.g., secure.phabricator.com shows the 7 active daemons, then 8 dead daemons from as far back as Aug 2012. Showing running daemons is far more useful. - Simplify the two "Running Daemons" and "All Daemons" subviews into one "All Daemons" subview. The main console now has "running daemons", effectively. - Create a "Recently completed tasks" view, which shows how many tasks of each task class have completed in the last 15 minutes and how long they took on average. Understanding how quickly tasks are completing is one of the most common uses of the daemon console, and it's currently almost useless for that. Now that we archive tasks, we can show this information in an easily digestable form. - Partially modernize all of the remaining views. Test Plan: Looked at daemon console. Reviewers: btrahan, chad, vrana Reviewed By: btrahan CC: aran Maniphest Tasks: T2372, T2003 Differential Revision: https://secure.phabricator.com/D4573
This commit is contained in:
@@ -4,19 +4,71 @@ final class PhabricatorDaemonConsoleController
|
||||
extends PhabricatorDaemonController {
|
||||
|
||||
public function processRequest() {
|
||||
$logs = id(new PhabricatorDaemonLog())->loadAllWhere(
|
||||
'`status` != %s ORDER BY id DESC LIMIT 15', 'exit');
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
$completed = id(new PhabricatorWorkerArchiveTask())->loadAllWhere(
|
||||
'dateModified > %d',
|
||||
time() - (60 * 15));
|
||||
|
||||
$completed_info = array();
|
||||
foreach ($completed as $completed_task) {
|
||||
$class = $completed_task->getTaskClass();
|
||||
if (empty($completed_info[$class])) {
|
||||
$completed_info[$class] = array(
|
||||
'n' => 0,
|
||||
'duration' => 0,
|
||||
);
|
||||
}
|
||||
$completed_info[$class]['n']++;
|
||||
$duration = $completed_task->getDuration();
|
||||
$completed_info[$class]['duration'] += $duration;
|
||||
}
|
||||
|
||||
$completed_info = isort($completed_info, 'n');
|
||||
|
||||
$rows = array();
|
||||
foreach ($completed_info as $class => $info) {
|
||||
$rows[] = array(
|
||||
phutil_escape_html($class),
|
||||
number_format($info['n']),
|
||||
number_format((int)($info['duration'] / $info['n'])).' us',
|
||||
);
|
||||
}
|
||||
|
||||
$completed_table = new AphrontTableView($rows);
|
||||
$completed_table->setNoDataString(
|
||||
pht('No tasks have completed in the last 15 minutes.'));
|
||||
$completed_table->setHeaders(
|
||||
array(
|
||||
pht('Class'),
|
||||
pht('Count'),
|
||||
pht('Avg'),
|
||||
));
|
||||
$completed_table->setColumnClasses(
|
||||
array(
|
||||
'wide',
|
||||
'n',
|
||||
'n',
|
||||
));
|
||||
|
||||
$completed_panel = new AphrontPanelView();
|
||||
$completed_panel->setHeader(pht('Recently Completed Tasks (15m)'));
|
||||
$completed_panel->appendChild($completed_table);
|
||||
$completed_panel->setNoBackground();
|
||||
|
||||
$logs = id(new PhabricatorDaemonLog())->loadAllWhere(
|
||||
'`status` = %s ORDER BY id DESC',
|
||||
'run');
|
||||
|
||||
$daemon_table = new PhabricatorDaemonLogListView();
|
||||
$daemon_table->setUser($user);
|
||||
$daemon_table->setDaemonLogs($logs);
|
||||
|
||||
$daemon_panel = new AphrontPanelView();
|
||||
$daemon_panel->setHeader('Recently Launched Daemons');
|
||||
$daemon_panel->setHeader('Active Daemons');
|
||||
$daemon_panel->appendChild($daemon_table);
|
||||
$daemon_panel->setNoBackground();
|
||||
|
||||
$tasks = id(new PhabricatorWorkerActiveTask())->loadAllWhere(
|
||||
'leaseOwner IS NOT NULL');
|
||||
@@ -63,6 +115,7 @@ final class PhabricatorDaemonConsoleController
|
||||
$leased_panel = new AphrontPanelView();
|
||||
$leased_panel->setHeader('Leased Tasks');
|
||||
$leased_panel->appendChild($leased_table);
|
||||
$leased_panel->setNoBackground();
|
||||
|
||||
$task_table = new PhabricatorWorkerActiveTask();
|
||||
$queued = queryfx_all(
|
||||
@@ -95,41 +148,14 @@ final class PhabricatorDaemonConsoleController
|
||||
$queued_panel = new AphrontPanelView();
|
||||
$queued_panel->setHeader('Queued Tasks');
|
||||
$queued_panel->appendChild($queued_table);
|
||||
|
||||
$cursors = id(new PhabricatorTimelineCursor())
|
||||
->loadAll();
|
||||
|
||||
$rows = array();
|
||||
foreach ($cursors as $cursor) {
|
||||
$rows[] = array(
|
||||
phutil_escape_html($cursor->getName()),
|
||||
number_format($cursor->getPosition()),
|
||||
);
|
||||
}
|
||||
|
||||
$cursor_table = new AphrontTableView($rows);
|
||||
$cursor_table->setHeaders(
|
||||
array(
|
||||
'Name',
|
||||
'Position',
|
||||
));
|
||||
$cursor_table->setColumnClasses(
|
||||
array(
|
||||
'wide',
|
||||
'n',
|
||||
));
|
||||
$cursor_table->setNoDataString('No timeline cursors exist.');
|
||||
|
||||
$cursor_panel = new AphrontPanelView();
|
||||
$cursor_panel->setHeader('Timeline Cursors');
|
||||
$cursor_panel->appendChild($cursor_table);
|
||||
$queued_panel->setNoBackground();
|
||||
|
||||
$nav = $this->buildSideNavView();
|
||||
$nav->selectFilter('');
|
||||
$nav->selectFilter('/');
|
||||
$nav->appendChild(
|
||||
array(
|
||||
$completed_panel,
|
||||
$daemon_panel,
|
||||
$cursor_panel,
|
||||
$queued_panel,
|
||||
$leased_panel,
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user