ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilGlobalCacheSetupAgent Class Reference
+ Inheritance diagram for ilGlobalCacheSetupAgent:
+ Collaboration diagram for ilGlobalCacheSetupAgent:

Public Member Functions

 __construct (protected Factory $refinery)
 
 hasConfig ()
 Does this agent require a configuration? More...
 
 getArrayToConfigTransformation ()
 Agents must be able to tell how to create a configuration from a nested array.
Exceptions
LogicExceptionif Agent has no Config
More...
 
 getInstallObjective (?Config $config=null)
 
 getUpdateObjective (?Config $config=null)
 
 getBuildObjective ()
 Get the goal the agent wants to achieve to build artifacts.
Exceptions
InvalidArgumentExceptionif Config does not match the Agent.
More...
 
 getStatusObjective (Storage $storage)
 
 getMigrations ()
 
 getNamedObjectives (?Config $config=null)
 
- Public Member Functions inherited from ILIAS\Setup\Agent
 getInstallObjective (?Config $config=null)
 Get the goals the agent wants to achieve on setup. More...
 
 getUpdateObjective (?Config $config=null)
 Get the goal the agent wants to achieve on update. More...
 
 getStatusObjective (Metrics\Storage $storage)
 Get the objective to be achieved when status is requested. More...
 
 getNamedObjectives (?Config $config=null)
 Gets all named objectives The keys of the returned array are the commands. More...
 

Protected Member Functions

 convertNode (array $node)
 

Detailed Description

Definition at line 32 of file class.ilGlobalCacheSetupAgent.php.

Constructor & Destructor Documentation

◆ __construct()

ilGlobalCacheSetupAgent::__construct ( protected Factory  $refinery)

Definition at line 34 of file class.ilGlobalCacheSetupAgent.php.

35  {
36  }

Member Function Documentation

◆ convertNode()

ilGlobalCacheSetupAgent::convertNode ( array  $node)
protected

Definition at line 102 of file class.ilGlobalCacheSetupAgent.php.

Referenced by getArrayToConfigTransformation(), and ILIAS\Tests\GlobalCache\Setup\TestObj\getMServer().

102  : Node
103  {
104  return new Node(
105  (string) $node["host"],
106  (int) $node["port"],
107  (int) $node["weight"]
108  );
109  }
+ Here is the caller graph for this function:

◆ getArrayToConfigTransformation()

ilGlobalCacheSetupAgent::getArrayToConfigTransformation ( )

Agents must be able to tell how to create a configuration from a nested array.

Exceptions
LogicExceptionif Agent has no Config

Implements ILIAS\Setup\Agent.

Definition at line 49 of file class.ilGlobalCacheSetupAgent.php.

References $data, convertNode(), null, and ILIAS\Repository\refinery().

50  {
51  return $this->refinery->custom()->transformation(function ($data): \ilGlobalCacheSettingsAdapter {
52  $settings = new \ilGlobalCacheSettingsAdapter();
53  if (
54  $data === null ||
55  !isset($data["components"]) ||
56  !$data["components"] ||
57  !isset($data["service"]) ||
58  $data["service"] === "none" ||
59  (
60  $data["service"] === "memcached" &&
61  (!isset($data["memcached_nodes"]) || count($data["memcached_nodes"]) === 0)
62  )
63  ) {
64  $settings->setActive(false);
65  } else {
66  $settings->setActive(true);
67  switch ($data["service"]) {
68  case "xcache": // xcache has been removed in ILIAS 8, we switch to static cache then
69  case "static":
70  $settings->setService(\ILIAS\Cache\Config::PHPSTATIC);
71  break;
72  case "memcached":
73  array_walk($data["memcached_nodes"], function (array $node) use ($settings): void {
74  $settings->addMemcachedNode($this->convertNode($node));
75  });
76  $settings->setService(\ILIAS\Cache\Config::MEMCACHED);
77  break;
78  case "apc":
79  $settings->setService(\ILIAS\Cache\Config::APCU);
80  break;
81  default:
82  throw new \InvalidArgumentException(
83  sprintf("Unknown caching service: '%s'", $data["service"])
84  );
85  }
86  $settings->resetActivatedComponents();
87  if ($data["components"] === "all") {
88  $settings->activateAll();
89  } else {
90  foreach ($data["components"] as $cmp => $active) {
91  if ($active) {
92  $settings->addActivatedComponent($cmp);
93  }
94  }
95  }
96  }
97 
98  return $settings;
99  });
100  }
Interface Observer Contains several chained tasks and infos about them.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
A transformation is a function from one datatype to another.
+ Here is the call graph for this function:

