]> git.mxchange.org Git - hub.git/commitdiff
Some cleanups + created a "late bootstrap" task for DHTs:
authorRoland Haeder <roland@mxchange.org>
Wed, 26 Mar 2014 19:34:29 +0000 (20:34 +0100)
committerRoland Haeder <roland@mxchange.org>
Wed, 26 Mar 2014 19:34:29 +0000 (20:34 +0100)
- 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 <roland@mxchange.org>
application/hub/config.php
application/hub/main/handler/answer-status/announcement/class_AnnouncementAnswerOkayHandler.php
application/hub/main/tasks/dht/.htaccess [deleted file]
application/hub/main/tasks/dht/bootstrap/.htaccess [deleted file]
application/hub/main/tasks/dht/bootstrap/class_DhtBootstrapTask.php [deleted file]
application/hub/main/tasks/dht/class_Dht [deleted file]
application/hub/main/tasks/node/dht/class_NodeDhtLateBootstrapTask.php [new file with mode: 0644]

index e47c5e0957595b7bc4a20b765dc5a4522c73b1c8..526836593fc2fb3823ce2934d83c829069c381d7 100644 (file)
@@ -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);
 
index a22092a0f4bc57468d9df301f99ab444ebb8f9fd..84d8b6a79c47a36661a25e94e44ed6876b131efc 100644 (file)
@@ -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 (file)
index 3a42882..0000000
+++ /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 (file)
index 3a42882..0000000
+++ /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 (file)
index 5ca4af4..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-/**
- * A Bootstrap task for DHTs, use this only for nodes which do not announce
- * themself to upper nodes as if they completed announcement they will attempt
- * to bootstrap their DHT. This said condition currently only matches with
- * bootstrap nodes (mode=boot) as they don't announce as they are already the
- * bootstrapper and there are no super nodes.
- *
- * If there would be super nodes, a centralization occurs (on the super nodes).
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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 (file)
index ca7fc9f..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-/**
- * A ??? task for DHTs
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @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 <http://www.gnu.org/licenses/>.
- */
-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 (file)
index 0000000..6b1cd61
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+/**
+ * A DhtBootstrap node-task
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+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]
+?>