From: Roland Haeder Date: Wed, 26 Mar 2014 19:34:29 +0000 (+0100) Subject: Some cleanups + created a "late bootstrap" task for DHTs: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=78b37b9d93b78a687eae1f19015b7e2a0def1cc3;p=hub.git Some cleanups + created a "late bootstrap" task for DHTs: - deleted no longer used classes (NodeDhtFooTask are used) - added class for "late bootstrapping" of DHTs which will be used by all nodes except 'boot'. This task will be started after the announcement answer came back from the "upper nodes". Signed-off-by: Roland Haeder --- diff --git a/application/hub/config.php b/application/hub/config.php index e47c5e095..526836593 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -573,6 +573,9 @@ $cfg->setConfigEntry('node_dht_init_task_class', 'NodeDhtInitializationTask'); // CFG: NODE-DHT-BOOTSTRAP-TASK-CLASS $cfg->setConfigEntry('node_dht_bootstrap_task_class', 'NodeDhtBootstrapTask'); +// CFG: NODE-DHT-LATE-BOOTSTRAP-TASK-CLASS +$cfg->setConfigEntry('node_dht_late_bootstrap_task_class', 'NodeDhtLateBootstrapTask'); + // CFG: NODE-DHT-QUERY-TASK-CLASS $cfg->setConfigEntry('node_dht_query_task_class', 'NodeDhtQueryTask'); @@ -637,7 +640,7 @@ $cfg->setConfigEntry('task_dht_init_interval_delay', 86400000); // = 1 day (won' $cfg->setConfigEntry('task_dht_init_max_runs', 1); // CFG: TASK-DHT-BOOTSTRAP-STATUP-DELAY -$cfg->setConfigEntry('task_dht_bootstrap_startup_delay', 100); +$cfg->setConfigEntry('task_dht_bootstrap_startup_delay', 500); // CFG: TASK-DHT-BOOTSTRAP-INTERVAL-DELAY $cfg->setConfigEntry('task_dht_bootstrap_interval_delay', 3600000); // = 1 hour (won't matter anyway) @@ -645,6 +648,15 @@ $cfg->setConfigEntry('task_dht_bootstrap_interval_delay', 3600000); // = 1 hour // CFG: TASK-DHT-BOOTSTRAP-MAX-RUNS $cfg->setConfigEntry('task_dht_bootstrap_max_runs', 1); +// CFG: TASK-DHT-LATE-BOOTSTRAP-STATUP-DELAY +$cfg->setConfigEntry('task_dht_late_bootstrap_startup_delay', 100); + +// CFG: TASK-DHT-LATE-BOOTSTRAP-INTERVAL-DELAY +$cfg->setConfigEntry('task_dht_late_bootstrap_interval_delay', 3600000); // = 1 hour (won't matter anyway) + +// CFG: TASK-DHT-LATE-BOOTSTRAP-MAX-RUNS +$cfg->setConfigEntry('task_dht_late_bootstrap_max_runs', 1); + // CFG: TASK-DHT-QUERY-STATUP-DELAY $cfg->setConfigEntry('task_dht_query_startup_delay', 1400); diff --git a/application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php b/application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php index a22092a0f..84d8b6a79 100644 --- a/application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php +++ b/application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php @@ -74,10 +74,10 @@ class AnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements Ha $handlerInstance = Registry::getRegistry()->getInstance('task_handler'); // Generate DHT bootstrap task - $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_bootstrap_task_class'); + $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_late_bootstrap_task_class'); // Register it as well - $handlerInstance->registerTask('dht_bootstrap', $taskInstance); + $handlerInstance->registerTask('dht_late_bootstrap', $taskInstance); // Get the node instance $nodeInstance = NodeObjectFactory::createNodeInstance(); diff --git a/application/hub/main/tasks/dht/.htaccess b/application/hub/main/tasks/dht/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/dht/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/dht/bootstrap/.htaccess b/application/hub/main/tasks/dht/bootstrap/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/main/tasks/dht/bootstrap/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/main/tasks/dht/bootstrap/class_DhtBootstrapTask.php b/application/hub/main/tasks/dht/bootstrap/class_DhtBootstrapTask.php deleted file mode 100644 index 5ca4af43c..000000000 --- a/application/hub/main/tasks/dht/bootstrap/class_DhtBootstrapTask.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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 DhtBootstrapTask 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 createDhtBootstrapTask () { - // Get new instance - $taskInstance = new DhtBootstrapTask(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/dht/class_Dht b/application/hub/main/tasks/dht/class_Dht deleted file mode 100644 index ca7fc9f3f..000000000 --- a/application/hub/main/tasks/dht/class_Dht +++ /dev/null @@ -1,72 +0,0 @@ - - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 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 Dht???Task 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 createDht???Task () { - // Get new instance - $taskInstance = new Dht???Task(); - - // Return the prepared instance - return $taskInstance; - } - - /** - * Accepts the visitor to process the visitor - * - * @param $visitorInstance An instance of a Visitor class - * @return void - * @todo Maybe visit some sub-objects - */ - public function accept (Visitor $visitorInstance) { - // Visit this task - $visitorInstance->visitTask($this); - } - - /** - * Executes the task - * - * @return void - * @todo 0% - */ - public function executeTask () { - $this->partialStub('Unimplemented task.'); - } -} - -// [EOF] -?> diff --git a/application/hub/main/tasks/node/dht/class_NodeDhtLateBootstrapTask.php b/application/hub/main/tasks/node/dht/class_NodeDhtLateBootstrapTask.php new file mode 100644 index 000000000..6b1cd6174 --- /dev/null +++ b/application/hub/main/tasks/node/dht/class_NodeDhtLateBootstrapTask.php @@ -0,0 +1,77 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.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 NodeDhtLateBootstrapTask 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 createNodeDhtLateBootstrapTask () { + // Get new instance + $taskInstance = new NodeDhtLateBootstrapTask(); + + // Get a DHT instance + $dhtInstance = DhtObjectFactory::createDhtInstance('node'); + + // Set the DHT instance here + $taskInstance->setDhtInstance($dhtInstance); + + // Return the prepared instance + return $taskInstance; + } + + /** + * Accepts the visitor to process the visitor + * + * @param $visitorInstance An instance of a Visitor class + * @return void + */ + public function accept (Visitor $visitorInstance) { + // Visit this task + $visitorInstance->visitTask($this); + } + + /** + * Executes the task + * + * @return void + */ + public function executeTask () { + // Let the DHT class do the work for us + $this->getDhtInstance()->bootstrapDht(); + } +} + +// [EOF] +?>