Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102721866
PhabricatorDaemonConsoleController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 23, 12:42
Size
3 KB
Mime Type
text/x-php
Expires
Tue, Feb 25, 12:42 (2 d)
Engine
blob
Format
Raw Data
Handle
24405307
Attached To
rPH Phabricator
PhabricatorDaemonConsoleController.php
View Options
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class
PhabricatorDaemonConsoleController
extends
PhabricatorDaemonController
{
public
function
processRequest
()
{
$tasks
=
id
(
new
PhabricatorWorkerTask
())->
loadAllWhere
(
'leaseOwner IS NOT NULL'
);
$rows
=
array
();
foreach
(
$tasks
as
$task
)
{
$rows
[]
=
array
(
$task
->
getID
(),
$task
->
getTaskClass
(),
$task
->
getLeaseOwner
(),
$task
->
getLeaseExpires
()
-
time
(),
$task
->
getFailureCount
(),
);
}
$leased_table
=
new
AphrontTableView
(
$rows
);
$leased_table
->
setHeaders
(
array
(
'ID'
,
'Class'
,
'Owner'
,
'Expries'
,
'Failures'
,
));
$leased_table
->
setColumnClasses
(
array
(
'n'
,
'wide'
,
''
,
''
,
'n'
,
));
$leased_table
->
setNoDataString
(
'No tasks are leased by workers.'
);
$leased_panel
=
new
AphrontPanelView
();
$leased_panel
->
setHeader
(
'Leased Tasks'
);
$leased_panel
->
appendChild
(
$leased_table
);
$task_table
=
new
PhabricatorWorkerTask
();
$queued
=
queryfx_all
(
$task_table
->
establishConnection
(
'r'
),
'SELECT taskClass, count(*) N FROM %T GROUP BY taskClass
ORDER BY N DESC'
,
$task_table
->
getTableName
());
$rows
=
array
();
foreach
(
$queued
as
$row
)
{
$rows
[]
=
array
(
phutil_escape_html
(
$row
[
'taskClass'
]),
number_format
(
$row
[
'N'
]),
);
}
$queued_table
=
new
AphrontTableView
(
$rows
);
$queued_table
->
setHeaders
(
array
(
'Class'
,
'Count'
,
));
$queued_table
->
setColumnClasses
(
array
(
'wide'
,
'n'
,
));
$queued_table
->
setNoDataString
(
'Task queue is empty.'
);
$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
);
return
$this
->
buildStandardPageResponse
(
array
(
$leased_panel
,
$queued_panel
,
$cursor_panel
,
),
array
(
'title'
=>
'Console'
,
'tab'
=>
'console'
,
));
}
}
Event Timeline
Log In to Comment