]> git.mxchange.org Git - hub.git/commitdiff
Refactured nodeInstance to be no longer stored in helpers
authorRoland Häder <roland@mxchange.org>
Mon, 11 Apr 2011 22:48:28 +0000 (22:48 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 11 Apr 2011 22:48:28 +0000 (22:48 +0000)
application/hub/interfaces/helper/hub/class_HelpableHub.php
application/hub/interfaces/package/class_Deliverable.php
application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php
application/hub/main/helper/hub/class_
application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/package/class_NetworkPackage.php
application/hub/main/pools/peer/class_DefaultPeerPool.php
application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php

index 8a648150036caffbed987f238c406726c9ed04d6..7ea364b2257b778141d220517d718f13af5620d4 100644 (file)
@@ -32,9 +32,10 @@ interface HelpableHub extends Helper {
        /**
         * Do the helped attempt by delivering a package to ourselfs
         *
+        * @param       $nodeInstance   An instance of a NodeHelper class
         * @return      void
         */
-       function sendPackage ();
+       function sendPackage (NodeHelper $nodeInstance);
 }
 
 // [EOF]
index 30ee1b57c371f2e39552b70a73beb0c1436ebc1c..d2cfe48f38fe31f9874f019cfba9736b7d2b297f 100644 (file)
@@ -26,10 +26,11 @@ interface Deliverable extends FrameworkInterface {
         * "Enqueues" raw content into this delivery class by reading the raw content
         * from given template instance and pushing it on the 'undeclared' stack.
         *
-        * @param       $helperInstance         A BaseHubHelper instance
+        * @param       $helperInstance         An instance of a BaseHubHelper class
+        * @param       $nodeInstance           An instance of a NodeHelper class
         * @return      void
         */
-       function enqueueRawDataFromTemplate (BaseHubHelper $helperInstance);
+       function enqueueRawDataFromTemplate (BaseHubHelper $helperInstance, NodeHelper $nodeInstance);
 
        /**
         * Checks wether a package has been enqueued for delivery.
index 4db7e06973ab523ca4fda7e3477dbab494587892..7f4bf97b7807b726217dda3a4392f758581212f4 100644 (file)
@@ -44,16 +44,12 @@ class HubDescriptorHelper extends BaseHubHelper implements HelpableHub {
        /**
         * Creates the helper class
         *
-        * @param       $nodeInstance           An instance of a NodeHelper class
         * @return      $helperInstance         A prepared instance of this helper
         */
-       public static final function createHubDescriptorHelper (NodeHelper $nodeInstance) {
+       public static final function createHubDescriptorHelper () {
                // Get new instance
                $helperInstance = new HubDescriptorHelper();
 
-               // Set the node instance
-               $helperInstance->setNodeInstance($nodeInstance);
-
                // Return the prepared instance
                return $helperInstance;
        }
@@ -88,11 +84,12 @@ class HubDescriptorHelper extends BaseHubHelper implements HelpableHub {
         * the code. After this wents fine, the rendered content got "packaged"
         * for network delivery.
         *
+        * @param       $nodeInstance   An instance of a NodeHelper class
         * @return      void
         */
-       public function sendPackage () {
+       public function sendPackage (NodeHelper $nodeInstance) {
                // Sanity check: Is the node in the approx. state? (active)
-               $this->getNodeInstance()->getStateInstance()->validateNodeStateIsActive();
+               $nodeInstance->getStateInstance()->validateNodeStateIsActive();
 
                // Compile the template, this inserts the loaded node data into the gaps.
                $this->getTemplateInstance()->compileTemplate();
@@ -101,7 +98,7 @@ class HubDescriptorHelper extends BaseHubHelper implements HelpableHub {
                $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
 
                // Next, feed the content in. The network package class is a pipe-through class.
-               $packageInstance->enqueueRawDataFromTemplate($this);
+               $packageInstance->enqueueRawDataFromTemplate($this, $nodeInstance);
        }
 
        /**
index 806c4c80559e347ce5c88df49f96b3844439257d..16c632308dd707e9892f0d73d2b63ae6cc14ef0c 100644 (file)
@@ -61,11 +61,12 @@ class Hub???Helper extends BaseHubHelper implements HelpableHub {
        /**
         * Do the helped attempt by delivering a package to ourselfs
         *
+        * @param       $nodeInstance   An instance of a NodeHelper class
         * @return      void
         */
-       public function sendPackage () {
+       public function sendPackage (NodeHelper $nodeInstance) {
                // Sanity check: Is the node in the approx. state? (active)
-               $this->getNodeInstance()->getStateInstance()->validateNodeStateIsActive();
+               $nodeInstance->getStateInstance()->validateNodeStateIsActive();
 
                // Compile the template, this inserts the loaded node data into the gaps.
                $this->getTemplateInstance()->compileTemplate();
index 8d9131db88a937b5d5df0febabb132548ac6a0f0..26761f19f093ee13b9e97b858be08e9e9163d73a 100644 (file)
@@ -44,16 +44,12 @@ class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub {
        /**
         * Creates the helper class
         *
-        * @param       $nodeInstance           An instance of a NodeHelper class
         * @return      $helperInstance         A prepared instance of this helper
         */
-       public static final function createHubSelfConnectHelper (NodeHelper $nodeInstance) {
+       public static final function createHubSelfConnectHelper () {
                // Get new instance
                $helperInstance = new HubSelfConnectHelper();
 
-               // Set the node instance
-               $helperInstance->setNodeInstance($nodeInstance);
-
                // Return the prepared instance
                return $helperInstance;
        }
@@ -83,11 +79,12 @@ class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub {
        /**
         * Do the self-connect attempt by delivering a package to ourselfs
         *
+        * @param       $nodeInstance   An instance of a NodeHelper class
         * @return      void
         */
-       public function sendPackage () {
+       public function sendPackage (NodeHelper $nodeInstance) {
                // Sanity check: Is the node in the approx. state? (active)
-               $this->getNodeInstance()->getStateInstance()->validateNodeStateIsActive();
+               $nodeInstance->getStateInstance()->validateNodeStateIsActive();
 
                // Compile the template, this inserts the loaded node data into the gaps.
                $this->getTemplateInstance()->compileTemplate();
@@ -96,7 +93,7 @@ class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub {
                $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
 
                // Next, feed the content in. The network package class is a pipe-through class.
-               $packageInstance->enqueueRawDataFromTemplate($this);
+               $packageInstance->enqueueRawDataFromTemplate($this, $nodeInstance);
        }
 
        /**
index e9240cb6b00b670eea4fe817f48ba56fc5cea942..c6e4dc051cbd016e3e5965916509202fca9e29dc 100644 (file)
@@ -468,7 +468,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $helperInstance->getTemplateInstance()->compileConfigInVariables();
 
                // "Publish" the descriptor by sending it to the bootstrap/list nodes
-               $helperInstance->sendPackage();
+               $helperInstance->sendPackage($this);
 
                // Change the state, this should be the last line except debug output
                $this->getStateInstance()->nodeAnnouncedToUpperHubs();
@@ -496,7 +496,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $helperInstance->loadDescriptorXml();
 
                // And send the package away
-               $helperInstance->sendPackage();
+               $helperInstance->sendPackage($this);
 
                // Debug output
                $this->debugOutput('HUB: Self Connection: FINISHED');
index c8479677ab683618c752d0fd7218a87219e81a1d..c7e37ab8c4c6a49b573f033dcf05d4360cd17b8d 100644 (file)
@@ -142,16 +142,17 @@ class NetworkPackage extends BaseFrameworkSystem implements Deliverable, Registe
         * "Getter" for hash from given content and helper instance
         *
         * @param       $content        Raw package content
-        * @param       $helperInstance         A BaseHubHelper instance
+        * @param       $helperInstance         An instance of a BaseHubHelper class
+        * @param       $nodeInstance           An instance of a NodeHelper class
         * @return      $hash   Hash for given package content
         */
-       private function getHashFromContent ($content, BaseHubHelper $helperInstance) {
+       private function getHashFromContent ($content, BaseHubHelper $helperInstance, NodeHelper $nodeInstance) {
                // Create the hash
                // @TODO crc32 is not good, but it needs to be fast
                $hash = crc32(
                        $content .
                        ':' .
-                       $helperInstance->getNodeInstance()->getSessionId() .
+                       $nodeInstance->getSessionId() .
                        ':' .
                        $this->getCompressorInstance()->getCompressorExtension()
                );
@@ -271,10 +272,11 @@ class NetworkPackage extends BaseFrameworkSystem implements Deliverable, Registe
         * "Enqueues" raw content into this delivery class by reading the raw content
         * from given template instance and pushing it on the 'undeclared' stack.
         *
-        * @param       $helperInstance         A BaseHubHelper instance
+        * @param       $helperInstance         An instance of a  BaseHubHelper class
+        * @param       $nodeInstance           An instance of a NodeHelper class
         * @return      void
         */
-       public function enqueueRawDataFromTemplate (BaseHubHelper $helperInstance) {
+       public function enqueueRawDataFromTemplate (BaseHubHelper $helperInstance, NodeHelper $nodeInstance) {
                // Get the raw content ...
                $content = $helperInstance->getTemplateInstance()->getRawTemplateData();
 
@@ -290,12 +292,12 @@ class NetworkPackage extends BaseFrameworkSystem implements Deliverable, Registe
                        // 3.) Tags
                        implode(self::PACKAGE_TAGS_SEPERATOR, $helperInstance->getPackageTags()),
                        // 4.) Checksum
-                       $this->getHashFromContent($content, $helperInstance)
+                       $this->getHashFromContent($content, $helperInstance, $nodeInstance)
                );
 
                // Now prepare the temporary array and push it on the 'undeclared' stack
                $this->getStackerInstance()->pushNamed(self::STACKER_NAME_UNDECLARED, array(
-                       'sender'    => $helperInstance->getNodeInstance()->getSessionId(),
+                       'sender'    => $nodeInstance->getSessionId(),
                        'recipient' => $helperInstance->getRecipientType(),
                        'content'   => $content,
                ));
index d57a7f224a4b91b237c8a5581d884cdbff04d71f..fc62b4134b4f321dfa56a4be8a430444e50d732d 100644 (file)
@@ -104,7 +104,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
                        } // END - if
                } else {
                        // Server sockets won't work with socket_getpeername()
-                       $this->debugOutput('POOL: Socket resource is server socket. This is no bug.');
+                       $this->debugOutput('POOL: Socket resource is server socket. This is not a bug.');
                }
 
                // Output error message
index 9e4f517870cb0fb135e727ada73685a37fd7fffb..86be8a9252c1d4e02d463c3ef44a21475ef8d9de 100644 (file)
@@ -75,11 +75,11 @@ class CruncherKeyProducer extends BaseKeyProducer implements KeyProducer, Regist
                // Is this cruncher virgin?
                if (!$stateInstance->isCruncherStateVirgin()) {
                        // This cruncher is not virgin, so skip it
-                       $this->debugOutput('ITERATOR: The cruncher is not virgin. stateInstance=' . $stateInstance->__toString() . '.');
+                       $this->debugOutput('PRODUCER: The cruncher is not virgin. stateInstance=' . $stateInstance->__toString() . '');
                        return;
                } elseif (!$this->getIteratorInstance()->valid()) {
-                       // This iterator has finished his assignment
-                       $this->debugOutput('ITERATOR: Finished creating keys. iteratorinstance=' . $this->getIteratorInstance()->__toString() . '');
+                       // This producer's iterator has finished its assignment
+                       $this->debugOutput('PRODUCER: Finished creating keys. iteratorinstance=' . $this->getIteratorInstance()->__toString() . '');
                        return;
                }
 
@@ -93,8 +93,8 @@ class CruncherKeyProducer extends BaseKeyProducer implements KeyProducer, Regist
                 */
 
                /*
-                * Get current key (which is not the key of the iterator)
-                * This is always an ASCII string.
+                * Get current key (which is not the key of the iterator) This is always
+                * an ASCII string.
                 */
                $currentKey = $this->getIteratorInstance()->current();