ILIAS  release_8 Revision v8.24
class.ilGlobalCacheMetricsCollectedObjective.php
Go to the documentation of this file.
1<?php
2
19use ILIAS\Setup;
20use ILIAS\DI;
21
23{
24 protected function getTentativePreconditions(Setup\Environment $environment): array
25 {
26 return [
28 ];
29 }
30
31 protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage): void
32 {
33 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
34 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
35
36 if (!$client_ini || !$db) {
37 return;
38 }
39
40 // ATTENTION: This is a total abomination. It only exists to allow various
41 // sub components of the various readers to run. This is a memento to the
42 // fact, that dependency injection is something we want. Currently, every
43 // component could just service locate the whole world via the global $DIC.
44 $DIC = $GLOBALS["DIC"];
45 $GLOBALS["DIC"] = new DI\Container();
47 $GLOBALS["DIC"]["ilDB"] = $db;
48
50 $settings->readFromIniFile($client_ini);
51
52 $service_type = (int) $settings->getService();
54 $storage->storeConfigText(
55 "service",
57 "The backend that is used for the ILIAS cache."
58 );
59 $storage->storeConfigBool(
60 "active",
61 (bool) $settings->isActive()
62 );
63
64 $servers = ilMemcacheServer::get();
65 if (
66 $service_type === ilGlobalCache::TYPE_MEMCACHED &&
67 count($servers) > 0
68 ) {
69 $server_collection = [];
70 foreach ($servers as $server) {
71 $active = new Setup\Metrics\Metric(
72 Setup\Metrics\Metric::STABILITY_CONFIG,
73 Setup\Metrics\Metric::TYPE_BOOL,
74 $server->isActive()
75 );
76 $host = new Setup\Metrics\Metric(
77 Setup\Metrics\Metric::STABILITY_CONFIG,
78 Setup\Metrics\Metric::TYPE_TEXT,
79 $server->getHost()
80 );
81 $port = new Setup\Metrics\Metric(
82 Setup\Metrics\Metric::STABILITY_CONFIG,
83 Setup\Metrics\Metric::TYPE_GAUGE,
84 $server->getPort()
85 );
86 $weight = new Setup\Metrics\Metric(
87 Setup\Metrics\Metric::STABILITY_CONFIG,
88 Setup\Metrics\Metric::TYPE_GAUGE,
89 $server->getWeight()
90 );
91
92 $server_collection[] = new Setup\Metrics\Metric(
93 Setup\Metrics\Metric::STABILITY_CONFIG,
94 Setup\Metrics\Metric::TYPE_COLLECTION,
95 [
96 "active" => $active,
97 "host" => $host,
98 "port" => $port,
99 "weight" => $weight
100 ],
101 "Configured memcached node."
102 );
103 }
104
105 $nodes = new Setup\Metrics\Metric(
106 Setup\Metrics\Metric::STABILITY_CONFIG,
107 Setup\Metrics\Metric::TYPE_COLLECTION,
108 $server_collection,
109 "Collection of configured memcached nodes."
110 );
111 $storage->store("memcached_nodes", $nodes);
112 }
113
114 $component_activation = [];
115 foreach (ilGlobalCache::getAvailableComponents() as $component) {
116 $component_activation[$component] = new Setup\Metrics\Metric(
117 Setup\Metrics\Metric::STABILITY_CONFIG,
118 Setup\Metrics\Metric::TYPE_BOOL,
119 $settings->isComponentActivated($component)
120 );
121 }
122 $component_activation = new Setup\Metrics\Metric(
123 Setup\Metrics\Metric::STABILITY_CONFIG,
124 Setup\Metrics\Metric::TYPE_COLLECTION,
125 $component_activation,
126 "Which components are activated to use caching?"
127 );
128 $storage->store(
129 "components",
130 $component_activation
131 );
132
133 $GLOBALS["DIC"] = $DIC;
134 }
135}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
A metric is something we can measure about the system.
Definition: Metric.php:34
collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage)
Class ilGlobalCacheSettings.
static lookupServiceConfigName(int $service_type)
static getAvailableComponents()
$server
global $DIC
Definition: feed.php:28
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
$service
Definition: ltiservices.php:43
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Container.php:19
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...