ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilGlobalCacheMetricsCollectedObjective Class Reference
+ Inheritance diagram for ilGlobalCacheMetricsCollectedObjective:
+ Collaboration diagram for ilGlobalCacheMetricsCollectedObjective:

Public 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 
)

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

References $DIC, $GLOBALS, $server, $service, ActiveRecord\get(), ilGlobalCache\getAvailableComponents(), ilGlobalCache\lookupServiceConfigName(), and ilGlobalCache\TYPE_MEMCACHED.

17  : 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 
35  $settings->readFromIniFile($client_ini);
36 
37  $service_type = (int) $settings->getService();
39  $storage->storeConfigText(
40  "service",
41  $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  }
Class ilGlobalCacheSettings.
static getAvailableComponents()
$service
Definition: result.php:17
global $DIC
Definition: goto.php:24
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$server
static lookupServiceConfigName(int $service_type)
+ Here is the call graph for this function:

◆ getTentativePreconditions()

ilGlobalCacheMetricsCollectedObjective::getTentativePreconditions ( Setup\Environment  $environment)

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

10  : array
11  {
12  return [
14  ];
15  }

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