1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
<?php
/**
* Host subclass for the phorge-elasticsearch-modern extension.
*
* Mirrors PhabricatorElasticsearchHost's surface area; differs only in
* the display name and (in future versions) the auth config fields.
*/
final class VyOSElasticModernHost extends PhabricatorSearchHost {
private $version = 7;
private $path = 'phabricator/';
private $protocol = 'http';
const KEY_REFS = 'search.elasticmodern.refs';
public function setConfig($config) {
$this->setRoles(idx($config, 'roles', $this->getRoles()))
->setHost(idx($config, 'host', $this->host))
->setPort(idx($config, 'port', $this->port))
->setProtocol(idx($config, 'protocol', $this->protocol))
->setPath(idx($config, 'path', $this->path))
->setVersion(idx($config, 'version', $this->version));
return $this;
}
public function getDisplayName() {
return pht('Elasticsearch (modern)');
}
public function getStatusViewColumns() {
return array(
pht('Protocol') => $this->getProtocol(),
pht('Host') => $this->getHost(),
pht('Port') => $this->getPort(),
pht('Index Path') => $this->getPath(),
pht('Version') => $this->getVersion(),
pht('Roles') => implode(', ', array_keys($this->getRoles())),
);
}
public function setProtocol($protocol) {
$this->protocol = $protocol;
return $this;
}
public function getProtocol() {
return $this->protocol;
}
public function setPath($path) {
$this->path = $path;
return $this;
}
public function getPath() {
return $this->path;
}
public function setVersion($version) {
$this->version = $version;
return $this;
}
public function getVersion() {
return $this->version;
}
/**
* @return PhutilURI
*/
public function getURI($to_path = null) {
$uri = id(new PhutilURI('http://'.$this->getHost()))
->setProtocol($this->getProtocol())
->setPort($this->getPort())
->setPath($this->getPath());
if ($to_path) {
$uri->appendPath($to_path);
}
return $uri;
}
public function getConnectionStatus() {
try {
$status = $this->getEngine()->indexIsSane($this);
return $status ? parent::STATUS_OKAY : parent::STATUS_FAIL;
} catch (Exception $e) {
return parent::STATUS_FAIL;
}
}
}
|