ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilGlobalCacheMetricsCollectedObjective.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2020 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6use ILIAS\DI;
7
9{
10 public function getTentativePreconditions(Setup\Environment $environment) : array
11 {
12 return [
14 ];
15 }
16
17 public function collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage) : void
18 {
19 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
20 $client_ini = $environment->getResource(Setup\Environment::RESOURCE_CLIENT_INI);
21
22 if (!$client_ini || !$db) {
23 return;
24 }
25
26 // ATTENTION: This is a total abomination. It only exists to allow various
27 // sub components of the various readers to run. This is a memento to the
28 // fact, that dependency injection is something we want. Currently, every
29 // component could just service locate the whole world via the global $DIC.
30 $DIC = $GLOBALS["DIC"];
31 $GLOBALS["DIC"] = new DI\Container();
32 $GLOBALS["DIC"]["ilDB"] = $db;
33
34 $settings = new ilGlobalCacheSettings();
35 $settings->readFromIniFile($client_ini);
36
37 $service_type = (int) $settings->getService();
39 $storage->storeConfigText(
40 "service",
42 "The backend that is used for the ILIAS cache."
43 );
44 $storage->storeConfigBool(
45 "active",
46 (bool) $settings->isActive()
47 );
48
49 $servers = ilMemcacheServer::get();
50 if (
51 $service_type === ilGlobalCache::TYPE_MEMCACHED &&
52 count($servers) > 0
53 ) {
54 $server_collection = [];
55 foreach ($servers as $server) {
56 $active = new Setup\Metrics\Metric(
57 Setup\Metrics\Metric::STABILITY_CONFIG,
58 Setup\Metrics\Metric::TYPE_BOOL,
59 $server->isActive()
60 );
61 $host = new Setup\Metrics\Metric(
62 Setup\Metrics\Metric::STABILITY_CONFIG,
63 Setup\Metrics\Metric::TYPE_TEXT,
64 $server->getHost()
65 );
66 $port = new Setup\Metrics\Metric(
67 Setup\Metrics\Metric::STABILITY_CONFIG,
68 Setup\Metrics\Metric::TYPE_TEXT,
69 $server->getPort()
70 );
71 $weight = new Setup\Metrics\Metric(
72 Setup\Metrics\Metric::STABILITY_CONFIG,
73 Setup\Metrics\Metric::TYPE_TEXT,
74 $server->getWeight()
75 );
76
77 $server_collection[] = new Setup\Metrics\Metric(
78 Setup\Metrics\Metric::STABILITY_CONFIG,
79 Setup\Metrics\Metric::TYPE_COLLECTION,
80 [
81 "active" => $active,
82 "host" => $host,
83 "port" => $port,
84 "weight" => $weight
85 ],
86 "Configured memcached node."
87 );
88 }
89
90 $nodes = new Setup\Metrics\Metric(
91 Setup\Metrics\Metric::STABILITY_CONFIG,
92 Setup\Metrics\Metric::TYPE_COLLECTION,
93 $server_collection,
94 "Collection of configured memcached nodes."
95 );
96 $storage->store("memcached_nodes", $nodes);
97 }
98
99 $component_activation = [];
100 foreach (ilGlobalCache::getAvailableComponents() as $component) {
101 $component_activation[$component] = new Setup\Metrics\Metric(
102 Setup\Metrics\Metric::STABILITY_CONFIG,
103 Setup\Metrics\Metric::TYPE_BOOL,
104 $settings->isComponentActivated($component)
105 );
106 }
107 $component_activation = new Setup\Metrics\Metric(
108 Setup\Metrics\Metric::STABILITY_CONFIG,
109 Setup\Metrics\Metric::TYPE_COLLECTION,
110 $component_activation,
111 "Which components are activated to use caching?"
112 );
113 $storage->store(
114 "components",
115 $component_activation
116 );
117
118 $GLOBALS["DIC"] = $DIC;
119 }
120}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:19
A metric is something we can measure about the system.
Definition: Metric.php:18
collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage)
Class ilGlobalCacheSettings.
static lookupServiceConfigName(int $service_type)
static getAvailableComponents()
$server
global $DIC
Definition: goto.php:24
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$service
Definition: result.php:17