]> git.mxchange.org Git - hub.git/commitdiff
Added initial crawler stuff:
authorRoland Haeder <roland@mxchange.org>
Sun, 4 May 2014 10:38:33 +0000 (12:38 +0200)
committerRoland Haeder <roland@mxchange.org>
Sun, 4 May 2014 10:38:33 +0000 (12:38 +0200)
- Crawler->node communicator classes/interfaces
- Local and remote URL fetcher classes
- The crawler application has now states (currently init, booting, active)
- Also the communicator does now have states (currently init, active)

Signed-off-by: Roland Haeder <roland@mxchange.org>
57 files changed:
application/hub/config.php
application/hub/interfaces/communicator/.htaccess [new file with mode: 0644]
application/hub/interfaces/communicator/class_Communicator.php [new file with mode: 0644]
application/hub/interfaces/crawler/class_Crawler.php
application/hub/interfaces/executor/class_Executor.php
application/hub/interfaces/producer/work_units/class_UnitProducer.php
application/hub/main/class_BaseHubSystem.php
application/hub/main/communicator/.htaccess [new file with mode: 0644]
application/hub/main/communicator/class_ [new file with mode: 0644]
application/hub/main/communicator/class_BaseCommunicator.php [new file with mode: 0644]
application/hub/main/communicator/crawler/.htaccess [new file with mode: 0644]
application/hub/main/communicator/crawler/class_CrawlerNodeCommunicator.php [new file with mode: 0644]
application/hub/main/crawler/class_BaseNodeCrawler.php
application/hub/main/crawler/console/class_NodeConsoleCrawler.php
application/hub/main/cruncher/class_BaseHubCruncher.php
application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php
application/hub/main/dht/class_BaseDht.php
application/hub/main/factories/communicator/.htaccess [new file with mode: 0644]
application/hub/main/factories/communicator/class_CommunicatorFactory.php [new file with mode: 0644]
application/hub/main/factories/states/communicator/.htaccess [new file with mode: 0644]
application/hub/main/factories/states/communicator/class_CommunicatorStateFactory.php [new file with mode: 0644]
application/hub/main/factories/states/crawler/.htaccess [new file with mode: 0644]
application/hub/main/factories/states/crawler/class_CrawlerStateFactory.php [new file with mode: 0644]
application/hub/main/filter/task/crawler/class_CrawlerTaskHandlerInitializerFilter.php
application/hub/main/helper/connection/class_BaseConnectionHelper.php
application/hub/main/miner/chash/class_HubChashMiner.php
application/hub/main/miner/class_BaseHubMiner.php
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/package/class_NetworkPackage.php
application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php
application/hub/main/states/communicator/.htaccess [new file with mode: 0644]
application/hub/main/states/communicator/active/.htaccess [new file with mode: 0644]
application/hub/main/states/communicator/active/class_CommunicatorActiveState.php [new file with mode: 0644]
application/hub/main/states/communicator/class_ [new file with mode: 0644]
application/hub/main/states/communicator/class_BaseCommunicatorState.php [new file with mode: 0644]
application/hub/main/states/communicator/init/.htaccess [new file with mode: 0644]
application/hub/main/states/communicator/init/class_CommunicatorInitState.php [new file with mode: 0644]
application/hub/main/states/crawler/.htaccess [new file with mode: 0644]
application/hub/main/states/crawler/active/.htaccess [new file with mode: 0644]
application/hub/main/states/crawler/active/class_CrawlerActiveState.php [new file with mode: 0644]
application/hub/main/states/crawler/booting/.htaccess [new file with mode: 0644]
application/hub/main/states/crawler/booting/class_CrawlerBootingState.ph [new file with mode: 0644]
application/hub/main/states/crawler/booting/class_CrawlerBootingState.php [new file with mode: 0644]
application/hub/main/states/crawler/class_ [new file with mode: 0644]
application/hub/main/states/crawler/class_BaseCrawlerState.php [new file with mode: 0644]
application/hub/main/states/crawler/init/.htaccess [new file with mode: 0644]
application/hub/main/states/crawler/init/class_CrawlerInitState.php [new file with mode: 0644]
application/hub/main/states/cruncher/init/class_CruncherInitState.php
application/hub/main/tasks/crawler/.htaccess [new file with mode: 0644]
application/hub/main/tasks/crawler/class_Crawler [new file with mode: 0644]
application/hub/main/tasks/crawler/communicator/.htaccess [new file with mode: 0644]
application/hub/main/tasks/crawler/communicator/class_CrawlerNodeCommunicatorTask.php [new file with mode: 0644]
application/hub/main/tasks/crawler/url_fetcher/.htaccess [new file with mode: 0644]
application/hub/main/tasks/crawler/url_fetcher/local/.htaccess [new file with mode: 0644]
application/hub/main/tasks/crawler/url_fetcher/local/class_CrawlerLocalUrlFetcherTask.php [new file with mode: 0644]
application/hub/main/tasks/crawler/url_fetcher/remote/.htaccess [new file with mode: 0644]
application/hub/main/tasks/crawler/url_fetcher/remote/class_CrawlerRemoteUrlFetcherTask.php [new file with mode: 0644]

