ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilGlobalCacheMetricsCollectedObjective.php
Go to the documentation of this file.
1<?php
2
24
26{
27 protected function getTentativePreconditions(Environment $environment): array
28 {
29 return [
31 new \ilDatabaseInitializedObjective()
32 ];
33 }
34
35 protected function collectFrom(Environment $environment, Storage $storage): void
36 {
37 $db = $environment->getResource(Environment::RESOURCE_DATABASE);
38 $client_ini = $environment->getResource(Environment::RESOURCE_CLIENT_INI);
39
40 if (!$client_ini) {
41 return;
42 }
43
44 $config = (new ilGlobalCacheSettingsAdapter($client_ini, $db))->getConfig();
45
46 $service = $config->getAdaptorName();
48 "service",
50 "The backend that is used for the ILIAS cache."
51 );
53 "active",
54 $config->isActivated()
55 );
56
57 $servers = $config->getNodes();
58 if (
59 $service === Config::MEMCACHED &&
60 $servers !== []
61 ) {
62 $server_collection = [];
63 foreach ($servers as $server) {
64 $host = new Metric(
65 Metric::STABILITY_CONFIG,
66 Metric::TYPE_TEXT,
67 $server->getHost()
68 );
69 $port = new Metric(
70 Metric::STABILITY_CONFIG,
71 Metric::TYPE_GAUGE,
72 $server->getPort()
73 );
74 $weight = new Metric(
75 Metric::STABILITY_CONFIG,
76 Metric::TYPE_GAUGE,
77 $server->getWeight()
78 );
79
80 $server_collection[] = new Metric(
81 Metric::STABILITY_CONFIG,
82 Metric::TYPE_COLLECTION,
83 [
84 "host" => $host,
85 "port" => $port,
86 "weight" => $weight
87 ],
88 "Configured memcached node."
89 );
90 }
91
92 $nodes = new Metric(
93 Metric::STABILITY_CONFIG,
94 Metric::TYPE_COLLECTION,
95 $server_collection,
96 "Collection of configured memcached nodes."
97 );
98 $storage->store("memcached_nodes", $nodes);
99 }
100
101 $component_activation = [];
102 foreach (ilGlobalCache::getAvailableComponents() as $component) {
103 $component_activation[$component] = new Metric(
104 Metric::STABILITY_CONFIG,
105 Metric::TYPE_BOOL,
106 $config->isComponentActivated($component)
107 );
108 }
109 $component_activation = new Metric(
110 Metric::STABILITY_CONFIG,
111 Metric::TYPE_COLLECTION,
112 $component_activation,
113 "Which components are activated to use caching?"
114 );
116 "components",
117 $component_activation
118 );
119 }
120}
Base class to simplify collection of metrics.
A metric is something we can measure about the system.
Definition: Metric.php:34
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
store(string $key, Metric $metric)
Store some metric in the storage.
storeConfigText(string $key, string $value, ?string $description=null)
storeConfigBool(string $key, bool $value, ?string $description=null)
$service
Definition: ltiresult.php:36
$server
Definition: shib_login.php:28