]> git.mxchange.org Git - hub.git/commitdiff
Some refacturings:
authorRoland Häder <roland@mxchange.org>
Fri, 27 Apr 2012 20:16:46 +0000 (20:16 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 27 Apr 2012 20:16:46 +0000 (20:16 +0000)
- Moved [g|s]et[Node|Session]Id() from BaseHubNode to BaseHubSystem
- This allows $nodeInstance to be removed from some method signatures
- Debug line added (which will be noisy, I know)
- TODOs.txt updated

application/hub/interfaces/package/class_Deliverable.php
application/hub/main/class_BaseHubSystem.php
application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php
application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/package/class_NetworkPackage.php
docs/TODOs.txt

index d38f4504cf2dcd54202fe48272a572c1db494d2a..517b2bb5e129650ca0534db805c10b9167a2b7cf 100644 (file)
@@ -27,10 +27,9 @@ interface Deliverable extends FrameworkInterface {
         * from given template instance and pushing it on the 'undeclared' stack.
         *
         * @param       $helperInstance         An instance of a HelpableHub class
-        * @param       $nodeInstance           An instance of a NodeHelper class
         * @return      void
         */
-       function enqueueRawDataFromTemplate (HelpableHub $helperInstance, NodeHelper $nodeInstance);
+       function enqueueRawDataFromTemplate (HelpableHub $helperInstance);
 
        /**
         * Checks whether a package has been enqueued for delivery.
index b6431b158eb696dbc6f4b422ec3fd7dc21793df5..414be86c6bff471a993dc79ecedd32cfd387e642 100644 (file)
@@ -282,6 +282,46 @@ class BaseHubSystem extends BaseFrameworkSystem {
                return $this->assemblerInstance;
        }
 
+       /**
+        * Setter for node id
+        *
+        * @param       $nodeId         Our new node id
+        * @return      void
+        */
+       private final function setNodeId ($nodeId) {
+               // Set it config now
+               $this->getConfigInstance()->setConfigEntry('node_id', (string) $nodeId);
+       }
+
+       /**
+        * Getter for node id
+        *
+        * @return      $nodeId         Current node id
+        */
+       private final function getNodeId () {
+               // Get it from config
+               return $this->getConfigInstance()->getConfigEntry('node_id');
+       }
+
+       /**
+        * Setter for session id
+        *
+        * @param       $sessionId              Our new session id
+        * @return      void
+        */
+       private final function setSessionId ($sessionId) {
+               $this->getConfigInstance()->setConfigEntry('session_id', (string) $sessionId);
+       }
+
+       /**
+        * Getter for session id
+        *
+        * @return      $sessionId              Current session id
+        */
+       public final function getSessionId () {
+               return $this->getConfigInstance()->getConfigEntry('session_id');
+       }
+
        /**
         * Constructs a callable method name from given socket error code. If the
         * method is not found, a generic one is used.
index 7f4bf97b7807b726217dda3a4392f758581212f4..d87de3c5e8ecb5a9242c3c3227e84289dfae0a0b 100644 (file)
@@ -98,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, $nodeInstance);
+               $packageInstance->enqueueRawDataFromTemplate($this);
        }
 
        /**
index 26761f19f093ee13b9e97b858be08e9e9163d73a..26609fd8fd45742300708ff0c2153d44e93ad9a4 100644 (file)
@@ -93,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, $nodeInstance);
+               $packageInstance->enqueueRawDataFromTemplate($this);
        }
 
        /**
index 07974fad42ddec9c2d308b124c7a67bac54eef84..bbd63bf6a98a74e37396506ed18d48fb2c3036cd 100644 (file)
@@ -86,46 +86,6 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                NodeStateFactory::createNodeStateInstanceByName('init', $this);
        }
 
-       /**
-        * Setter for node id
-        *
-        * @param       $nodeId         Our new node id
-        * @return      void
-        */
-       private final function setNodeId ($nodeId) {
-               // Set it config now
-               $this->getConfigInstance()->setConfigEntry('node_id', (string) $nodeId);
-       }
-
-       /**
-        * Getter for node id
-        *
-        * @return      $nodeId         Current node id
-        */
-       private final function getNodeId () {
-               // Get it from config
-               return $this->getConfigInstance()->getConfigEntry('node_id');
-       }
-
-       /**
-        * Setter for session id
-        *
-        * @param       $sessionId              Our new session id
-        * @return      void
-        */
-       private final function setSessionId ($sessionId) {
-               $this->getConfigInstance()->setConfigEntry('session_id', (string) $sessionId);
-       }
-
-       /**
-        * Getter for session id
-        *
-        * @return      $sessionId              Current session id
-        */
-       public final function getSessionId () {
-               return $this->getConfigInstance()->getConfigEntry('session_id');
-       }
-
        /**
         * Setter for query instance
         *
index 1fb432da5e809a30cebb6d7d0d368a2677a3e7f2..3549f0d735870fa7e984a77fea6017221f96cdcf 100644 (file)
@@ -250,15 +250,14 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         * @param       $helperInstance         An instance of a HelpableHub class
         * @param       $nodeInstance           An instance of a NodeHelper class
         * @return      $hash                           Hash for given package content
-        * @todo        $helperInstance is unused
         */
-       private function getHashFromContent ($content, HelpableHub $helperInstance, NodeHelper $nodeInstance) {
+       private function getHashFromContent ($content) {
                // Create the hash
                // @TODO crc32() is very weak, but it needs to be fast
                $hash = crc32(
                        $content .
                        self::PACKAGE_CHECKSUM_SEPARATOR .
-                       $nodeInstance->getSessionId() .
+                       $this->getSessionId() .
                        self::PACKAGE_CHECKSUM_SEPARATOR .
                        $this->getCompressorInstance()->getCompressorExtension()
                );
@@ -473,10 +472,9 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         * from given template instance and pushing it on the 'undeclared' stack.
         *
         * @param       $helperInstance         An instance of a HelpableHub class
-        * @param       $nodeInstance           An instance of a NodeHelper class
         * @return      void
         */
-       public function enqueueRawDataFromTemplate (HelpableHub $helperInstance, NodeHelper $nodeInstance) {
+       public function enqueueRawDataFromTemplate (HelpableHub $helperInstance) {
                // Get the raw content ...
                $content = $helperInstance->getTemplateInstance()->getRawTemplateData();
 
@@ -498,7 +496,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                        // - separator
                        self::PACKAGE_MASK_SEPARATOR,
                        // 4.) Checksum
-                       $this->getHashFromContent($content, $helperInstance, $nodeInstance)
+                       $this->getHashFromContent($content)
                );
 
                // Now prepare the temporary array and push it on the 'undeclared' stack
@@ -507,7 +505,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                        self::PACKAGE_DATA_RECIPIENT => $helperInstance->getRecipientType(),
                        self::PACKAGE_DATA_CONTENT   => $content,
                        self::PACKAGE_DATA_STATUS    => self::PACKAGE_STATUS_NEW,
-                       self::PACKAGE_DATA_SIGNATURE => $this->generatePackageSignature($content, $nodeInstance->getSessionId())
+                       self::PACKAGE_DATA_SIGNATURE => $this->generatePackageSignature($content, $this->getSessionId())
                ));
        }
 
@@ -715,6 +713,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                 * Also make sure the error code is SOCKET_ERROR_UNHANDLED because we
                 * only want to handle unhandled packages here.
                 */
+               /* NOISY-DEBUG: */ $this->debugOutput('NETWORK-PACKAGE: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE]);
                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)
index 8a625223338fb4eb81613098434cfadb565e39f7..ee4879dd877fabef170183d84737e233ef7d3a7c 100644 (file)
@@ -6,7 +6,7 @@
 ./application/hub/interfaces/helper/connections/class_ConnectionHelper.php:38:  * @todo        We may want to implement a filter for ease notification of other objects like our pool
 ./application/hub/interfaces/helper/messages/class_MessageHelper.php:10: * @todo               Please find another name for this interface
 ./application/hub/interfaces/nodes/class_NodeHelper.php:10: * @todo            We need to find a better name for this interface
-./application/hub/main/class_BaseHubSystem.php:400:                            // @TODO On some systems it is 134, on some 107?
+./application/hub/main/class_BaseHubSystem.php:440:                            // @TODO On some systems it is 134, on some 107?
 ./application/hub/main/commands/console/class_HubConsoleChatCommand.php:107:    * @todo        Should we add some more filters?
 ./application/hub/main/commands/console/class_HubConsoleChatCommand.php:58:     * @todo        Try to create a ChatActivationTask or so
 ./application/hub/main/commands/console/class_HubConsoleCruncherCommand.php:107:        * @todo        Should we add some more filters?
@@ -75,9 +75,9 @@
 ./application/hub/main/nodes/boot/class_HubBootNode.php:119:           // @TODO Add some filters here
 ./application/hub/main/nodes/boot/class_HubBootNode.php:58:     * @todo        add some more special bootstrap things for this boot node
 ./application/hub/main/nodes/boot/class_HubBootNode.php:99:     * @todo        Unfinished method
-./application/hub/main/nodes/class_BaseHubNode.php:384:         * @todo        Try to make this method more generic so we can move it in BaseFrameworkSystem
-./application/hub/main/nodes/class_BaseHubNode.php:424:         * @todo        Change the first if() block to check for a specific state
-./application/hub/main/nodes/class_BaseHubNode.php:597:                // @TODO Add some criteria, e.g. if the node is active or so
+./application/hub/main/nodes/class_BaseHubNode.php:344:         * @todo        Try to make this method more generic so we can move it in BaseFrameworkSystem
+./application/hub/main/nodes/class_BaseHubNode.php:384:         * @todo        Change the first if() block to check for a specific state
+./application/hub/main/nodes/class_BaseHubNode.php:557:                // @TODO Add some criteria, e.g. if the node is active or so
 ./application/hub/main/nodes/list/class_HubListNode.php:58:     * @todo        Implement more bootstrap steps
 ./application/hub/main/nodes/list/class_HubListNode.php:68:     * @todo        Unfinished method
 ./application/hub/main/nodes/list/class_HubListNode.php:91:            // @TODO Add some filters here
 ./application/hub/main/nodes/regular/class_HubRegularNode.php:68:       * @todo        Unfinished method
 ./application/hub/main/nodes/regular/class_HubRegularNode.php:91:              // @TODO Add some filters here
 ./application/hub/main/package/class_NetworkPackage.php:23: * @todo            Needs to add functionality for handling the object's type
-./application/hub/main/package/class_NetworkPackage.php:248:    * @todo        $helperInstance is unused
-./application/hub/main/package/class_NetworkPackage.php:252:           // @TODO crc32() is very weak, but it needs to be fast
-./application/hub/main/package/class_NetworkPackage.php:434:                   // @TODO We may want to do somthing more here?
-./application/hub/main/package/class_NetworkPackage.php:562:                   // @TODO Add some logging here
-./application/hub/main/package/class_NetworkPackage.php:692:                   // @TODO Add some logging here
-./application/hub/main/package/class_NetworkPackage.php:812:           // @TODO Add some content here
-./application/hub/main/package/class_NetworkPackage.php:851:    * @todo        This may be enchanced for outgoing packages?
+./application/hub/main/package/class_NetworkPackage.php:256:           // @TODO crc32() is very weak, but it needs to be fast
+./application/hub/main/package/class_NetworkPackage.php:438:                   // @TODO We may want to do somthing more here?
+./application/hub/main/package/class_NetworkPackage.php:565:                   // @TODO Add some logging here
+./application/hub/main/package/class_NetworkPackage.php:695:                   // @TODO Add some logging here
+./application/hub/main/package/class_NetworkPackage.php:816:           // @TODO Add some content here
+./application/hub/main/package/class_NetworkPackage.php:855:    * @todo        This may be enchanced for outgoing packages?
 ./application/hub/main/package/fragmenter/class_PackageFragmenter.php:275:      * @todo        Implement a way to send non-announcement packages with extra-salt
 ./application/hub/main/package/fragmenter/class_PackageFragmenter.php:427:      * @todo        $helperInstance is unused
 ./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:106:                       // @TODO Do something with it