ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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)
 Get the goals the agent wants to achieve on setup.The provided configuration is to be used to set according configuration values in the installation.
Exceptions
InvalidArgumentExceptionif Config does not match the Agent..
More...
 
 getUpdateObjective (?Config $config=null)
 Get the goal the agent wants to achieve on update.The provided configuration is to be used to change according configuration values in the installation. If this is not possible for some reason, an according UnachievableException needs to be thrown in the according objective.The configuration is not to be used to initialize the required environment for the objectives. This must be done via ClientIdReadObjective and depending objectives like ilIniFilesLoadedObjective.If no configuration is provided the configuration of the component should stay as is.
Exceptions
InvalidArgumentExceptionif Config does not match the Agent..
More...
 
 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 ()
 @inheritDoc More...
 
 getNamedObjectives (?Config $config=null)
 Gets all named objectives The keys of the returned array are the commands. More...
 
- Public Member Functions inherited from ILIAS\Setup\Agent
 hasConfig ()
 Does this agent require a configuration? More...
 
 getArrayToConfigTransformation ()
 Agents must be able to tell how to create a configuration from a nested array. More...
 
 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...
 
 getBuildObjective ()
 Get the goal the agent wants to achieve to build artifacts. More...
 
 getStatusObjective (Metrics\Storage $storage)
 Get the objective to be achieved when status is requested. More...
 
 getMigrations ()
 Get a named map of migrations available for this Agent. 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.

102 : Node
103 {
104 return new Node(
105 (string) $node["host"],
106 (int) $node["port"],
107 (int) $node["weight"]
108 );
109 }

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

+ 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.

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 }
A transformation is a function from one datatype to another.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

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

+ 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 }
A non-objective, nothing to do to achieve it...
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31

◆ getInstallObjective()

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

Get the goals the agent wants to achieve on setup.The provided configuration is to be used to set according configuration values in the installation.

Exceptions
InvalidArgumentExceptionif Config does not match the Agent..

Implements ILIAS\Setup\Agent.

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 }
Signals that some goal won't be achievable by actions of the system ever.

◆ getMigrations()

ilGlobalCacheSetupAgent::getMigrations ( )

@inheritDoc

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)

Gets all named objectives The keys of the returned array are the commands.

Only the AgentCollection should return an array where the cmd of the named objective is the array key.

Parameters
Config | null$config
Returns
array<string|int, ObjectiveConstructor>

Implements ILIAS\Setup\Agent.

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)

◆ getUpdateObjective()

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

Get the goal the agent wants to achieve on update.The provided configuration is to be used to change according configuration values in the installation. If this is not possible for some reason, an according UnachievableException needs to be thrown in the according objective.The configuration is not to be used to initialize the required environment for the objectives. This must be done via ClientIdReadObjective and depending objectives like ilIniFilesLoadedObjective.If no configuration is provided the configuration of the component should stay as is.

Exceptions
InvalidArgumentExceptionif Config does not match the Agent..

Implements ILIAS\Setup\Agent.

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 }

◆ 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: