Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F558812
PhabricatorConfigClusterSearchController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
PhabricatorConfigClusterSearchController.php
View Options
<?php
final
class
PhabricatorConfigClusterSearchController
extends
PhabricatorConfigServicesController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$title
=
pht
(
'Search Servers'
);
$doc_href
=
PhabricatorEnv
::
getDoclink
(
'Cluster: Search'
);
$button
=
id
(
new
PHUIButtonView
())
->
setIcon
(
'fa-book'
)
->
setHref
(
$doc_href
)
->
setTag
(
'a'
)
->
setText
(
pht
(
'Documentation'
));
$header
=
$this
->
buildHeaderView
(
$title
,
$button
);
$search_status
=
$this
->
buildClusterSearchStatus
();
$crumbs
=
$this
->
newCrumbs
()
->
addTextCrumb
(
$title
);
$content
=
id
(
new
PHUITwoColumnView
())
->
setHeader
(
$header
)
->
setFooter
(
$search_status
);
$nav
=
$this
->
newNavigation
(
'search-servers'
);
return
$this
->
newPage
()
->
setTitle
(
$title
)
->
setCrumbs
(
$crumbs
)
->
setNavigation
(
$nav
)
->
appendChild
(
$content
);
}
private
function
buildClusterSearchStatus
()
{
$viewer
=
$this
->
getViewer
();
$services
=
PhabricatorSearchService
::
getAllServices
();
Javelin
::
initBehavior
(
'phabricator-tooltips'
);
$view
=
array
();
foreach
(
$services
as
$service
)
{
$view
[]
=
$this
->
renderStatusView
(
$service
);
}
return
$view
;
}
private
function
renderStatusView
(
$service
)
{
$head
=
array_merge
(
array
(
pht
(
'Type'
)),
array_keys
(
$service
->
getStatusViewColumns
()),
array
(
pht
(
'Status'
)));
$rows
=
array
();
$status_map
=
PhabricatorSearchService
::
getConnectionStatusMap
();
$stats
=
false
;
$stats_view
=
false
;
foreach
(
$service
->
getHosts
()
as
$host
)
{
try
{
// Default status icon
//
// At the moment the default status is shown also when
// you just use MySQL as search server. So, on MySQL it
// shows "Unknown" even if probably it should says "Active".
// If you have time, please improve the MySQL getConnectionStatus()
// to return something more useful than this default.
$default_status
=
array
(
'icon'
=>
'fa-question-circle'
,
'color'
=>
'blue'
,
'label'
=>
pht
(
'Unknown'
),
);
$status
=
$host
->
getConnectionStatus
();
$status
=
idx
(
$status_map
,
$status
,
$default_status
);
}
catch
(
Exception
$ex
)
{
$status
[
'icon'
]
=
'fa-times'
;
$status
[
'label'
]
=
pht
(
'Connection Error'
);
$status
[
'color'
]
=
'red'
;
$host
->
didHealthCheck
(
false
);
}
if
(!
$stats_view
)
{
try
{
$stats
=
$host
->
getEngine
()->
getIndexStats
(
$host
);
$stats_view
=
$this
->
renderIndexStats
(
$stats
);
}
catch
(
Exception
$e
)
{
$stats_view
=
false
;
}
}
$type_icon
=
'fa-search sky'
;
$type_tip
=
$host
->
getDisplayName
();
$type_icon
=
id
(
new
PHUIIconView
())
->
setIcon
(
$type_icon
);
$status_view
=
array
(
id
(
new
PHUIIconView
())->
setIcon
(
$status
[
'icon'
].
' '
.
$status
[
'color'
]),
' '
,
$status
[
'label'
],
);
$row
=
array
(
array
(
$type_icon
,
' '
,
$type_tip
));
$row
=
array_merge
(
$row
,
array_values
(
$host
->
getStatusViewColumns
()));
$row
[]
=
$status_view
;
$rows
[]
=
$row
;
}
$table
=
id
(
new
AphrontTableView
(
$rows
))
->
setNoDataString
(
pht
(
'No search servers are configured.'
))
->
setHeaders
(
$head
);
$view
=
$this
->
buildConfigBoxView
(
pht
(
'Search Servers'
),
$table
);
$stats
=
null
;
if
(
$stats_view
->
hasAnyProperties
())
{
$stats
=
$this
->
buildConfigBoxView
(
pht
(
'%s Stats'
,
$service
->
getDisplayName
()),
$stats_view
);
}
return
array
(
$stats
,
$view
);
}
private
function
renderIndexStats
(
$stats
)
{
$view
=
id
(
new
PHUIPropertyListView
());
if
(
$stats
!==
false
)
{
foreach
(
$stats
as
$label
=>
$val
)
{
$view
->
addProperty
(
$label
,
$val
);
}
}
return
$view
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, May 12, 9:59 PM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
126826
Default Alt Text
PhabricatorConfigClusterSearchController.php (3 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment