]> git.mxchange.org Git - hub.git/commitdiff
Fixes for crawler:
authorRoland Haeder <roland@mxchange.org>
Sat, 25 Apr 2015 22:30:13 +0000 (00:30 +0200)
committerRoland Haeder <roland@mxchange.org>
Sat, 25 Apr 2015 22:30:13 +0000 (00:30 +0200)
- Removed 2nd parameter $crawlerInstance as this can be get from object registry
- Other improvements

Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/config.php
application/hub/main/class_BaseHubSystem.php
application/hub/main/crawler/class_BaseNodeCrawler.php
application/hub/main/factories/states/crawler/class_CrawlerStateFactory.php
application/hub/main/filter/crawler/class_CrawlerInitializationFilter.php
application/hub/main/source/urls/class_CrawlerUploadedListUrlSource.php
application/hub/main/states/crawler/active/class_CrawlerActiveState.php
application/hub/main/states/crawler/booting/class_CrawlerBootingState.ph
application/hub/main/states/crawler/booting/class_CrawlerBootingState.php
application/hub/main/states/crawler/init/class_CrawlerInitState.php

index 8b39d7ed413929133c250019c6bf6fe1e981ab84..1a8e5fa6b749c30b5689d9999fce16a320300d65 100644 (file)
@@ -920,7 +920,7 @@ $cfg->setConfigEntry('miner_default_mode', 'chash');
 // CFG: MINER-BUFFER-STACKER-CLASS
 $cfg->setConfigEntry('miner_buffer_stacker_class', 'FiFoStacker');
 
-// CFG: HUBCONSOLE-CMD-CRUNCHER-RESOLVER-CLASS
+// CFG: HUB-CONSOLE-CMD-CRUNCHER-RESOLVER-CLASS
 $cfg->setConfigEntry('hub_console_cmd_miner_resolver_class', 'HubConsoleCommandResolver');
 
 // CFG: MINER-PHP-REQUIREMENTS-FILTER
@@ -1008,7 +1008,7 @@ $cfg->setConfigEntry('cruncher_default_mode', 'mcrypt');
 // CFG: CRUNCHER-BUFFER-STACKER-CLASS
 $cfg->setConfigEntry('cruncher_buffer_stacker_class', 'FiFoStacker');
 
-// CFG: HUBCONSOLE-CMD-CRUNCHER-RESOLVER-CLASS
+// CFG: HUB-CONSOLE-CMD-CRUNCHER-RESOLVER-CLASS
 $cfg->setConfigEntry('hubconsole_cmd_cruncher_resolver_class', 'HubConsoleCommandResolver');
 
 // CFG: CRUNCHER-PHP-REQUIREMENTS-FILTER
@@ -1147,7 +1147,7 @@ $cfg->setConfigEntry('cruncher_per_unit_key_limit', 1000);
 //                            Chat Configuration
 ///////////////////////////////////////////////////////////////////////////////
 
-// CFG: HUBCONSOLE-CMD-CHAT-RESOLVER-CLASS
+// CFG: HUB-CONSOLE-CMD-CHAT-RESOLVER-CLASS
 $cfg->setConfigEntry('hubconsole_cmd_chat_resolver_class', 'HubConsoleCommandResolver');
 
 // CFG: CHAT-PHP-REQUIREMENTS-FILTER
@@ -1199,8 +1199,8 @@ $cfg->setConfigEntry('file_stacks_extension', 'stack');
 // CFG: INDEX-EXTENSION
 $cfg->setConfigEntry('index_extension', '.idx');
 
-// CFG: HUBCONSOLE-CMD-CHAT-RESOLVER-CLASS
-$cfg->setConfigEntry('hubconsole_cmd_crawler_resolver_class', 'HubConsoleCommandResolver');
+// CFG: HUB-CONSOLE-CMD-CHAT-RESOLVER-CLASS
+$cfg->setConfigEntry('hub_console_cmd_crawler_resolver_class', 'HubConsoleCommandResolver');
 
 // CFG: CRAWLER-PHP-REQUIREMENTS-FILTER
 $cfg->setConfigEntry('crawler_php_requirements_filter', 'CrawlerPhpRequirementsFilter');
@@ -1480,8 +1480,8 @@ $cfg->setConfigEntry('news_home_limit', 10);
 //                         Apt-Proxy Configuration
 ///////////////////////////////////////////////////////////////////////////////
 
-// CFG: HUBCONSOLE-CMD-APT-PROXY-RESOLVER-CLASS
-$cfg->setConfigEntry('hubconsole_cmd_apt_proxy_resolver_class', 'HubConsoleCommandResolver');
+// CFG: HUB-CONSOLE-CMD-APT-PROXY-RESOLVER-CLASS
+$cfg->setConfigEntry('hub_console_cmd_apt_proxy_resolver_class', 'HubConsoleCommandResolver');
 
 // CFG: APT-PROXY-PHP-REQUIREMENTS-FILTER
 $cfg->setConfigEntry('apt_proxy_php_requirements_filter', 'AptProxyPhpRequirementsFilter');
index 0dc699244990176f7b9f3964ccffc67880594869..e3264277f1f7407733cdb0054e13f015a8710373 100644 (file)
@@ -54,11 +54,6 @@ class BaseHubSystem extends BaseFrameworkSystem {
         */
        private $communicatorInstance = NULL;
 
-       /**
-        * An instance of a crawler
-        */
-       private $crawlerInstance = NULL;
-
        /**
         * An instance of a cruncher
         */
@@ -158,25 +153,6 @@ class BaseHubSystem extends BaseFrameworkSystem {
                $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
         *
index 62ab12074a83b53c1ac107e21c50f88307974d66..d5ce4a5d8288dee6372f70b4694f93bbd70f3ad2 100644 (file)
@@ -37,6 +37,9 @@ class BaseNodeCrawler extends BaseHubSystem {
                // Call parent constructor
                parent::__construct($className);
 
+               // Set this crawler instance in registry
+               Registry::getRegistry()->addInstance('crawler', $this);
+
                // Init state which sets the state to 'init'
                $this->initState();
        }
@@ -48,7 +51,7 @@ class BaseNodeCrawler extends BaseHubSystem {
         */
        private function initState() {
                // Get the state factory and create the initial state.
-               CrawlerStateFactory::createCrawlerStateInstanceByName('init', $this);
+               CrawlerStateFactory::createCrawlerStateInstanceByName('init');
        }
 
        /**
index 08e0cc5549ffda65f0c18592ca796cb4329aaf3e..4b0eb52fb13d769baff26dd844c21974904df471 100644 (file)
@@ -37,15 +37,17 @@ class CrawlerStateFactory extends ObjectFactory {
         * 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) {
+       public static final function createCrawlerStateInstanceByName ($stateName) {
                // Then construct the class' configuraton entry
                $className = 'crawler_' . $stateName . '_state_class';
 
                // Get a class from that configuration entry
-               $stateInstance = self::createObjectByConfiguredName($className, array($crawlerInstance));
+               $stateInstance = self::createObjectByConfiguredName($className);
+
+               // Get crawler instance
+               $crawlerInstance = Registry::getRegistry()->getInstance('crawler');
 
                // Debug message
                self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-STATE-FACTORY[' . __METHOD__ . ':' . __LINE__ . ']: Crawler state has changed from ' . $crawlerInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
index 31ae09a9afae7dc1932912399f130530ee8422a2..570346eeceb543fb08894afe541d7f0bafdcd905 100644 (file)
@@ -65,9 +65,6 @@ class CrawlerInitializationFilter extends BaseCrawlerFilter implements Filterabl
 
                // Add crawler-specific filters
                $crawlerInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
-
-               // Set the crawler instance in registry
-               Registry::getRegistry()->addInstance('crawler', $crawlerInstance);
        }
 }
 
index 4c28ab0c52ef36b0fc49b7c59478c352105b5a06..33caffaf89b054a5b7f48db6f60628c798af5835 100644 (file)
@@ -161,7 +161,7 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvData()=' . count($csvData) . ' - CALLED!');
 
-               // The array has 3 elements, later enhancements may accept more
+               // The array must have a fixed amount of elements, later enhancements may accept more
                assert(count($csvData) == self::CRAWL_ENTRY_SIZE);
 
                /*
@@ -282,7 +282,7 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R
                        return;
                } // END - if
 
-               // ...  with 3 elements, later enhancements may accept more
+               // ...  with a fixed amount of elements, later enhancements may accept more
                assert(count($csvData) == self::CRAWL_ENTRY_SIZE);
 
                /*
@@ -313,7 +313,7 @@ class CrawlerUploadedListUrlSource extends BaseUrlSource implements UrlSource, R
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CRAWLER-SOURCE [' . __METHOD__ . ':' . __LINE__ . ']: csvData[' . gettype($csvData) . ']=' . print_r($csvData, TRUE));
 
-               // It must have 3 elements (see method parseCsvFile() for details)
+               // It must have a fixed amount of elements (see method parseCsvFile() for details)
                assert(count($csvData) == self::CRAWL_ENTRY_SIZE);
 
                // Save it in crawler queue (which will enrich it with way more informations
index e06e9f4d99b7d24087b8b88901dc79cae9c77f23..5abe587235ec85ed3c4dc0b40f2142a4888d742c 100644 (file)
@@ -41,13 +41,10 @@ class CrawlerActiveState extends BaseCrawlerState implements Stateable {
         * @param       $crawlerInstance        An instance of a Crawler class
         * @return      $stateInstance          An instance of a Stateable class
         */
-       public static final function createCrawlerActiveState (Crawler $crawlerInstance) {
+       public static final function createCrawlerActiveState () {
                // Get new instance
                $stateInstance = new CrawlerActiveState();
 
-               // Set the crawler instance
-               $stateInstance->setCrawlerInstance($crawlerInstance);
-
                // Return the prepared instance
                return $stateInstance;
        }
index 289d49e6cdc98f8a1651be5c2c72c65d7a507ad8..ffb733e306dc0c84de5437fbda5880a9ce52648f 100644 (file)
@@ -10,5 +10,5 @@
                $this->partialStub('Unfinished method.');
 
                // Change state to 'active'
-               CrawlerStateFactory::createCrawlerStateInstanceByName('active', $this->getCrawlerInstance());
+               CrawlerStateFactory::createCrawlerStateInstanceByName('active');
        }
index 7e7e52b966270848d34abda51c395a93726a6cca..6edbdbbd78aa94116e40effc07bffc9fc8cf5663 100644 (file)
@@ -38,16 +38,12 @@ class CrawlerBootingState extends BaseCrawlerState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $crawlerInstance        An instance of a Crawler class
-        * @return      $stateInstance          An instance of a Stateable class
+        * @return      $stateInstance  An instance of a Stateable class
         */
-       public static final function createCrawlerBootingState (Crawler $crawlerInstance) {
+       public static final function createCrawlerBootingState () {
                // Get new instance
                $stateInstance = new CrawlerBootingState();
 
-               // Set the crawler instance
-               $stateInstance->setCrawlerInstance($crawlerInstance);
-
                // Return the prepared instance
                return $stateInstance;
        }
index 1e2e4dc2c78f2443799daa487296444df86c6e45..fffd219edbf79ee00dae98dcbe2fedd6c8e0a19a 100644 (file)
@@ -38,16 +38,12 @@ class CrawlerInitState extends BaseCrawlerState implements Stateable {
        /**
         * Creates an instance of this class
         *
-        * @param       $crawlerInstance        An instance of a Crawler class
-        * @return      $stateInstance          An instance of a Stateable class
+        * @return      $stateInstance  An instance of a Stateable class
         */
-       public static final function createCrawlerInitState (Crawler $crawlerInstance) {
+       public static final function createCrawlerInitState () {
                // Get new instance
                $stateInstance = new CrawlerInitState();
 
-               // Set the crawler instance
-               $stateInstance->setCrawlerInstance($crawlerInstance);
-
                // Return the prepared instance
                return $stateInstance;
        }
@@ -74,7 +70,7 @@ class CrawlerInitState extends BaseCrawlerState implements Stateable {
                $this->partialStub('Unfinished method.');
 
                // Change state to 'booting'
-               CrawlerStateFactory::createCrawlerStateInstanceByName('booting', $this->getCrawlerInstance());
+               CrawlerStateFactory::createCrawlerStateInstanceByName('booting');
        }
 }