index 0d47627ab4b3dffca4b932561183f1e6e0158ae0..4b53d4697587955539e9e55039a574e7ed616f70 100644 (file)
@@ -1205,6 +1205,54 @@ $cfg->setConfigEntry('crawler_bootstrap_generic_activation_filter', 'CrawlerBoot
 // CFG: CRAWLER-SHUTDOWN-FILTER
 $cfg->setConfigEntry('crawler_shutdown_filter', 'CrawlerShutdownFilter');
 
+// CFG: CRAWLER-NODE-COMMUNICATOR-CLASS
+$cfg->setConfigEntry('crawler_node_communicator_class', 'CrawlerNodeCommunicator');
+
+// CFG: CRAWLER-INIT-STATE-CLASS
+$cfg->setConfigEntry('crawler_init_state_class', 'CrawlerInitState');
+
+// CFG: CRAWLER-BOOTING-STATE-CLASS
+$cfg->setConfigEntry('crawler_booting_state_class', 'CrawlerBootingState');
+
+// CFG: COMMUNICATOR-INIT-STATE-CLASS
+$cfg->setConfigEntry('communicator_init_state_class', 'CommunicatorInitState');
+
+// CFG: CRAWLER-NODE-COMMUNICATOR-TASK-CLASS
+$cfg->setConfigEntry('crawler_node_communicator_task_class', 'CrawlerNodeCommunicatorTask');
+
+// CFG: TASK-CRAWLER-NODE-COMMUNICATOR-STARTUP-DELAY
+$cfg->setConfigEntry('task_crawler_node_communicator_startup_delay', 500);
+
+// CFG: TASK-CRAWLER-NODE-COMMUNICATOR-INTERVAL-DELAY
+$cfg->setConfigEntry('task_crawler_node_communicator_interval_delay', 250);
+
+// CFG: TASK-CRAWLER-NODE-COMMUNICATOR-MAX-RUNS
+$cfg->setConfigEntry('task_crawler_node_communicator_max_runs', 0);
+
+// CFG: CRAWLER-LOCAL-URL-FETCHER-TASK-CLASS
+$cfg->setConfigEntry('crawler_local_url_fetcher_task_class', 'CrawlerLocalUrlFetcherTask');
+
+// CFG: TASK-CRAWLER-LOCAL-URL-FETCHER-STARTUP-DELAY
+$cfg->setConfigEntry('task_crawler_local_url_fetcher_startup_delay', 1500);
+
+// CFG: TASK-CRAWLER-LOCAL-URL-FETCHER-INTERVAL-DELAY
+$cfg->setConfigEntry('task_crawler_local_url_fetcher_interval_delay', 50);
+
+// CFG: TASK-CRAWLER-LOCAL-URL-FETCHER-MAX-RUNS
+$cfg->setConfigEntry('task_crawler_local_url_fetcher_max_runs', 0);
+
+// CFG: CRAWLER-REMOTE-URL-FETCHER-TASK-CLASS
+$cfg->setConfigEntry('crawler_remote_url_fetcher_task_class', 'CrawlerRemoteUrlFetcherTask');
+
+// CFG: TASK-CRAWLER-REMOTE-URL-FETCHER-STARTUP-DELAY
+$cfg->setConfigEntry('task_crawler_remote_url_fetcher_startup_delay', 1500);
+
+// CFG: TASK-CRAWLER-REMOTE-URL-FETCHER-INTERVAL-DELAY
+$cfg->setConfigEntry('task_crawler_remote_url_fetcher_interval_delay', 50);
+
+// CFG: TASK-CRAWLER-REMOTE-URL-FETCHER-MAX-RUNS
+$cfg->setConfigEntry('task_crawler_remote_url_fetcher_max_runs', 0);
+
 ///////////////////////////////////////////////////////////////////////////////
 //                            HTTP Configuration
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/application/hub/interfaces/communicator/.htaccess b/application/hub/interfaces/communicator/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/communicator/class_Communicator.php b/application/hub/interfaces/communicator/class_Communicator.php
new file mode 100644 (file)
index 0000000..a0d6c48
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * An interface for communicators
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Core 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/>.
+ */
+interface Communicator extends Executor {
+}
+
+// [EOF]
+?>
index 1c4103f46d672e3a7cf7a6a03524b863c5842506..ac0592558837f45509a0579024a42c6614e863e2 100644 (file)
@@ -63,6 +63,14 @@ interface Crawler extends FrameworkInterface {
         * @return      $isActive       Whether the crawler is active
         */
        function isActive ();
+
+       /**
+        * Initializes this crawler instance
+        *
+        * @param       $stateInstance  An instance of a Stateable class
+        * @return      void
+        */
+       function initCrawler (Stateable $stateInstance);
 }
 
 // [EOF]
index 36380d7f0dccc2ff88719314489864906e823675..d85585cd571db5940167a726fe56bf53e366a70b 100644 (file)
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 interface Executor extends FrameworkInterface {
+       /**
+        * Initializes the executor, whatever it does.
+        *
+        * @return      void
+        */
+       function initExecutor (Stateable $stateInstance);
 }
 
 // [EOF]
index 1dbc91307758310adebe9adf7aca2d7bfc587931..126aaaf350179457ba66fde5b4ca4c5f275d0fd5 100644 (file)
@@ -29,7 +29,7 @@ interface UnitProducer extends Producer, Executor {
         * @param       $stateInstance  An instance of a Stateable instance
         * @return      void
         */
-       function prepareUnitProduction (Stateable $stateInstance);
+       function initUnitProduction (Stateable $stateInstance);
 }
 
 // [EOF]
index ef68edf0429a787234b6a5bb01c61889e23af83c..ad83f7de251cfed72af6a9b0b9c7315a655c4111 100644 (file)
@@ -48,6 +48,16 @@ class BaseHubSystem extends BaseFrameworkSystem {
         */
        private $nodeInstance = NULL;
 
+       /**
+        * An instance of a communicator
+        */
+       private $communicatorInstance = NULL;
+
+       /**
+        * An instance of a crawler
+        */
+       private $crawlerInstance = NULL;
+
        /**
         * An instance of a cruncher
         */
@@ -128,6 +138,44 @@ class BaseHubSystem extends BaseFrameworkSystem {
                $this->nodeInstance = $nodeInstance;
        }
 
+       /**
+        * Getter for communicator instance
+        *
+        * @return      $communicatorInstance   An instance of a Communicator class
+        */
+       public final function getCommunicatorInstance () {
+               return $this->communicatorInstance;
+       }
+
+       /**
+        * Setter for communicator instance
+        *
+        * @param       $communicatorInstance   An instance of a Communicator class
+        * @return      void
+        */
+       protected final function setCommunicatorInstance (Communicator $communicatorInstance) {
+               $this->communicatorInstance = $communicatorInstance;
+       }
+
+       /**
+        * Getter for crawler instance
+        *
+        * @return      $crawlerInstance        An instance of a Crawler class
+        */
+       public final function getCrawlerInstance () {
+               return $this->crawlerInstance;
+       }
+
+       /**
+        * Setter for crawler instance
+        *
+        * @param       $crawlerInstance        An instance of a Crawler class
+        * @return      void
+        */
+       protected final function setCrawlerInstance (Crawler $crawlerInstance) {
+               $this->crawlerInstance = $crawlerInstance;
+       }
+
        /**
         * Getter for cruncher instance
         *
diff --git a/application/hub/main/communicator/.htaccess b/application/hub/main/communicator/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/communicator/class_ b/application/hub/main/communicator/class_
new file mode 100644 (file)
index 0000000..4a7c8f4
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * A ???->node communicator class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 !!! 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 ???NodeCommunicator extends BaseCommunicator implements Communicator {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $communicatorInstance           An instance of a Communicator class
+        */
+       public final static function create???NodeCommunicator () {
+               // Get new instance
+               $communicatorInstance = new ???NodeCommunicator();
+
+               // Return the prepared instance
+               return $communicatorInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/communicator/class_BaseCommunicator.php b/application/hub/main/communicator/class_BaseCommunicator.php
new file mode 100644 (file)
index 0000000..1fda373
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * A general communicator class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 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 BaseCommunicator extends BaseHubSystem {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+
+               // Init state which sets the state to 'init'
+               $this->initState();
+       }
+
+       /**
+        * Initializes the node's state which sets it to 'init'
+        *
+        * @return      void
+        */
+       private function initState() {
+               // Get the state factory and create the initial state.
+               CommunicatorStateFactory::createCommunicatorStateInstanceByName('init', $this);
+       }
+
+       /**
+        * Initializes the executor, whatever it does.
+        *
+        * @return      void
+        */
+       public function initExecutor (Stateable $stateInstance) {
+               $this->partialStub('Unfinished method with state ' . $this->getPrintableState() . '.');
+
+               // This communicator is now fully initialized so change the state
+               $stateInstance->communicatorHasInitialized();
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/communicator/crawler/.htaccess b/application/hub/main/communicator/crawler/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/communicator/crawler/class_CrawlerNodeCommunicator.php b/application/hub/main/communicator/crawler/class_CrawlerNodeCommunicator.php
new file mode 100644 (file)
index 0000000..bfbc4c3
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * A crawler->node communicator class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Crawler 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 CrawlerNodeCommunicator extends BaseCommunicator implements Communicator, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $communicatorInstance           An instance of a Communicator class
+        */
+       public final static function createCrawlerNodeCommunicator () {
+               // Get new instance
+               $communicatorInstance = new CrawlerNodeCommunicator();
+
+               // Return the prepared instance
+               return $communicatorInstance;
+       }
+}
+
+// [EOF]
+?>
index c515456c626ea300a4836d920288eb7fc3cce5be..62ab12074a83b53c1ac107e21c50f88307974d66 100644 (file)
@@ -36,6 +36,31 @@ class BaseNodeCrawler extends BaseHubSystem {
        protected function __construct ($className) {
                // Call parent constructor
                parent::__construct($className);
+
+               // Init state which sets the state to 'init'
+               $this->initState();
+       }
+
+       /**
+        * Initializes the node's state which sets it to 'init'
+        *
+        * @return      void
+        */
+       private function initState() {
+               // Get the state factory and create the initial state.
+               CrawlerStateFactory::createCrawlerStateInstanceByName('init', $this);
+       }
+
+       /**
+        * Initializes this crawler instance
+        *
+        * @param       $stateInstance  An instance of a Stateable class
+        * @return      void
+        * @todo        0% done
+        */
+       public function initCrawler (Stateable $stateInstance) {
+               // Please implement
+               $this->partialStub('Unfinished method.');
        }
 
        /**
index d94216b08b58d9d1628842443671820a56e9653e..d1b1cba582211bf45a1d88dcd5bb5c29c7e00413 100644 (file)
@@ -68,7 +68,7 @@ class NodeConsoleCrawler extends BaseNodeCrawler implements Crawler, Registerabl
 
                // Output all lines
                self::createDebugInstance(__CLASS__)->debugOutput(' ');
-               self::createDebugInstance(__CLASS__)->debugOutput($app->getAppName() . ' v' . $app->getAppVersion() . ' - A distributed crawler');
+               self::createDebugInstance(__CLASS__)->debugOutput('Distributed Crawler v' . $app->getAppVersion());
                self::createDebugInstance(__CLASS__)->debugOutput('Copyright (c) 2014 Crawler Developer Team');
                self::createDebugInstance(__CLASS__)->debugOutput(' ');
                self::createDebugInstance(__CLASS__)->debugOutput('This program comes with ABSOLUTELY NO WARRANTY; for details see docs/COPYING.');
index b73aa4d10143cb795ef3534342b0870408ce055d..f86c9b978d4d610d93bc00593a1647e4979cd719 100644 (file)
@@ -111,7 +111,7 @@ abstract class BaseHubCruncher extends BaseHubSystem implements Updateable {
         * to show up.
         *
         * In this method we already know that the in-buffer is going depleted so
-        * we don't need to double-check it here.
+        * no need to double-check it here.
         *
         * @return      void
         */
index 2adc0914aa428b925b967179204eca7d947fd743..bf684cc6e797e4a93c4d059b85b2e3008c96dac0 100644 (file)
@@ -55,7 +55,7 @@ class HubMcryptCruncher extends BaseHubCruncher implements CruncherHelper, Regis
         * to show up.
         *
         * In this method we already know that the in-buffer is going depleted so
-        * we don't need to double-check it here.
+        * no need to double-check it here.
         *
         * @return      void
         */
index f4e4a0344acea228ad57b7786fcda5690741c393..4dda72d23c46c25fe4ef8495b120440eedc576ee 100644 (file)
@@ -52,10 +52,7 @@ abstract class BaseDht extends BaseHubSystem implements Distributable {
                // Init all stackers
                $this->initStacks();
 
-               /*
-                * Get the state factory and create the initial state, we don't need
-                * the state instance here
-                */
+               // Get the state factory and create the initial state.
                DhtStateFactory::createDhtStateInstanceByName('init', $this);
        }
 
diff --git a/application/hub/main/factories/communicator/.htaccess b/application/hub/main/factories/communicator/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/factories/communicator/class_CommunicatorFactory.php b/application/hub/main/factories/communicator/class_CommunicatorFactory.php
new file mode 100644 (file)
index 0000000..0a8d394
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * A factory class for communicator
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Core 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 CommunicatorFactory extends ObjectFactory {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Returns a singleton communicator instance. If no instance is found, it fill
+        * be generated and stored in registry, else the communicator from the
+        * registry will be returned.
+        *
+        * @param       $configEntry                    A configuration entry naming the real class' name
+        * @parasm      $communicatorType               Type of the communicator, can currently be 'node'
+        * @return      $communicatorInstance   A communicator instance
+        */
+       public static final function createCommunicatorInstance ($configEntry, $communicatorType) {
+               // If there is no communicator?
+               if (Registry::getRegistry()->instanceExists($communicatorType . '_communicator')) {
+                       // Get communicator from registry
+                       $communicatorInstance = Registry::getRegistry()->getInstance($communicatorType . '_communicator');
+               } else {
+                       // Get the communicator instance
+                       $communicatorInstance = self::createObjectByConfiguredName($configEntry);
+
+                       // Add it to the registry
+                       Registry::getRegistry()->addInstance($communicatorType . '_communicator', $communicatorInstance);
+               }
+
+               // Return the instance
+               return $communicatorInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/factories/states/communicator/.htaccess b/application/hub/main/factories/states/communicator/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/factories/states/communicator/class_CommunicatorStateFactory.php b/application/hub/main/factories/states/communicator/class_CommunicatorStateFactory.php
new file mode 100644 (file)
index 0000000..8f5d9b1
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+/**
+ * A factory class for communicator states
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Core 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 CommunicatorStateFactory extends ObjectFactory {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of a configurable communicator state and sets it in the
+        * given communicator instance.
+        *
+        * @param       $stateName                              Name of the state
+        * @param       $communicatorInstance   A Communicator class instance
+        * @return      $stateInstance                  A Stateable class instance
+        */
+       public static final function createCommunicatorStateInstanceByName ($stateName, Communicator $communicatorInstance) {
+               // Then construct the class' configuraton entry
+               $className = 'communicator_' . $stateName . '_state_class';
+
+               // Get a class from that configuration entry
+               $stateInstance = self::createObjectByConfiguredName($className, array($communicatorInstance));
+
+               // Debug message
+               self::createDebugInstance(__CLASS__)->debugOutput('COMMUNICATOR-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Communicator state has changed from ' . $communicatorInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
+               // Once we have that state, set it in the communicator instance
+               $communicatorInstance->setStateInstance($stateInstance);
+
+               // Update communicator data
+               $communicatorInstance->updateCommunicatorData();
+
+               // For any purposes, return the state instance
+               return $stateInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/factories/states/crawler/.htaccess b/application/hub/main/factories/states/crawler/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/factories/states/crawler/class_CrawlerStateFactory.php b/application/hub/main/factories/states/crawler/class_CrawlerStateFactory.php
new file mode 100644 (file)
index 0000000..7b4c675
--- /dev/null
@@ -0,0 +1,65 @@
+<?php
+/**
+ * A factory class for crawler states
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Core 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 CrawlerStateFactory extends ObjectFactory {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of a configurable crawler state and sets it in the
+        * given crawler instance.
+        *
+        * @param       $stateName                              Name of the state
+        * @param       $crawlerInstance        A Crawler class instance
+        * @return      $stateInstance                  A Stateable class instance
+        */
+       public static final function createCrawlerStateInstanceByName ($stateName, Crawler $crawlerInstance) {
+               // Then construct the class' configuraton entry
+               $className = 'crawler_' . $stateName . '_state_class';
+
+               // Get a class from that configuration entry
+               $stateInstance = self::createObjectByConfiguredName($className, array($crawlerInstance));
+
+               // Debug message
+               self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Crawler state has changed from ' . $crawlerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
+               // Once we have that state, set it in the crawler instance
+               $crawlerInstance->setStateInstance($stateInstance);
+
+               // Update crawler data
+               $crawlerInstance->updateCrawlerData();
+
+               // For any purposes, return the state instance
+               return $stateInstance;
+       }
+}
+
+// [EOF]
+?>
index a119fec396184a819d8b432137efc159abfac8a3..799f9b60a9eecdb51fbf610c5de824642e573af4 100644 (file)
@@ -64,10 +64,18 @@ class CrawlerTaskHandlerInitializerFilter extends BaseCrawlerFilter implements F
                /*
                 * Register all tasks:
                 *
-                * 1) ...
+                * 1) "Communicator" for crawler->node communication
                 */
-               //$taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_???_task_class');
-               //$handlerInstance->registerTask('crawler_???', $taskInstance);
+               $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_node_communicator_task_class');
+               $handlerInstance->registerTask('crawler_node_communicator', $taskInstance);
+
+               // 2) Local URL fetcher (fetches URLs locally and adds them to the analyzer's input stack)
+               $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_local_url_fetcher_task_class');
+               $handlerInstance->registerTask('crawler_local_url_fetcher', $taskInstance);
+
+               // 3) Remote URL fetcher (let fetch URLs by other crawler nodes and also adds them to the stack)
+               $taskInstance = ObjectFactory::createObjectByConfiguredName('crawler_remote_url_fetcher_task_class');
+               $handlerInstance->registerTask('crawler_remote_url_fetcher', $taskInstance);
 
                // Put the task handler in registry
                Registry::getRegistry()->addInstance('task_handler', $handlerInstance);
index e5abac69ce9ef940e4370566558bf875ec5477f3..5fc569a9173b8d0274c3f9c07924cd3ce45f1b75 100644 (file)
@@ -306,10 +306,7 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Registerable,
         * @return      void
         */
        private function initState() {
-               /*
-                * Get the state factory and create the initial state, we don't need
-                * the state instance here
-                */
+               // Get the state factory and create the initial state.
                PeerStateFactory::createPeerStateInstanceByName('init', $this);
        }
 
index dbc20dd02d99bfb83ddb9515f677063ddb4d28ff..7e9f207b6d3a9495331f33ea5db8fba944ea3735 100644 (file)
@@ -55,7 +55,7 @@ class HubChashMiner extends BaseHubMiner implements MinerHelper, Registerable {
         * to show up.
         *
         * In this method we already know that the in-buffer is going depleted so
-        * we don't need to double-check it here.
+        * no need to double-check it here.
         *
         * @return      void
         */
index a8e322321da5d3c43d23a0f83fed883b442f1f8a..27ac974e8e11e092f713f5466df8b5d6bca9c3dd 100644 (file)
@@ -111,7 +111,7 @@ abstract class BaseHubMiner extends BaseHubSystem implements Updateable {
         * to show up.
         *
         * In this method we already know that the in-buffer is going depleted so
-        * we don't need to double-check it here.
+        * no need to double-check it here.
         *
         * @return      void
         */
index 175862d5d10c67357bf6a56275687e5e079d7c40..3dd419d36aeefc9b3f70906adb9ab1fe41d6cde6 100644 (file)
@@ -104,10 +104,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria {
         * @return      void
         */
        private function initState() {
-               /*
-                * Get the state factory and create the initial state, we don't need
-                * the state instance here
-                */
+               // Get the state factory and create the initial state.
                NodeStateFactory::createNodeStateInstanceByName('init', $this);
        }
 
index 816d034e172695745870656be0e8f93cd0d73129..8eeaf8be3299f62ea2845f388f8ae9834d182652 100644 (file)
@@ -952,7 +952,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] . '(' . BaseRawDataHandler::SOCKET_ERROR_UNHANDLED . ')');
                assert($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] == BaseRawDataHandler::SOCKET_ERROR_UNHANDLED);
 
-               // Remove the last chunk SEPARATOR (because it is being added and we don't need it)
+               // Remove the last chunk SEPARATOR (because there is no need for it)
                if (substr($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
                        // It is there and should be removed
                        $decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA] = substr($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA], 0, -1);
index 9e5c0f26085113436cf9f1885777342c77662c3a..2e0a0a1bca32dd93e46c22ddbc9beb01e35c5a3c 100644 (file)
@@ -78,7 +78,7 @@ class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer,
         * @return      void
         * @todo        ~60% done
         */
-       public function prepareUnitProduction (Stateable $stateInstance) {
+       public function initUnitProduction (Stateable $stateInstance) {
                // First get a database wrapper because we want to permanently store test units
                $wrapperInstance = DatabaseWrapperFactory::createWrapperByConfiguredName('cruncher_unit_db_wrapper_class');
 
diff --git a/application/hub/main/states/communicator/.htaccess b/application/hub/main/states/communicator/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/states/communicator/active/.htaccess b/application/hub/main/states/communicator/active/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/states/communicator/active/class_CommunicatorActiveState.php b/application/hub/main/states/communicator/active/class_CommunicatorActiveState.php
new file mode 100644 (file)
index 0000000..e6a30e1
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/**
+ * A active communicator state class
+ *
+ * @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 CommunicatorActiveState extends BaseCommunicatorState implements Stateable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructo
+               parent::__construct(__CLASS__);
+
+               // Set state name
+               $this->setStateName('active');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $communicatorInstance   An instance of a Communicator class
+        * @return      $stateInstance                  An instance of a Stateable class
+        */
+       public static final function createCommunicatorActiveState (Communicator $communicatorInstance) {
+               // Get new instance
+               $stateInstance = new CommunicatorActiveState();
+
+               // Set the communicator instance
+               $stateInstance->setCommunicatorInstance($communicatorInstance);
+
+               // Return the prepared instance
+               return $stateInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/states/communicator/class_ b/application/hub/main/states/communicator/class_
new file mode 100644 (file)
index 0000000..23c71a8
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * A ??? communicator state class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Core 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 Communicator???State extends BaseCommunicatorState implements Stateable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set state name
+               $this->setStateName('!!!');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $communicatorInstance   An instance of a Communicator class
+        * @return      $stateInstance                  An instance of a Stateable class
+        */
+       public final static function createCommunicator???State (Communicator $communicatorInstance) {
+               // Get new instance
+               $stateInstance = new Communicator???State();
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('COMMUNICATOR-STATE: Has changed from ' . $communicatorInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
+               // Set the communicator instance
+               $stateInstance->setCommunicatorInstance($communicatorInstance);
+
+               // Return the prepared instance
+               return $stateInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/states/communicator/class_BaseCommunicatorState.php b/application/hub/main/states/communicator/class_BaseCommunicatorState.php
new file mode 100644 (file)
index 0000000..b6bd049
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/**
+ * A general communicator state class
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Core 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 BaseCommunicatorState extends BaseState {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+
+       /**
+        * Validates whether the state is 'active' or throws an exception if
+        * it is every other state.
+        *
+        * @return      void
+        * @throws      InvalidStateException   If the state is not 'active'
+        */
+       public function validateCommunicatorStateIsActive () {
+               // Just compare it...
+               if (!$this instanceof CommunicatorActiveState) {
+                       // Throw the exception
+                       throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
+               } // END - if
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/states/communicator/init/.htaccess b/application/hub/main/states/communicator/init/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/states/communicator/init/class_CommunicatorInitState.php b/application/hub/main/states/communicator/init/class_CommunicatorInitState.php
new file mode 100644 (file)
index 0000000..86f7455
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+/**
+ * A init communicator state class
+ *
+ * @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 CommunicatorInitState extends BaseCommunicatorState implements Stateable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructo
+               parent::__construct(__CLASS__);
+
+               // Set state name
+               $this->setStateName('init');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $communicatorInstance   An instance of a Communicator class
+        * @return      $stateInstance                  An instance of a Stateable class
+        */
+       public static final function createCommunicatorInitState (Communicator $communicatorInstance) {
+               // Get new instance
+               $stateInstance = new CommunicatorInitState();
+
+               // Set the communicator instance
+               $stateInstance->setCommunicatorInstance($communicatorInstance);
+
+               // Return the prepared instance
+               return $stateInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/states/crawler/.htaccess b/application/hub/main/states/crawler/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/states/crawler/active/.htaccess b/application/hub/main/states/crawler/active/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/states/crawler/active/class_CrawlerActiveState.php b/application/hub/main/states/crawler/active/class_CrawlerActiveState.php
new file mode 100644 (file)
index 0000000..cac3289
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+/**
+ * A active crawler state class
+ *
+ * @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 CrawlerActiveState extends BaseCrawlerState implements Stateable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructo
+               parent::__construct(__CLASS__);
+
+               // Set state name
+               $this->setStateName('active');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $crawlerInstance        An instance of a Crawler class
+        * @return      $stateInstance          An instance of a Stateable class
+        */
+       public static final function createCrawlerActiveState (Crawler $crawlerInstance) {
+               // Get new instance
+               $stateInstance = new CrawlerActiveState();
+
+               // Set the crawler instance
+               $stateInstance->setCrawlerInstance($crawlerInstance);
+
+               // Return the prepared instance
+               return $stateInstance;
+       }
+
+       /**
+        * Executes the state with given Executor instance
+        *
+        * @param       $executorInstance       An instance of a Executor class
+        * @return      void
+        * @todo        0% done
+        */
+       public function executeState (Executor $executorInstance) {
+               $this->partialStub('Unfinished method, executorInstance=' . $executorInstance->__toString());
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/states/crawler/booting/.htaccess b/application/hub/main/states/crawler/booting/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/states/crawler/booting/class_CrawlerBootingState.ph b/application/hub/main/states/crawler/booting/class_CrawlerBootingState.ph
new file mode 100644 (file)
index 0000000..289d49e
--- /dev/null
@@ -0,0 +1,14 @@
+
+       /**
+        * State change if the communicator has fully initialized.
+        *
+        * @return      void
+        * @todo        ~30% done
+        */
+       public function communicatorHasInitialized () {
+               // Please implement
+               $this->partialStub('Unfinished method.');
+
+               // Change state to 'active'
+               CrawlerStateFactory::createCrawlerStateInstanceByName('active', $this->getCrawlerInstance());
+       }
diff --git a/application/hub/main/states/crawler/booting/class_CrawlerBootingState.php b/application/hub/main/states/crawler/booting/class_CrawlerBootingState.php
new file mode 100644 (file)
index 0000000..a3121e8
--- /dev/null
@@ -0,0 +1,68 @@
+<?php
+/**
+ * A booting crawler state class
+ *
+ * @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 CrawlerBootingState extends BaseCrawlerState implements Stateable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructo
+               parent::__construct(__CLASS__);
+
+               // Set state name
+               $this->setStateName('booting');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $crawlerInstance        An instance of a Crawler class
+        * @return      $stateInstance          An instance of a Stateable class
+        */
+       public static final function createCrawlerBootingState (Crawler $crawlerInstance) {
+               // Get new instance
+               $stateInstance = new CrawlerBootingState();
+
+               // Set the crawler instance
+               $stateInstance->setCrawlerInstance($crawlerInstance);
+
+               // Return the prepared instance
+               return $stateInstance;
+       }
+
+       /**
+        * Executes the state with given Executor instance
+        *
+        * @param       $executorInstance       An instance of a Executor class
+        * @return      void
+        * @todo        0% done
+        */
+       public function executeState (Executor $executorInstance) {
+               $this->partialStub('Unfinished method, executorInstance=' . $executorInstance->__toString());
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/states/crawler/class_ b/application/hub/main/states/crawler/class_
new file mode 100644 (file)
index 0000000..7579778
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * A ??? crawler state class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Crawler 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 Crawler???State extends BaseCrawlerState implements Stateable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set state name
+               $this->setStateName('!!!');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $crawlerInstance        An instance of a Crawler class
+        * @return      $stateInstance                  An instance of a Stateable class
+        */
+       public final static function createCrawler???State (Crawler $crawlerInstance) {
+               // Get new instance
+               $stateInstance = new Crawler???State();
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('COMMUNICATOR-STATE: Has changed from ' . $crawlerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
+               // Set the crawler instance
+               $stateInstance->setCrawlerInstance($crawlerInstance);
+
+               // Return the prepared instance
+               return $stateInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/states/crawler/class_BaseCrawlerState.php b/application/hub/main/states/crawler/class_BaseCrawlerState.php
new file mode 100644 (file)
index 0000000..03dbf5f
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/**
+ * A general crawler state class
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Crawler 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 BaseCrawlerState extends BaseState {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+
+       /**
+        * Validates whether the state is 'active' or throws an exception if
+        * it is every other state.
+        *
+        * @return      void
+        * @throws      InvalidStateException   If the state is not 'active'
+        */
+       public function validateCrawlerStateIsActive () {
+               // Just compare it...
+               if (!$this instanceof CrawlerActiveState) {
+                       // Throw the exception
+                       throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
+               } // END - if
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/states/crawler/init/.htaccess b/application/hub/main/states/crawler/init/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/states/crawler/init/class_CrawlerInitState.php b/application/hub/main/states/crawler/init/class_CrawlerInitState.php
new file mode 100644 (file)
index 0000000..c6d6b8b
--- /dev/null
@@ -0,0 +1,82 @@
+<?php
+/**
+ * A init crawler state class
+ *
+ * @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 CrawlerInitState extends BaseCrawlerState implements Stateable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructo
+               parent::__construct(__CLASS__);
+
+               // Set state name
+               $this->setStateName('init');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $crawlerInstance        An instance of a Crawler class
+        * @return      $stateInstance          An instance of a Stateable class
+        */
+       public static final function createCrawlerInitState (Crawler $crawlerInstance) {
+               // Get new instance
+               $stateInstance = new CrawlerInitState();
+
+               // Set the crawler instance
+               $stateInstance->setCrawlerInstance($crawlerInstance);
+
+               // Return the prepared instance
+               return $stateInstance;
+       }
+
+       /**
+        * Executes the state with given Executor instance
+        *
+        * @param       $executorInstance       An instance of a Executor class
+        * @return      void
+        */
+       public function executeState (Executor $executorInstance) {
+               // Initialize the executor (can be a Communicator instance)
+               $executorInstance->initExecutor($this);
+       }
+
+       /**
+        * State change if the communicator has fully initialized.
+        *
+        * @return      void
+        * @todo        ~30% done
+        */
+       public function communicatorHasInitialized () {
+               // Please implement
+               $this->partialStub('Unfinished method.');
+
+               // Change state to 'booting'
+               CrawlerStateFactory::createCrawlerStateInstanceByName('booting', $this->getCrawlerInstance());
+       }
+}
+
+// [EOF]
+?>
index dbe08e3043eee19f014af4749c0d62ca27b6d6b9..bccf3de5da21ef7a999a003351f142da1c84067e 100644 (file)
@@ -59,8 +59,8 @@ class CruncherInitState extends BaseCruncherState implements Stateable {
         * @return      void
         */
        public function executeState (Executor $executorInstance) {
-               // Now prepare the unit production to maybe become 'virgin' or 'active' if work/test units are there
-               $executorInstance->prepareUnitProduction($this);
+               // Initialize the unit production to maybe become 'virgin' or 'active' if work/test units are there
+               $executorInstance->initUnitProduction($this);
        }
 
        /**
diff --git a/application/hub/main/tasks/crawler/.htaccess b/application/hub/main/tasks/crawler/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/tasks/crawler/class_Crawler b/application/hub/main/tasks/crawler/class_Crawler
new file mode 100644 (file)
index 0000000..37d2d04
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * A ??? task for crawlers
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Crawler 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 Crawler???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 createCrawler???Task () {
+               // Get new instance
+               $taskInstance = new Crawler???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/crawler/communicator/.htaccess b/application/hub/main/tasks/crawler/communicator/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/tasks/crawler/communicator/class_CrawlerNodeCommunicatorTask.php b/application/hub/main/tasks/crawler/communicator/class_CrawlerNodeCommunicatorTask.php
new file mode 100644 (file)
index 0000000..9b1d4ff
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+/**
+ * A NodeCommunicator task for crawlers
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Crawler 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 CrawlerNodeCommunicatorTask 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 createCrawlerNodeCommunicatorTask () {
+               // Get new instance
+               $taskInstance = new CrawlerNodeCommunicatorTask();
+
+               // 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
+        */
+       public function executeTask () {
+               // Get the communicator instance
+               $communicatorInstance = CommunicatorFactory::createCommunicatorInstance('crawler_node_communicator_class', 'node');
+
+               // Get the current crawler state from registry
+               $stateInstance = Registry::getRegistry()->getInstance('crawler')->getStateInstance();
+
+               // Debug message
+               /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Executing stateInstance=' . $stateInstance->__toString());
+
+               // We can now invoke that state instance and pass our communicator instance for generating some test units
+               $stateInstance->executeState($communicatorInstance);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/tasks/crawler/url_fetcher/.htaccess b/application/hub/main/tasks/crawler/url_fetcher/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/tasks/crawler/url_fetcher/local/.htaccess b/application/hub/main/tasks/crawler/url_fetcher/local/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/tasks/crawler/url_fetcher/local/class_CrawlerLocalUrlFetcherTask.php b/application/hub/main/tasks/crawler/url_fetcher/local/class_CrawlerLocalUrlFetcherTask.php
new file mode 100644 (file)
index 0000000..2f4b43f
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * A LocalUrlFetcher task for crawlers
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Crawler 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 CrawlerLocalUrlFetcherTask 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 createCrawlerLocalUrlFetcherTask () {
+               // Get new instance
+               $taskInstance = new CrawlerLocalUrlFetcherTask();
+
+               // 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/crawler/url_fetcher/remote/.htaccess b/application/hub/main/tasks/crawler/url_fetcher/remote/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/tasks/crawler/url_fetcher/remote/class_CrawlerRemoteUrlFetcherTask.php b/application/hub/main/tasks/crawler/url_fetcher/remote/class_CrawlerRemoteUrlFetcherTask.php
new file mode 100644 (file)
index 0000000..57d3009
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/**
+ * A RemoteUrlFetcher task for crawlers
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2014 Crawler 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 CrawlerRemoteUrlFetcherTask 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 createCrawlerRemoteUrlFetcherTask () {
+               // Get new instance
+               $taskInstance = new CrawlerRemoteUrlFetcherTask();
+
+               // 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]
+?>