Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/cluster/search/PhabricatorElasticsearchHost.php
13464 views
1
<?php
2
3
final class PhabricatorElasticsearchHost
4
extends PhabricatorSearchHost {
5
6
private $version = 5;
7
private $path = 'phabricator/';
8
private $protocol = 'http';
9
10
const KEY_REFS = 'search.elastic.refs';
11
12
13
public function setConfig($config) {
14
$this->setRoles(idx($config, 'roles', $this->getRoles()))
15
->setHost(idx($config, 'host', $this->host))
16
->setPort(idx($config, 'port', $this->port))
17
->setProtocol(idx($config, 'protocol', $this->protocol))
18
->setPath(idx($config, 'path', $this->path))
19
->setVersion(idx($config, 'version', $this->version));
20
return $this;
21
}
22
23
public function getDisplayName() {
24
return pht('Elasticsearch');
25
}
26
27
public function getStatusViewColumns() {
28
return array(
29
pht('Protocol') => $this->getProtocol(),
30
pht('Host') => $this->getHost(),
31
pht('Port') => $this->getPort(),
32
pht('Index Path') => $this->getPath(),
33
pht('Elastic Version') => $this->getVersion(),
34
pht('Roles') => implode(', ', array_keys($this->getRoles())),
35
);
36
}
37
38
public function setProtocol($protocol) {
39
$this->protocol = $protocol;
40
return $this;
41
}
42
43
public function getProtocol() {
44
return $this->protocol;
45
}
46
47
public function setPath($path) {
48
$this->path = $path;
49
return $this;
50
}
51
52
public function getPath() {
53
return $this->path;
54
}
55
56
public function setVersion($version) {
57
$this->version = $version;
58
return $this;
59
}
60
61
public function getVersion() {
62
return $this->version;
63
}
64
65
public function getURI($to_path = null) {
66
$uri = id(new PhutilURI('http://'.$this->getHost()))
67
->setProtocol($this->getProtocol())
68
->setPort($this->getPort())
69
->setPath($this->getPath());
70
71
if ($to_path) {
72
$uri->appendPath($to_path);
73
}
74
return $uri;
75
}
76
77
public function getConnectionStatus() {
78
$status = $this->getEngine()->indexIsSane($this);
79
return $status ? parent::STATUS_OKAY : parent::STATUS_FAIL;
80
}
81
82
}
83
84