ILIAS  release_8 Revision v8.24
ilGlobalCacheMetricsCollectedObjective Class Reference
+ Inheritance diagram for ilGlobalCacheMetricsCollectedObjective:
+ Collaboration diagram for ilGlobalCacheMetricsCollectedObjective:

Protected Member Functions

 getTentativePreconditions (Setup\Environment $environment)
 
 collectFrom (Setup\Environment $environment, Setup\Metrics\Storage $storage)
 

Detailed Description

Member Function Documentation

◆ collectFrom()

ilGlobalCacheMetricsCollectedObjective::collectFrom ( Setup\Environment  $environment,
Setup\Metrics\Storage  $storage 
)
protected

@noinspection PhpArrayIndexImmediatelyRewrittenInspection

Definition at line 31 of file class.ilGlobalCacheMetricsCollectedObjective.php.

31 : 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 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Class ilGlobalCacheSettings.
static lookupServiceConfigName(int $service_type)
static getAvailableComponents()
$server
global $DIC
Definition: feed.php:28
$service
Definition: ltiservices.php:43
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200

References $DIC, $GLOBALS, $server, $service, ILIAS\LTI\ToolProvider\$settings, ActiveRecord\get(), ilGlobalCache\getAvailableComponents(), ILIAS\Repository\int(), ilGlobalCache\lookupServiceConfigName(), and ilGlobalCache\TYPE_MEMCACHED.

+ Here is the call graph for this function:

◆ getTentativePreconditions()

ilGlobalCacheMetricsCollectedObjective::getTentativePreconditions ( Setup\Environment  $environment)
protected

Definition at line 24 of file class.ilGlobalCacheMetricsCollectedObjective.php.

24 : array
25 {
26 return [
28 ];
29 }

The documentation for this class was generated from the following file: