From f7e3ad3f9e2322a6a8837409038c151bec2094f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 26 Mar 2010 04:20:25 +0000 Subject: [PATCH] Network package writer added, shutdown refactured, fixes: - New NetworkPackageWriterTask class introduced (unfinished) - Shutdown procedure refactured to make use of the visitor pattern - Several fixes/improvements, hub announcement still not working - TODOs.txt updated --- .gitattributes | 2 + application/hub/config.php | 18 +++ .../interfaces/package/class_Deliverable.php | 7 +- .../query/local/class_LocalQueryConnector.php | 21 +++ .../class_TaskHandlerInitializerFilter.php | 6 + .../main/handler/tasks/class_TaskHandler.php | 17 ++- .../class_HubDescriptorHelper.php | 22 ++-- .../hub/main/nodes/class_BaseHubNode.php | 1 - .../hub/main/package/class_NetworkPackage.php | 31 +++-- .../node/active/class_NodeActiveState.php | 10 ++ .../hub/main/states/node/announced/.htaccess | 1 + .../announced/class_NodeAnnouncedState.php | 60 +++++++++ application/hub/main/states/node/class_ | 6 +- .../states/node/init/class_NodeInitState.php | 2 + .../node/virgin/class_NodeVirginState.php | 2 +- application/hub/main/tasks/class_ | 2 +- application/hub/main/tasks/network/.htaccess | 1 + .../class_NetworkPackageWriterTask.php | 71 +++++++++++ .../tasks/class_ShutdownTaskVisitor.php | 120 ++++++++++++++++++ docs/TODOs.txt | 112 ++++++++++------ 20 files changed, 439 insertions(+), 73 deletions(-) create mode 100644 application/hub/main/states/node/announced/.htaccess create mode 100644 application/hub/main/states/node/announced/class_NodeAnnouncedState.php create mode 100644 application/hub/main/tasks/network/.htaccess create mode 100644 application/hub/main/tasks/network/class_NetworkPackageWriterTask.php create mode 100644 application/hub/main/visitor/tasks/class_ShutdownTaskVisitor.php diff --git a/.gitattributes b/.gitattributes index a859566fa..0f747dee3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -257,6 +257,7 @@ application/hub/main/states/hub/class_BaseHubState.php -text application/hub/main/states/node/.htaccess -text application/hub/main/states/node/active/.htaccess -text application/hub/main/states/node/active/class_NodeActiveState.php -text +application/hub/main/states/node/announced/.htaccess -text application/hub/main/states/node/class_ -text application/hub/main/states/node/class_BaseNodeState.php -text application/hub/main/states/node/init/.htaccess -text @@ -276,6 +277,7 @@ application/hub/main/tasks/hub/update/.htaccess -text application/hub/main/tasks/hub/update/class_HubUpdateCheckTask.php -text application/hub/main/tasks/idle/.htaccess -text application/hub/main/tasks/idle/class_IdleLoopTask.php -text +application/hub/main/tasks/network/.htaccess -text application/hub/main/template/.htaccess -text application/hub/main/template/announcement/.htaccess -text application/hub/main/template/announcement/class_AnnouncementTemplateEngine.php -text diff --git a/application/hub/config.php b/application/hub/config.php index b870f54ba..99d368310 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -102,6 +102,9 @@ $cfg->setConfigEntry('tcp_network_package_handler_class', 'TcpNetworkPackageHand // CFG: SHUTDOWN-LISTENER-POOL-VISITOR-CLASS $cfg->setConfigEntry('shutdown_listener_pool_visitor_class', 'ShutdownListenerPoolVisitor'); +// CFG: SHUTDOWN-TASK-VISITOR-CLASS +$cfg->setConfigEntry('shutdown_task_visitor_class', 'ShutdownTaskVisitor'); + // CFG: ACTIVE-TASK-VISITOR-CLASS $cfg->setConfigEntry('active_task_visitor_class', 'ActiveTaskVisitor'); @@ -285,6 +288,18 @@ $cfg->setConfigEntry('hub_ping_task_class', 'HubPingTask'); // CFG: HUB-SELF-ANNOUNCEMENT-TASK-CLASS $cfg->setConfigEntry('hub_self_announcement_task_class', 'HubSelfAnnouncementTask'); +// CFG: HUB-PACKAGE-WRITER-TASK-CLASS +$cfg->setConfigEntry('hub_package_writer_task_class', 'NetworkPackageWriterTask'); + +// CFG: TASK-NETWORK-PACKAGE-WRITER-STARTUP-DELAY +$cfg->setConfigEntry('task_network_package_writer_startup_delay', 2500); + +// CFG: TASK-NETWORK-PACKAGE-WRITER-INTERVAL-DELAY +$cfg->setConfigEntry('task_network_package_writer_interval_delay', 10); + +// CFG: TASK-NETWORK-PACKAGE-WRITER-MAX-RUNS +$cfg->setConfigEntry('task_network_package_writer_max_runs', 0); + // CFG: TASK-LIST-CLASS $cfg->setConfigEntry('task_list_class', 'TaskList'); @@ -318,6 +333,9 @@ $cfg->setConfigEntry('node_virgin_state_class', 'NodeVirginState'); // CFG: NODE-ACTIVE-STATE-CLASS $cfg->setConfigEntry('node_active_state_class', 'NodeActiveState'); +// CFG: NODE-ANNOUNCED-STATE-CLASS +$cfg->setConfigEntry('node_announced_state_class', 'NodeAnnouncedState'); + // CFG: NETWORK-PACKAGE-CLASS $cfg->setConfigEntry('network_package_class', 'NetworkPackage'); diff --git a/application/hub/interfaces/package/class_Deliverable.php b/application/hub/interfaces/package/class_Deliverable.php index a97c93fc4..072bcd765 100644 --- a/application/hub/interfaces/package/class_Deliverable.php +++ b/application/hub/interfaces/package/class_Deliverable.php @@ -23,15 +23,14 @@ */ interface Deliverable extends FrameworkInterface { /** - * "Queues" raw content into this delivery class by reading the raw content + * "Enqueues" raw content into this delivery class by reading the raw content * from given template instance. * - * @param $templateInstance A CompileableTemplate instance + * @param $helperInstance A BaseHubHelper instance * @return void */ - function queueRawDataFromTemplate (CompileableTemplate $templateInstance); + function enqueueRawDataFromTemplate (BaseHubHelper $helperInstance); } // [EOF] ?> - diff --git a/application/hub/main/connectors/query/local/class_LocalQueryConnector.php b/application/hub/main/connectors/query/local/class_LocalQueryConnector.php index 88dd5c3f2..1a56b1777 100644 --- a/application/hub/main/connectors/query/local/class_LocalQueryConnector.php +++ b/application/hub/main/connectors/query/local/class_LocalQueryConnector.php @@ -70,6 +70,27 @@ class LocalQueryConnector extends BaseQueryConnector implements Connectable, Vis return $connectorInstance; } + /** + * Handles the in the list avaiable query (current) and hands it over to the + * query processor instance + * + * @return void + * @TODO Unfinished work here + */ + private function handleCurrentQuery () { + // Is there a query available? + if (!$this->getIteratorInstance()->valid()) { + // Simply abort here + return; + } // END - if + + // Get the current query + $currentQuery = $this->getIteratorInstance()->current(); + + // Only while construction, else it would output to much! + /* DEBUG: */ $this->debugOutput('CONNECTOR: Handling query ' . $currentQuery); + } + /** * Accepts the visitor to process the visit "request" * diff --git a/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php b/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php index dae02e044..4a2dff856 100644 --- a/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php +++ b/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php @@ -70,6 +70,12 @@ class TaskHandlerInitializerFilter extends BaseFilter implements Filterable { // Network package reader, needs to be delayed a little $handlerInstance->registerTask('network_package_reader', $nodeInstance->getListenerPoolInstance()); + // Generate package writer task + $taskInstance = ObjectFactory::createObjectByConfiguredName('hub_package_writer_task_class'); + + // Register it as well + $handlerInstance->registerTask('network_package_writer', $taskInstance); + // Query handler instance $handlerInstance->registerTask('query_handler', $nodeInstance->getQueryConnectorInstance()); diff --git a/application/hub/main/handler/tasks/class_TaskHandler.php b/application/hub/main/handler/tasks/class_TaskHandler.php index a1ecf3016..f96df781e 100644 --- a/application/hub/main/handler/tasks/class_TaskHandler.php +++ b/application/hub/main/handler/tasks/class_TaskHandler.php @@ -154,12 +154,18 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { /** * Unregisters the given task * - * @param $taskName Name of the task + * @param $taskData Data of the task * @return void */ - private function unregisterTask ($taskName) { + private function unregisterTask (array $taskData) { + // Debug output + $this->debugOutput('TASK-HANDLER: Removing task ' . $taskData['id'] . ' from queue - START'); + // Remove the entry - $this->getListInstance()->removeEntry('tasks', $taskName); + $this->getListInstance()->removeEntry('tasks', $taskData); + + // Debug output + $this->debugOutput('TASK-HANDLER: Removing task ' . $taskData['id'] . ' from queue - FINISHED'); } /** @@ -262,6 +268,9 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { // Remember all tasks that has been shutdown for removal $tasks = array(); + // Instance a visitor + $this->visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_task_visitor_class'); + // Shutdown all tasks in once go while ($this->getIteratorInstance()->valid()) { // Get current entry @@ -271,7 +280,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask { $this->debugOutput('TASK-HANDLER: Shutting down task ' . $current['id'] . ' (taskInstance=' . $current['task_instance']->__toString() . ') ...'); // Shutdown the task - $current['task_instance']->doShutdown(); + $current['task_instance']->accept($this->visitorInstance); // Remember this task $tasks[] = $current; diff --git a/application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php b/application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php index 91812d27d..ea2253336 100644 --- a/application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php +++ b/application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php @@ -110,19 +110,21 @@ class HubDescriptorHelper extends BaseHubHelper { // Prepare the decorator compressor (for later flawless and easy updates) $compressorInstance = ObjectFactory::createObjectByConfiguredName('deco_package_compressor_class', array($compressorInstance)); - // Now prepare the network package for delivery so only need to do this - // once just before the "big announcement loop". - $packageInstance = ObjectFactory::createObjectByConfiguredName('network_package_class', array($compressorInstance)); - - // Enable re-queue support which re-queues the below feeded content - // into the delivery method all over again. - $packageInstance->enableDataReQueueing(); + // Do we have an instance in the registry? + if (Registry::getRegistry()->instanceExists('network_package')) { + // Then use this instance + $packageInstance = Registry::getRegistry()->getInstance('network_package'); + } else { + // Now prepare the network package for delivery so only need to do this + // once just before the "big announcement loop". + $packageInstance = ObjectFactory::createObjectByConfiguredName('network_package_class', array($compressorInstance)); + } // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->queueRawDataFromTemplate($this->getTemplateInstance()); + $packageInstance->enqueueRawDataFromTemplate($this); - // Debug only: - /* DEBUG: */ die(print_r($this->getTemplateInstance(), true)); + // Set the instance in registry for further use + Registry::getRegistry()->addInstance('network_package', $packageInstance); } } diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index 784c9a15c..f9d1cdf9c 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -470,7 +470,6 @@ class BaseHubNode extends BaseHubSystem implements Updateable { // Change the state, this should be the last line except debug output $this->getStateInstance()->nodeAnnouncedToUpperHubs(); - die("OK!\n"); // Debug output $this->debugOutput('HUB: Self-announcement: FINISHED'); diff --git a/application/hub/main/package/class_NetworkPackage.php b/application/hub/main/package/class_NetworkPackage.php index f47e10b4f..4f6551c27 100644 --- a/application/hub/main/package/class_NetworkPackage.php +++ b/application/hub/main/package/class_NetworkPackage.php @@ -34,12 +34,17 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class NetworkPackage extends BaseFrameworkSystem implements Deliverable { +class NetworkPackage extends BaseFrameworkSystem implements Deliverable, Registerable { /** * Package mask for compressing package data */ const PACKAGE_MASK = '%s:%s:%s'; + /** + * Stacker name for "undeclared" packages + */ + const STACKER_NAME_UNDECLARED = 'undeclared'; + /** * Protected constructor * @@ -78,28 +83,32 @@ class NetworkPackage extends BaseFrameworkSystem implements Deliverable { } /** - * "Queues" raw content into this delivery class by reading the raw content + * "Enqueues" raw content into this delivery class by reading the raw content * from given template instance and pushing it on the 'undeclared' stack. * - * @param $templateInstance A CompileableTemplate instance + * @param $helperInstance A BaseHubHelper instance * @return void */ - public function queueRawDataFromTemplate (CompileableTemplate $templateInstance) { - // Get the raw content and compress it - $content = $this->getCompressorInstance()->compressStream($templateInstance->getRawTemplateData()); + public function enqueueRawDataFromTemplate (BaseHubHelper $helperInstance) { + // Get the raw content ... + $content = $helperInstance->getTemplateInstance()->getRawTemplateData(); + + // ... and compress it + $content = $this->getCompressorInstance()->compressStream($content); // Add magic in front of it and hash behind it, including BASE64 encoding $content = sprintf(self::PACKAGE_MASK, $this->getCompressorInstance()->getCompressorExtension(), base64_encode($content), - crc32($content) // Not so good, but needs to be fast! + crc32($content) // @TODO Not so good, but needs to be fast! ); - // Now prepare the temporary array and push it on the 'undeclared' stack - $this->getStackerInstance()->pushNamed('undeclared', array( - 'sender' => null, + // Now prepare the temporary array and push it on the 'undeclared' stack including a call-back helper instance + $this->getStackerInstance()->pushNamed(self::STACKER_NAME_UNDECLARED, array( + 'sender' => $helperInstance->getNodeInstance()->getSessionId(), 'recipient' => null, - 'content' => $content + 'content' => $content, + 'callback' => $helperInstance )); } } diff --git a/application/hub/main/states/node/active/class_NodeActiveState.php b/application/hub/main/states/node/active/class_NodeActiveState.php index 9544e3a5a..c6c58771c 100644 --- a/application/hub/main/states/node/active/class_NodeActiveState.php +++ b/application/hub/main/states/node/active/class_NodeActiveState.php @@ -54,6 +54,16 @@ class NodeActiveState extends BaseNodeState implements Stateable { // Return the prepared instance return $stateInstance; } + + /** + * State change for if the node got announced to it's upper hubs + * + * @return void + */ + public function nodeAnnouncedToUpperHubs () { + // Create the new state instance + StateFactory::createStateInstanceByName('announced', $this->getNodeInstance()); + } } // [EOF] diff --git a/application/hub/main/states/node/announced/.htaccess b/application/hub/main/states/node/announced/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/states/node/announced/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/states/node/announced/class_NodeAnnouncedState.php b/application/hub/main/states/node/announced/class_NodeAnnouncedState.php new file mode 100644 index 000000000..0e2c10a91 --- /dev/null +++ b/application/hub/main/states/node/announced/class_NodeAnnouncedState.php @@ -0,0 +1,60 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeAnnouncedState extends BaseState implements Stateable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set state name + $this->setStateName('announced'); + } + + /** + * Creates an instance of this class + * + * @param $nodeInstance An instance of a NodeHelper class + * @return $stateInstance An instance of a Stateable class + */ + public final static function createNodeAnnouncedState (NodeHelper $nodeInstance) { + // Get new instance + $stateInstance = new NodeAnnouncedState(); + + // Debug message + $stateInstance->debugOutput('NODE-STATE: Has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); + + // Set the node instance + $stateInstance->setNodeInstance($nodeInstance); + + // Return the prepared instance + return $stateInstance; + } +} + +// [EOF] +?> diff --git a/application/hub/main/states/node/class_ b/application/hub/main/states/node/class_ index 7d73f8d30..f19ed1d87 100644 --- a/application/hub/main/states/node/class_ +++ b/application/hub/main/states/node/class_ @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class Node???State extends BaseState implements NodeStateable { +class Node???State extends BaseState implements Stateable { /** * Protected constructor * @@ -39,14 +39,14 @@ class Node???State extends BaseState implements NodeStateable { * Creates an instance of this class * * @param $nodeInstance An instance of a NodeHelper class - * @return $stateInstance An instance of a NodeStateable class + * @return $stateInstance An instance of a Stateable class */ public final static function createNode???State (NodeHelper $nodeInstance) { // Get new instance $stateInstance = new Node???State(); // Debug message - $stateInstance->debugOutput("NODE-STATE: Has changed from " . $nodeInstance->getPrintableState() . " to " . $stateInstance->getStateName() . "."); + $stateInstance->debugOutput('NODE-STATE: Has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.'); // Set the node instance $stateInstance->setNodeInstance($nodeInstance); diff --git a/application/hub/main/states/node/init/class_NodeInitState.php b/application/hub/main/states/node/init/class_NodeInitState.php index 2d0092d2a..ff41619fe 100644 --- a/application/hub/main/states/node/init/class_NodeInitState.php +++ b/application/hub/main/states/node/init/class_NodeInitState.php @@ -58,6 +58,8 @@ class NodeInitState extends BaseNodeState implements Stateable { /** * State change for if the node has just generated a session id. This makes * nodes with current state 'init' now 'virgin'. + * + * @return void */ public function nodeGeneratedSessionId () { // Create the new state instance diff --git a/application/hub/main/states/node/virgin/class_NodeVirginState.php b/application/hub/main/states/node/virgin/class_NodeVirginState.php index 65a3fc6ad..fd8e498fe 100644 --- a/application/hub/main/states/node/virgin/class_NodeVirginState.php +++ b/application/hub/main/states/node/virgin/class_NodeVirginState.php @@ -60,7 +60,7 @@ class NodeVirginState extends BaseNodeState implements Stateable { * listeners, tasks, queues, etc. An active hub does not imply that it * can be reached from outside so we have to deal with that state with * yet another state class. - * + * * @return void */ public function nodeIsActivated () { diff --git a/application/hub/main/tasks/class_ b/application/hub/main/tasks/class_ index cae03fc15..e390c2fe8 100644 --- a/application/hub/main/tasks/class_ +++ b/application/hub/main/tasks/class_ @@ -35,7 +35,7 @@ class ???Task extends BaseTask implements Taskable, Visitable { /** * Creates an instance of this class * - * @return $taskInstance An instance of a Visitable class + * @return $taskInstance An instance of a Visitable class */ public final static function create???Task () { // Get new instance diff --git a/application/hub/main/tasks/network/.htaccess b/application/hub/main/tasks/network/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/tasks/network/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/tasks/network/class_NetworkPackageWriterTask.php b/application/hub/main/tasks/network/class_NetworkPackageWriterTask.php new file mode 100644 index 000000000..ebaedf184 --- /dev/null +++ b/application/hub/main/tasks/network/class_NetworkPackageWriterTask.php @@ -0,0 +1,71 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NetworkPackageWriterTask extends BaseTask implements Taskable, Visitable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $taskInstance An instance of a Visitable class + */ + public final static function createNetworkPackageWriterTask () { + // Get new instance + $taskInstance = new NetworkPackageWriterTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo 0% + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function execute () { + $this->partialStub('Unimplemented task.'); + } +} + +// [EOF] +?> diff --git a/application/hub/main/visitor/tasks/class_ShutdownTaskVisitor.php b/application/hub/main/visitor/tasks/class_ShutdownTaskVisitor.php new file mode 100644 index 000000000..cf1753f49 --- /dev/null +++ b/application/hub/main/visitor/tasks/class_ShutdownTaskVisitor.php @@ -0,0 +1,120 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class ShutdownTaskVisitor extends BaseVisitor implements TaskVisitor, QueryConnectorVisitor, PoolVisitor, ListenerVisitor, DecoratorVisitor { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set visitor mode + $this->setVisitorMode('task'); + } + + /** + * Creates an instance of this class + * + * @return $visitorInstance An instance a Visitorable class + */ + public final static function createShutdownTaskVisitor () { + // Get new instance + $visitorInstance = new ShutdownTaskVisitor(); + + // Return the prepared instance + return $visitorInstance; + } + + /** + * Visits the given task instance + * + * @param $taskInstance A Taskable instance + * @return void + */ + public function visitTask (Taskable $taskInstance) { + // Shutdown the task instance + $taskInstance->doShutdown(); + } + + /** + * Connector visitor method for active tasks + * + * @param $connectorInstance A Connectable instance + * @return void + */ + public function visitQueryConnector (Connectable $connectorInstance) { + // Shutdown the connector instance + $connectorInstance->doShutdown(); + } + + /** + * Pool visitor method for active tasks + * + * @param $poolInstance A Poolable instance + * @return void + */ + public function visitPool (Poolable $poolInstance) { + // Shutdown the pool instance + $poolInstance->doShutdown(); + } + + /** + * Query visitor method for active queries + * + * @param $queryInstance A Queryable instance + * @return void + * @todo Does a query needs to perform some actions as an active task? + */ + public function visitQuery (Queryable $queryInstance) { + // Shutdown the query instance + $queryInstance->doShutdown(); + } + + /** + * Visits the given listener instance + * + * @param $listenerInstance A Listenable instance + * @return void + */ + public function visitListener (Listenable $listenerInstance) { + // Shutdown the listener instance + $listenerInstance->doShutdown(); + } + + /** + * Visits the given decorator instance + * + * @param $decoratorInstance A decorator instance + * @return void + */ + public function visitDecorator (BaseDecorator $decoratorInstance) { + // Shutdown the decorator instance + $decoratorInstance->doShutdown(); + } +} + +// [EOF] +?> diff --git a/docs/TODOs.txt b/docs/TODOs.txt index 87a2bf96b..906dc88ef 100644 --- a/docs/TODOs.txt +++ b/docs/TODOs.txt @@ -1,35 +1,40 @@ ### WARNING: THIS FILE IS AUTO-GENERATED BY ./todo-builder.sh ### ### DO NOT EDIT THIS FILE. ### ./application/hub/interfaces/nodes/class_NodeHelper.php:10: * @todo We need to find a better name for this interface -./application/hub/main/commands/console/class_HubConsoleMainCommand.php:107: * @todo Should we add some more filters? +./application/hub/main/commands/console/class_HubConsoleMainCommand.php:108: * @todo Should we add some more filters? +./application/hub/main/commands/console/class_HubConsoleMainCommand.php:58: * @todo Try to create a HubActivationTask or so ./application/hub/main/connectors/query/local/class_LocalQueryConnector.php:10: * @todo Find an interface for: handleAllQueries() +./application/hub/main/connectors/query/local/class_LocalQueryConnector.php:78: * @TODO Unfinished work here ./application/hub/main/filter/activation/class_HubActivationSelfAnnouncementFilter.php:54: * @todo 0% done ./application/hub/main/filter/node/class_NodeInitializationFilter.php:54: * @todo 0% done ./application/hub/main/filter/node/class_NodeInitializationFilter.php:87: // @TODO Can we rewrite this to app_die() ? -./application/hub/main/filter/node/class_NodePhpRequirementsFilter.php:54: * @todo 0% done +./application/hub/main/filter/node/class_NodePhpRequirementsFilter.php:55: * @todo Add more test and try to add an extra message to the thrown exception ./application/hub/main/filter/shutdown/class_HubShutdownDeinitQueuesFilter.php:55: * @todo 0% done ./application/hub/main/filter/shutdown/class_HubShutdownFlushNodeListFilter.php:55: * @todo 0% done -./application/hub/main/filter/shutdown/class_HubShutdownListenerPoolFilter.php:55: * @todo 0% done +./application/hub/main/filter/shutdown/class_HubShutdownTaskHandlerFilter.php:55: * @todo 0% done ./application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php:55: * @todo 0% done ./application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php:61: * @todo 0% ./application/hub/main/handler/network/udp/class_UdpNetworkPackageHandler.php:55: * @todo 0% -./application/hub/main/handler/tasks/class_TaskHandler.php:143: // @TODO Messurement can be added around this call +./application/hub/main/handler/tasks/class_TaskHandler.php:133: // @TODO Messurement can be added around this call +./application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php:10: * @todo Find an interface for hub helper +./application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php:57: * @todo Rewrite the ->renderXmlContent() call to no arguments ./application/hub/main/iterator/network/class_NetworkListenIterator.php:10: * @todo This current implementation is not recommended, use a ./application/hub/main/iterator/network/class_NetworkListenIterator.php:11: * @todo latency-based iteration or similar approaches ./application/hub/main/iterator/pool/handler/class_HandlerPoolIterator.php:10: * @todo This current implementation is not recommended, use a ./application/hub/main/iterator/pool/handler/class_HandlerPoolIterator.php:11: * @todo latency-based iteration or similar approaches ./application/hub/main/iterator/pool/tasks/class_TaskPoolIterator.php:10: * @todo This current implementation is not recommended, use a ./application/hub/main/iterator/pool/tasks/class_TaskPoolIterator.php:11: * @todo latency-based iteration or similar approaches -./application/hub/main/listener/tcp/class_TcpListener.php:160: * @todo 0% done ./application/hub/main/listener/udp/class_UdpListener.php:61: * @todo stream_socket_server() was declared slow by some user comments. ./application/hub/main/listener/udp/class_UdpListener.php:62: * @todo Please rewrite it to socket_create() and its brothers. ./application/hub/main/listener/udp/class_UdpListener.php:85: * @todo 0% done -./application/hub/main/lists/class_BaseList.php:236: // @TODO Extend this somehow? +./application/hub/main/lists/class_BaseList.php:264: // @TODO Extend this somehow? ./application/hub/main/nodes/boot/class_HubBootNode.php:119: // @TODO Add some filters here ./application/hub/main/nodes/boot/class_HubBootNode.php:58: * @todo add some more special bootstrap things for this boot node ./application/hub/main/nodes/boot/class_HubBootNode.php:99: * @todo Unfinished method -./application/hub/main/nodes/class_BaseHubNode.php:356: * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem -./application/hub/main/nodes/class_BaseHubNode.php:529: // @TODO Add some criteria, e.g. if the node is active or so +./application/hub/main/nodes/class_BaseHubNode.php:407: * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem +./application/hub/main/nodes/class_BaseHubNode.php:444: * @todo Change the first if() block to check for a specific state +./application/hub/main/nodes/class_BaseHubNode.php:582: // @TODO Add some criteria, e.g. if the node is active or so +./application/hub/main/nodes/class_BaseHubNode.php:611: // @TODO Add more states e.g. 'firewalled', 'senior' ./application/hub/main/nodes/list/class_HubListNode.php:58: * @todo Implement more bootstrap steps ./application/hub/main/nodes/list/class_HubListNode.php:68: * @todo Unfinished method ./application/hub/main/nodes/list/class_HubListNode.php:91: // @TODO Add some filters here @@ -39,23 +44,27 @@ ./application/hub/main/nodes/regular/class_HubRegularNode.php:58: * @todo Implement this method ./application/hub/main/nodes/regular/class_HubRegularNode.php:68: * @todo Unfinished method ./application/hub/main/nodes/regular/class_HubRegularNode.php:91: // @TODO Add some filters here +./application/hub/main/package/class_NetworkPackage.php:103: crc32($content) // @TODO Not so good, but needs to be fast! +./application/hub/main/package/class_NetworkPackage.php:22: * @todo Needs to add functionality for handling the object's type ./application/hub/main/resolver/state/network/class_NetworkStateResolver.php:69: * @todo 0% ./application/hub/main/resolver/state/network/class_NetworkStateResolver.php:78: // @TODO On some systems it is 134, on some 107? ./application/hub/main/tasks/hub/announcement/class_HubSelfAnnouncementTask.php:53: * @todo 0% ./application/hub/main/tasks/hub/class_HubSelfConnectTask.php:53: * @todo 0% ./application/hub/main/tasks/hub/ping/class_HubPingTask.php:63: * @todo 0% ./application/hub/main/tasks/hub/update/class_HubUpdateCheckTask.php:53: * @todo 0% -./application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php:90: * @todo Does a query needs to perform some actions as an active task? -./inc/classes/exceptions/io/class_FileNotFoundException.php:10: * @todo Rename this class to FileIoException -./inc/classes/exceptions/main/class_ClassNotFoundException.php:10: * @todo Rename this class to NoClassException -./inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php:10: * @todo Rename this class to NoFoundEntryException +./application/hub/main/tasks/network/class_NetworkPackageWriterTask.php:53: * @todo 0% +./application/hub/main/template/announcement/class_AnnouncementTemplateEngine.php:10: * @todo This template engine does not make use of setTemplateType() +./application/hub/main/template/announcement/class_AnnouncementTemplateEngine.php:256: * @todo Find something useful with this! +./application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php:92: * @todo Does a query needs to perform some actions as an active task? +./application/hub/main/visitor/tasks/class_ShutdownTaskVisitor.php:89: * @todo Does a query needs to perform some actions as an active task? ./inc/classes/exceptions/main/class_MissingMethodException.php:13: * @todo Try to rewrite user/guest login classes and mark this exception as deprecated +./inc/classes/exceptions/main/class_NoConfigEntryException.php:10: * @todo Rename this class to NoFoundEntryException ./inc/classes/interfaces/class_FrameworkInterface.php:11: * @todo Find a better name for this interface -./inc/classes/main/class_BaseFrameworkSystem.php:1078: * @todo Write a logging mechanism for productive mode -./inc/classes/main/class_BaseFrameworkSystem.php:1092: // @TODO Finish this part! -./inc/classes/main/class_BaseFrameworkSystem.php:119: // @todo Try to clean these constants up -./inc/classes/main/class_BaseFrameworkSystem.php:200: * @todo This is old code. Do we still need this old lost code? -./inc/classes/main/class_BaseFrameworkSystem.php:268: * @todo SearchableResult and UpdateableResult shall have a super interface to use here +./inc/classes/main/class_BaseFrameworkSystem.php:1112: * @todo Write a logging mechanism for productive mode +./inc/classes/main/class_BaseFrameworkSystem.php:1126: // @TODO Finish this part! +./inc/classes/main/class_BaseFrameworkSystem.php:134: // @todo Try to clean these constants up +./inc/classes/main/class_BaseFrameworkSystem.php:215: * @todo This is old code. Do we still need this old lost code? +./inc/classes/main/class_BaseFrameworkSystem.php:283: * @todo SearchableResult and UpdateableResult shall have a super interface to use here ./inc/classes/main/commands/web/class_WebLoginAreaCommand.php:64: * @todo Add some stuff here: Some personal data, app/game related data ./inc/classes/main/commands/web/class_WebProblemCommand.php:58: * @todo 0% done ./inc/classes/main/commands/web/class_WebStatusCommand.php:58: * @todo 0% done @@ -74,6 +83,7 @@ ./inc/classes/main/criteria/search/class_SearchCriteria.php:114: * @todo Find a nice casting here. (int) allows until and including 32766. ./inc/classes/main/criteria/search/class_SearchCriteria.php:94: * @todo Find a nice casting here. (int) allows until and including 32766. ./inc/classes/main/database/databases/class_LocalFileDatabase.php:363: * @todo Do some checks on the database directory and files here +./inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php:426: * @todo Find something useful with this! ./inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php:82: * @todo 0% done ./inc/classes/main/filter/change/class_EmailChangeFilter.php:54: * @todo Implement email change of the user here. HINT: Use the User class! ./inc/classes/main/filter/change/class_PasswordChangeFilter.php:55: * @todo Finished updating user password hash here. HINT: Use the User class again. @@ -99,13 +109,15 @@ ./inc/classes/main/images/class_BaseImage.php:245: * @todo Find something usefull for this method. ./inc/classes/main/images/class_BaseImage.php:255: * @todo Find something usefull for this method. ./inc/classes/main/io/class_FileIoStream.php:74: * @todo This method needs heavy rewrite +./inc/classes/main/mailer/class_BaseMailer.php:60: // @TODO This needs testing/fixes because the deprecated method ./inc/classes/main/mailer/debug/class_DebugMailer.php:124: * @todo 0% done ./inc/classes/main/menu/class_BaseMenu.php:59: // @TODO Should we log it here? We should, because it will be silently ignored. ./inc/classes/main/output/class_ConsoleOutput.php:56: // @TODO Need to rewrite this to $requestInstance->addHeader() -./inc/classes/main/parser/xml/class_XmlParser.php:69: // @TODO We need to find a fallback solution here +./inc/classes/main/parser/xml/class_XmlParser.php:70: // @TODO We need to find a fallback solution here ./inc/classes/main/points/class_UserPoints.php:100: * @todo Finish loading part of points ./inc/classes/main/request/console/class_ConsoleRequest.php:115: // @TODO There are no cookies on console ./inc/classes/main/request/console/class_ConsoleRequest.php:55: * @todo Needs to be implemented +./inc/classes/main/request/web/class_HttpRequest.php:10: * @todo Move out the cookie part to a seperate class, e.g. Cookie ./inc/classes/main/response/http/class_HttpResponse.php:77: * @todo Encryption of cookie data not yet supported. ./inc/classes/main/response/http/class_HttpResponse.php:78: * @todo Why are these parameters conflicting? ./inc/classes/main/response/http/class_HttpResponse.php:79: * @todo If the return statement is removed and setcookie() commented out, @@ -118,32 +130,56 @@ ./inc/classes/main/result/class_DatabaseResult.php:379:4 * @todo Find a caching way without modifying the result array ./inc/classes/main/rng/class_RandomNumberGenerator.php:150: * @todo I had a better random number generator here but now it is somewhere lost :( ./inc/classes/main/rng/class_RandomNumberGenerator.php:83: * @todo Add site key for stronger salt! -./inc/classes/main/template/class_BaseTemplateEngine.php:810: * @todo Unfinished work or don't die here. -./inc/classes/main/template/class_BaseTemplateEngine.php:827: // @TODO Non-string found so we need some deeper analysis... -./inc/classes/main/template/class_BaseTemplateEngine.php:904: // @TODO Old behaviour, will become obsolete! -./inc/classes/main/template/class_BaseTemplateEngine.php:907: // @TODO Yet another old way -./inc/classes/main/template/class_BaseTemplateEngine.php:983: * @todo Make this code some nicer... +./inc/classes/main/template/class_BaseTemplateEngine.php:1049: // @TODO This silent abort should be logged, maybe. +./inc/classes/main/template/class_BaseTemplateEngine.php:1057: // @TODO Old behaviour, will become obsolete! +./inc/classes/main/template/class_BaseTemplateEngine.php:1060: // @TODO Yet another old way +./inc/classes/main/template/class_BaseTemplateEngine.php:1126: // @TODO This silent abort should be logged, maybe. +./inc/classes/main/template/class_BaseTemplateEngine.php:1147: * @todo Make this code some nicer... +./inc/classes/main/template/class_BaseTemplateEngine.php:955: * @todo Unfinished work or don't die here. +./inc/classes/main/template/class_BaseTemplateEngine.php:972: // @TODO Non-string found so we need some deeper analysis... +./inc/classes/main/template/console/class_ConsoleTemplateEngine.php:10: * @todo This template engine does not make use of setTemplateType() ./inc/classes/main/template/image/class_ImageTemplateEngine.php:224: * @todo Find something usefull with this! ./inc/classes/main/template/image/class_ImageTemplateEngine.php:244: * @todo Add cache creation here -./inc/classes/main/template/mail/class_MailTemplateEngine.php:234: * @todo Add cache creation here -./inc/classes/main/template/mail/class_MailTemplateEngine.php:244: * @todo Should we call back the mailer class here? -./inc/classes/main/template/mail/class_MailTemplateEngine.php:325: * @todo 0% done -./inc/classes/main/template/menu/class_MenuTemplateEngine.php:257: * @todo Find something useful with this! -./inc/classes/main/template/menu/class_MenuTemplateEngine.php:302: * @todo Add cache creation here +./inc/classes/main/template/mail/class_MailTemplateEngine.php:10: * @todo This template engine does not make use of setTemplateType() +./inc/classes/main/template/mail/class_MailTemplateEngine.php:237: * @todo Add cache creation here +./inc/classes/main/template/mail/class_MailTemplateEngine.php:247: * @todo Should we call back the mailer class here? +./inc/classes/main/template/mail/class_MailTemplateEngine.php:328: * @todo 0% done +./inc/classes/main/template/menu/class_MenuTemplateEngine.php:276: * @todo Find something useful with this! +./inc/classes/main/template/menu/class_MenuTemplateEngine.php:322: * @todo Add cache creation here ./inc/classes/main/user/class_BaseUser.php:308: * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem ./inc/classes/main/user/class_BaseUser.php:80: * @todo Find a way of casting here. "(int)" might destroy the user id > 32766 ./inc/classes/main/user/member/class_Member.php:84: * @todo Add more ways over creating user classes ./inc/classes/middleware/debug/class_DebugMiddleware.php:112: // @TODO Initialization phase +./inc/classes.php:10: * @todo We should minimize these includes ./inc/config/class_FrameworkConfiguration.php:172: * @todo We have to add some more entries from $_SERVER here -./inc/database.php:49:// @TODO Rewrite this -./inc/hooks.php:26:// @TODO This makes the core depending on the SPL. But it should be installed anyway. -./inc/includes.php:36:// @TODO Find a nicer OOP-ed way for this -./inc/language.php:31:// @TODO Rewrite this +./inc/database.php:11: * @todo We should minimize these includes +./inc/database.php:51:// @TODO Rewrite this +./inc/file_io.php:13: * @todo We should minimize these includes +./inc/hooks.php:11: * @todo We should minimize these includes +./inc/hooks.php:28:// @TODO This makes the core depending on the SPL. But it should be installed anyway. +./inc/includes.php:11: * @todo We should minimize these includes +./inc/includes.php:38:// @TODO Find a nicer OOP-ed way for this +./inc/language.php:10: * @todo We should minimize these includes +./inc/language.php:33:// @TODO Rewrite this ./inc/loader/class_ClassLoader.php:262: /* @todo: Do not die here. */ +./inc/output.php:11: * @todo We should minimize these includes +./inc/selector.php:11: * @todo We should minimize these includes +./index.php:59: * @todo This method is old code and needs heavy rewrite ### ### DEPRECATION FOLLOWS: ### ### -./inc/classes/exceptions/io/class_FileNotFoundException.php:11: * @deprecated -./inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php:10: * @deprecated -./inc/classes/exceptions/main/class_ClassNotFoundException.php:11: * @deprecated -./inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php:11: * @deprecated -./inc/classes/main/template/class_BaseTemplateEngine.php:1133: * @deprecated -./inc/classes/main/template/class_BaseTemplateEngine.php:953: * @deprecated +./application/hub/main/filter/bootstrap/class_HubBootstrapAquireHubIdFilter.php:2:// @DEPRECATED +./application/hub/main/filter/bootstrap/class_HubBootstrapGenSessionIdFilter.php:2:// @DEPRECATED +./application/hub/main/filter/shutdown/class_HubShutdownListenerPoolFilter.php:2:// @DEPRECATED +./application/hub/main/nodes/class_BaseHubNode.php:45: * @deprecated +./inc/classes/exceptions/io/class_FileNotFoundException.php:2:// @DEPRECATED +./inc/classes/exceptions/io/class_FilePointerNotOpenedException.php:2:// @DEPRECATED +./inc/classes/exceptions/io/class_InvalidDirectoryResourceException.php:2:// @DEPRECATED +./inc/classes/exceptions/main/class_ClassNotFoundException.php:2:// @DEPRECATED +./inc/classes/exceptions/main/class_ConfigEntryNotFoundException.php:2:// @DEPRECATED +./inc/classes.php:9: * @deprecated +./inc/database.php:10: * @deprecated +./inc/file_io.php:12: * @deprecated +./inc/hooks.php:10: * @deprecated +./inc/includes.php:10: * @deprecated +./inc/language.php:9: * @deprecated +./inc/output.php:10: * @deprecated +./inc/selector.php:10: * @deprecated -- 2.39.5