From e777f101a23784f63b1fb7976f08fa361315cdff Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 20 Aug 2009 17:00:28 +0000 Subject: [PATCH] Tasks added and registered with handler: - HubUpdateCheckTask added which shall periodicly check for updates - HubPingTask added which shall ping outgoing hub connections - Both above tasks are registered (see config.php for timing details) - Missing configuration entries added --- .gitattributes | 6 + application/hub/config.php | 21 ++++ .../class_TaskHandlerInitializerFilter.php | 21 +++- application/hub/main/iterator/hub/.htaccess | 1 + .../iterator/hub/class_HubPingIterator.php | 107 ++++++++++++++++++ application/hub/main/tasks/hub/ping/.htaccess | 1 + .../main/tasks/hub/ping/class_HubPingTask.php | 80 +++++++++++++ .../hub/main/tasks/hub/update/.htaccess | 1 + .../hub/update/class_HubUpdateCheckTask.php | 70 ++++++++++++ 9 files changed, 305 insertions(+), 3 deletions(-) create mode 100644 application/hub/main/iterator/hub/.htaccess create mode 100644 application/hub/main/iterator/hub/class_HubPingIterator.php create mode 100644 application/hub/main/tasks/hub/ping/.htaccess create mode 100644 application/hub/main/tasks/hub/ping/class_HubPingTask.php create mode 100644 application/hub/main/tasks/hub/update/.htaccess create mode 100644 application/hub/main/tasks/hub/update/class_HubUpdateCheckTask.php diff --git a/.gitattributes b/.gitattributes index 0aa62cbdc..e5858576e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -139,6 +139,8 @@ application/hub/main/handler/tasks/class_TaskHandler.php -text application/hub/main/iterator/.htaccess -text application/hub/main/iterator/class_ -text application/hub/main/iterator/class_BaseIterator.php -text +application/hub/main/iterator/hub/.htaccess -text +application/hub/main/iterator/hub/class_HubPingIterator.php -text application/hub/main/iterator/network/.htaccess -text application/hub/main/iterator/network/class_NetworkListenIterator.php -text application/hub/main/iterator/pool/.htaccess -text @@ -232,6 +234,10 @@ application/hub/main/tasks/class_ -text application/hub/main/tasks/class_BaseTask.php -text application/hub/main/tasks/hub/.htaccess -text application/hub/main/tasks/hub/class_HubSelfConnectTask.php -text +application/hub/main/tasks/hub/ping/.htaccess -text +application/hub/main/tasks/hub/ping/class_HubPingTask.php -text +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/visitor/.htaccess -text diff --git a/application/hub/config.php b/application/hub/config.php index 57cf9fd5b..6c80e23d8 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -198,12 +198,30 @@ $cfg->setConfigEntry('task_self_connect_startup_delay', 4000); // CFG: TASK-SELF-CONNECT-INTERVAL-DELAY $cfg->setConfigEntry('task_self_connect_interval_delay', 1000*60*30); +// CFG: TASK-UPDATE-CHECK-STARTUP-DELAY +$cfg->setConfigEntry('task_update_check_startup_delay', 1000*60*60*6); + +// CFG: TASK-UPDATE-CHECK-INTERVAL-DELAY +$cfg->setConfigEntry('task_update_check_interval_delay', 1000*60*60*24); + +// CFG: TASK-PING-STARTUP-DELAY +$cfg->setConfigEntry('task_ping_startup_delay', 1000*60); + +// CFG: TASK-PING-INTERVAL-DELAY +$cfg->setConfigEntry('task_ping_interval_delay', 1000*60*60); + // CFG: IDLE-TASK-CLASS $cfg->setConfigEntry('idle_task_class', 'IdleLoopTask'); // CFG: HUB-SELFCONNECT-TASK-CLASS $cfg->setConfigEntry('hub_selfconnect_task_class', 'HubSelfConnectTask'); +// CFG: HUB-UPDATE-CHECK-TASK-CLASS +$cfg->setConfigEntry('hub_update_check_task_class', 'HubUpdateCheckTask'); + +// CFG: HUB-PING-TASK-CLASS +$cfg->setConfigEntry('hub_ping_task_class', 'HubPingTask'); + // CFG: TASK-LIST-CLASS $cfg->setConfigEntry('task_list_class', 'TaskList'); @@ -216,6 +234,9 @@ $cfg->setConfigEntry('default_iterator_class', 'DefaultIterator'); // CFG: QUERY-ITERATOR-CLASS $cfg->setConfigEntry('query_iterator_class', 'DefaultIterator'); +// CFG: HUB-PING-ITERATOR-CLASS +$cfg->setConfigEntry('hub_ping_iterator_class', 'HubPingIterator'); + // CFG: LOCAL-QUERY-LIST-CLASS $cfg->setConfigEntry('local_query_list_class', 'LocalQueryList'); diff --git a/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php b/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php index acba7cd92..a2a95d424 100644 --- a/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php +++ b/application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php @@ -61,10 +61,10 @@ class TaskHandlerInitializerFilter extends BaseFilter implements Filterable { // Get a new task handler instance $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class'); - // Register some tasks and provide both instances for this: - // 1.) Network package reader, needs to be delayed a little + // Network package reader, needs to be delayed a little $handlerInstance->registerTask('network_package_reader', $nodeInstance->getListenerPoolInstance()); - // 2.) Query instance + + // Query handler instance $handlerInstance->registerTask('query_handler', $nodeInstance->getQueryConnectorInstance()); // Generate idle task @@ -81,6 +81,21 @@ class TaskHandlerInitializerFilter extends BaseFilter implements Filterable { // Register it $handlerInstance->registerTask('self_connect', $taskInstance); + + // Prepare a update-check task + $taskInstance = ObjectFactory::createObjectByConfiguredName('hub_update_check_task_class'); + + // Register it + $handlerInstance->registerTask('update_check', $taskInstance); + + // Get the list instance here + $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance(); + + // Prepare a ping task + $taskInstance = ObjectFactory::createObjectByConfiguredName('hub_ping_task_class', array($listInstance)); + + // Register it + $handlerInstance->registerTask('ping', $taskInstance); } } diff --git a/application/hub/main/iterator/hub/.htaccess b/application/hub/main/iterator/hub/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/iterator/hub/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/iterator/hub/class_HubPingIterator.php b/application/hub/main/iterator/hub/class_HubPingIterator.php new file mode 100644 index 000000000..4c21ee7cc --- /dev/null +++ b/application/hub/main/iterator/hub/class_HubPingIterator.php @@ -0,0 +1,107 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 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 HubPingIterator extends BaseIterator implements Iterator { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $iteratorInstance An instance of a Iterator class + */ + public final static function createHubPingIterator () { + // Get new instance + $iteratorInstance = new HubPingIterator(); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + */ + public function current () { + // Default is null + $current = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $key Current key in iteration + */ + public function key () { + // Default is null + $key = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $key; + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->partialStub('Please implement this method.'); + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + */ + public function rewind () { + $this->partialStub('Please implement this method.'); + } + + /** + * Checks wether the current entry is valid (not at the end of the list) + * + * @return void + */ + public function valid () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/main/tasks/hub/ping/.htaccess b/application/hub/main/tasks/hub/ping/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/tasks/hub/ping/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/tasks/hub/ping/class_HubPingTask.php b/application/hub/main/tasks/hub/ping/class_HubPingTask.php new file mode 100644 index 000000000..c0a6ca27f --- /dev/null +++ b/application/hub/main/tasks/hub/ping/class_HubPingTask.php @@ -0,0 +1,80 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 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 HubPingTask extends BaseTask implements Visitable, Taskable { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @param $listInstance A Listable instance + * @return $taskInstance An instance of a Visitable class + */ + public final static function createHubPingTask (Listable $listInstance) { + // Get new instance + $taskInstance = new HubPingTask(); + + // Se the list instance in this task + $taskInstance->setListInstance($listInstance); + + // Init ping iterator instance + $iteratorInstance = ObjectFactory::createObjectByConfiguredName('hub_ping_iterator_class', array($listInstance)); + + // Set it as well + $taskInstance->setIteratorInstance($iteratorInstance); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to rpocess the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo 0% + */ + public function accept (Visitor $visitorInstance) { + $this->partialStub('Please implement this method. visitor='.$visitorInstance->__toString()); + } + + /** + * Executes the task + * + * @return void + */ + public function execute () { + $this->partialStub('Unimplemented task.'); + } +} + +// [EOF] +?> diff --git a/application/hub/main/tasks/hub/update/.htaccess b/application/hub/main/tasks/hub/update/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/tasks/hub/update/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/tasks/hub/update/class_HubUpdateCheckTask.php b/application/hub/main/tasks/hub/update/class_HubUpdateCheckTask.php new file mode 100644 index 000000000..87c5604eb --- /dev/null +++ b/application/hub/main/tasks/hub/update/class_HubUpdateCheckTask.php @@ -0,0 +1,70 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 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 HubUpdateCheckTask extends BaseTask implements Visitable, Taskable { + /** + * 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 createHubUpdateCheckTask () { + // Get new instance + $taskInstance = new HubUpdateCheckTask(); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to rpocess the visit "request" + * + * @param $visitorInstance An instance of a Visitor class + * @return void + * @todo 0% + */ + public function accept (Visitor $visitorInstance) { + $this->partialStub('Please implement this method. visitor='.$visitorInstance->__toString()); + } + + /** + * Executes the task + * + * @return void + */ + public function execute () { + $this->partialStub('Unimplemented task.'); + } +} + +// [EOF] +?> -- 2.39.5