◆ getBuildObjective()

ilGlobalCacheSetupAgent::getBuildObjective ( )

Get the goal the agent wants to achieve to build artifacts.

Exceptions
InvalidArgumentExceptionif Config does not match the Agent.

Implements ILIAS\Setup\Agent.

Definition at line 136 of file class.ilGlobalCacheSetupAgent.php.

136  : Objective
137  {
138  return new NullObjective();
139  }
An objective is a desired state of the system that is supposed to be created by the setup...
Definition: Objective.php:30
A non-objective, nothing to do to achieve it...

◆ getInstallObjective()

ilGlobalCacheSetupAgent::getInstallObjective ( ?Config  $config = null)

Definition at line 114 of file class.ilGlobalCacheSetupAgent.php.

114  : Objective
115  {
116  if (!$config instanceof ilGlobalCacheSettingsAdapter) {
117  throw new UnachievableException('wrong config type, expected ilGlobalCacheSettings');
118  }
119  return new ilGlobalCacheConfigStoredObjective($config);
120  }
An objective is a desired state of the system that is supposed to be created by the setup...
Definition: Objective.php:30
Signals that some goal won't be achievable by actions of the system ever.

◆ getMigrations()

ilGlobalCacheSetupAgent::getMigrations ( )

Implements ILIAS\Setup\Agent.

Definition at line 152 of file class.ilGlobalCacheSetupAgent.php.

152  : array
153  {
154  return [];
155  }

◆ getNamedObjectives()

ilGlobalCacheSetupAgent::getNamedObjectives ( ?Config  $config = null)

Definition at line 157 of file class.ilGlobalCacheSetupAgent.php.

157  : array
158  {
159  $config ??= new ilGlobalCacheSettingsAdapter();
160  return [
161  'flushAll' => new ObjectiveConstructor(
162  'flushes all GlobalCaches.',
164  )
165  ];
166  }

◆ getStatusObjective()

ilGlobalCacheSetupAgent::getStatusObjective ( Storage  $storage)

Definition at line 144 of file class.ilGlobalCacheSetupAgent.php.

144  : Objective
145  {
146  return new ilGlobalCacheMetricsCollectedObjective($storage);
147  }
An objective is a desired state of the system that is supposed to be created by the setup...
Definition: Objective.php:30

◆ getUpdateObjective()

ilGlobalCacheSetupAgent::getUpdateObjective ( ?Config  $config = null)

Definition at line 125 of file class.ilGlobalCacheSetupAgent.php.

125  : Objective
126  {
127  if ($config instanceof ilGlobalCacheSettingsAdapter) {
128  return new ilGlobalCacheConfigStoredObjective($config);
129  }
130  return new NullObjective();
131  }
An objective is a desired state of the system that is supposed to be created by the setup...
Definition: Objective.php:30
A non-objective, nothing to do to achieve it...

◆ hasConfig()

ilGlobalCacheSetupAgent::hasConfig ( )

Does this agent require a configuration?

Implements ILIAS\Setup\Agent.

Definition at line 41 of file class.ilGlobalCacheSetupAgent.php.

41  : bool
42  {
43  return true;
44  }

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