Network package writer added, shutdown refactured, fixes:
authorRoland Häder <roland@mxchange.org>
Fri, 26 Mar 2010 04:20:25 +0000 (04:20 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 26 Mar 2010 04:20:25 +0000 (04:20 +0000)
- 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

20 files changed:
.gitattributes
application/hub/config.php
application/hub/interfaces/package/class_Deliverable.php
application/hub/main/connectors/query/local/class_LocalQueryConnector.php
application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php
application/hub/main/handler/tasks/class_TaskHandler.php
application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/package/class_NetworkPackage.php
application/hub/main/states/node/active/class_NodeActiveState.php
application/hub/main/states/node/announced/.htaccess [new file with mode: 0644]
application/hub/main/states/node/announced/class_NodeAnnouncedState.php [new file with mode: 0644]
application/hub/main/states/node/class_
application/hub/main/states/node/init/class_NodeInitState.php
application/hub/main/states/node/virgin/class_NodeVirginState.php
application/hub/main/tasks/class_
application/hub/main/tasks/network/.htaccess [new file with mode: 0644]
application/hub/main/tasks/network/class_NetworkPackageWriterTask.php [new file with mode: 0644]
application/hub/main/visitor/tasks/class_ShutdownTaskVisitor.php [new file with mode: 0644]
docs/TODOs.txt

index a859566faad75c9dae61828b3198143be122d34d..0f747dee390d19f2e00facb6bb21f3eb4eccd16d 100644 (file)
@@ -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
index b870f54baf1c4d8b5d85cde179f316c8fedf13ef..99d368310f9fc682316246417fcfc0eeb0a67a4f 100644 (file)
@@ -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');
 
index a97c93fc4ff543bf55262dafe6bca6f3430de1c0..072bcd765d6cd5e1c412cdcb2c2fa88877b72e42 100644 (file)
  */
 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]
 ?>
-
index 88dd5c3f221a7af819c306f1a50a4780c314248d..1a56b177779146d615bb1ae7c90c6f4ee1f194a8 100644 (file)
@@ -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"
         *
index dae02e0443591ca67b69c2444d4ac819197afcbe..4a2dff8563e40b2d98c6a1e997d7532f0b6d7fb4 100644 (file)
@@ -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());
 
index a1ecf3016e48bf24e9a9012bcde467af43666fb1..f96df781e331f5bd361b3606501c53b9a36d65c2 100644 (file)
@@ -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;
index 91812d27dc90b10e7bd482ae28a4cc5a21d70c8b..ea2253336519a32acedd9ca92f5e8f539e1771b3 100644 (file)
@@ -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);
        }
 }
 
index 784c9a15c944f81ce1a0bc0269f7026e13e25590..f9d1cdf9c6425fe44b6d21b902650faf98457242 100644 (file)
@@ -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');
index f47e10b4fad7315264008e6e88b3c3e6cea376f1..4f6551c27801483fe163cb35f10d8b47a891f63c 100644 (file)
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-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
                ));
        }
 }
index 9544e3a5a5a7274646d383233c3724021fa83d41..c6c58771c4e055c19502ed24822296e75c0b7ab1 100644 (file)
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..0e2c10a
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * A Announced node state class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index 7d73f8d3092d4276cb7786faae93f7e664504cc0..f19ed1d878d618aa5dda00bdebf6b66e6c574d52 100644 (file)
@@ -21,7 +21,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-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);
index 2d0092d2a6c84445417a9572072d6de55b7ed749..ff41619fef823b70b34936ea11faf8126841fef8 100644 (file)
@@ -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
index 65a3fc6ad1bed347e14227d6aabb16b8fc54f820..fd8e498fe92906ced13ced9a08320b6618140ed0 100644 (file)
@@ -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 () {
index cae03fc15664c75a0b7bd54e1ffc9979f1b0918a..e390c2fe8855a3f43430042b1ccb7df476be845d 100644 (file)
@@ -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 (file)
index 0000000..3a42882
--- /dev/null
@@ -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 (file)
index 0000000..ebaedf1
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+/**
+ * A NetworkPackageWriter task
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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 (file)
index 0000000..cf1753f
--- /dev/null
@@ -0,0 +1,120 @@
+<?php
+/**
+ * An ShutdownTask visitor
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>
index 87a2bf96b1bcbf3c2b6e2e37f727761d9d117fda..906dc88efd470392502c498e3234b53f3c7d22a8 100644 (file)
@@ -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
 ./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.
 ./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,
 ./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