]> git.mxchange.org Git - hub.git/commitdiff
Renamed methods (MAY BREAK THINGS)
authorRoland Häder <roland@mxchange.org>
Sat, 4 Aug 2012 23:29:11 +0000 (23:29 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 4 Aug 2012 23:29:11 +0000 (23:29 +0000)
12 files changed:
application/hub/config.php
application/hub/interfaces/decoder/class_Decodeable.php
application/hub/interfaces/discovery/class_DiscoverableRecipient.php
application/hub/interfaces/handler/network/class_Networkable.php
application/hub/interfaces/package/class_Receivable.php
application/hub/main/decoder/package/class_PackageDecoder.php
application/hub/main/discovery/package/class_PackageRecipientDiscovery.php
application/hub/main/handler/network/class_BaseRawDataHandler.php
application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php
application/hub/main/listener/class_BaseListenerDecorator.php
application/hub/main/package/class_NetworkPackage.php
application/hub/main/tasks/network/class_NetworkPackageReaderTask.php

index 1eb266bb800ecf75d0a4af464ba9c01935203761..9422ef935514ab828905c7d189c441bd0d500c63 100644 (file)
@@ -342,8 +342,8 @@ $cfg->setConfigEntry('stacker_outgoing_queue_max_size', 100000);
 // CFG: STACKER-INCOMING-QUEUE-MAX-SIZE
 $cfg->setConfigEntry('stacker_incoming_queue_max_size', 100000);
 
-// CFG: STACKER-DECODED-DATA-MAX-SIZE
-$cfg->setConfigEntry('stacker_decoded_data_max_size', 100);
+// CFG: STACKER-RAW-DATA-MAX-SIZE
+$cfg->setConfigEntry('stacker_raw_data_max_size', 100);
 
 // CFG: STACKER-FINAL-CHUNKS-MAX-SIZE
 $cfg->setConfigEntry('stacker_final_chunks_max_size', 100);
index ebcb427fd079f62794f448b5d9087faddac518f4..afb3d4a7ec9bee45d11aff4d6c067298d5a3e74b 100644 (file)
@@ -39,7 +39,7 @@ interface Decodeable extends FrameworkInterface {
        /**
         * Checks whether decoded packages have arrived (for this peer)
         *
-        * @return      $ifDecodedPackagesLeft  Whether decoded packages have arrived
+        * @return      $ifRawPackagesLeft      Whether decoded packages have arrived
         */
        function ifDeocedPackagesLeft ();
 
index afa752fe43c77af7a331abc075c5fd792af0e3b7..765d3de3ebc3aaed00dbb7f44100bf0c1be956bf 100644 (file)
@@ -33,10 +33,10 @@ interface DiscoverableRecipient extends FrameworkInterface {
        /**
         * Tries to discover all recipients by given decoded package data.
         *
-        * @param       $decodedData    Decoded raw package data array
+        * @param       $decodedData    Raw raw package data array
         * @return      void
         */
-       function discoverDecodedRecipients (array $decodedData);
+       function discoverRawRecipients (array $decodedData);
 
        /**
         * "Getter" for recipient iterator
index 9788a8a4c2055c84163c47a566a10e810b0f93da..93df1400c339e75d2c804bb186abfb6f35a98248 100644 (file)
@@ -37,14 +37,14 @@ interface Networkable extends Handleable {
         *
         * @return      $isPending      Whether decoded data is pending
         */
-       function isDecodedDataPending ();
+       function isRawDataPending ();
 
        /**
         * "Getter" for next decoded data from the stacker
         *
-        * @return      $decodedData    Decoded data from the stacker
+        * @return      $decodedData    Raw data from the stacker
         */
-       function getNextDecodedData ();
+       function getNextRawData ();
 }
 
 // [EOF]
index 0a6dcb384b65bf9f7255c2b64311bccbf8006021..821c8178e299757cbf60c9149c7a9926a93fe280 100644 (file)
@@ -37,14 +37,14 @@ interface Receivable extends FrameworkInterface {
         *
         * @return      void
         */
-       function handleIncomingDecodedData ();
+       function handleIncomingRawData ();
 
        /**
         * Checks whether incoming decoded data is handled.
         *
         * @return      $isHandled      Whether incoming decoded data is handled
         */
-       function isIncomingDecodedDataHandled ();
+       function isIncomingRawDataHandled ();
 
        /**
         * Assembles incoming decoded data so it will become an abstract network
@@ -52,7 +52,7 @@ interface Receivable extends FrameworkInterface {
         *
         * @return      void
         */
-       function assembleDecodedDataToPackage ();
+       function assembleRawDataToPackage ();
 
        /**
         * Checks whether a new message has arrived
@@ -88,7 +88,7 @@ interface Receivable extends FrameworkInterface {
         * @param       $handlerInstance        An instance of a Networkable class
         * @return      void
         */
-       function addDecodedDataToIncomingStack (Networkable $handlerInstance);
+       function addRawDataToIncomingStack (Networkable $handlerInstance);
 
        /**
         * "Decode" the package content. This method does also verify the attached hash
@@ -120,7 +120,7 @@ interface Receivable extends FrameworkInterface {
         * @param       $decodedData    An array with decoded raw package data
         * @return      void
         */
-       function handleDecodedData (array $decodedData);
+       function handleRawData (array $decodedData);
 }
 
 // [EOF]
index 2e62c63c8cd2680f6d881809841b45258ad70fa1..f3f9257e18c99e453118088895a4a756bccf6f08 100644 (file)
@@ -95,7 +95,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable {
                $discoveryInstance = PackageDiscoveryFactory::createPackageDiscoveryInstance();
 
                // ... then disover all recipient (might be only one), this package may shall be forwarded
-               $discoveryInstance->discoverDecodedRecipients($decodedData);
+               $discoveryInstance->discoverRawRecipients($decodedData);
 
                // Check for 'recipient' field (the 'sender' field and others are ignored here)
                if ($discoveryInstance->isRecipientListEmpty()) {
@@ -103,21 +103,21 @@ class PackageDecoder extends BaseDecoder implements Decodeable {
                        $this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECODED_PACKAGE, $decodedData);
                } else {
                        // Forward the package to the next node
-                       $this->getPackageInstance()->forwardDecodedPackage($decodedData);
+                       $this->getPackageInstance()->forwardRawPackage($decodedData);
                }
        }
 
        /**
         * Checks whether decoded packages have arrived (for this peer)
         *
-        * @return      $ifDecodedPackagesLeft  Whether decoded packages have arrived
+        * @return      $ifRawPackagesLeft      Whether decoded packages have arrived
         */
        public function ifDeocedPackagesLeft () {
                // Check it ...
-               $ifDecodedPackagesLeft = (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_DECODED_PACKAGE));
+               $ifRawPackagesLeft = (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_DECODED_PACKAGE));
 
                // ... return it
-               return $ifDecodedPackagesLeft;
+               return $ifRawPackagesLeft;
        }
 
        /**
@@ -130,7 +130,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable {
                $decodedData = $this->getStackerInstance()->popNamed(self::STACKER_NAME_DECODED_PACKAGE);
 
                // Handle it
-               $this->getPackageInstance()->handleDecodedData($decodedData);
+               $this->getPackageInstance()->handleRawData($decodedData);
        }
 }
 
index 3b12418dd1a7d68e756f88f2bfbc32b4e46498b7..3ebcbe30f89ba2398ad09205f25399c811f29dae 100644 (file)
@@ -129,12 +129,12 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
        /**
         * Tries to discover all recipients by given decoded package data.
         *
-        * @param       $decodedData    Decoded raw package data array
+        * @param       $decodedData    Raw raw package data array
         * @return      void
         * @todo        Add some validation of recipient field, e.g. ip:port is found
         * @todo        The if() does only check for TCP, not UDP, e.g. try to get a $handlerInstance here
         */
-       public function discoverDecodedRecipients (array $decodedData) {
+       public function discoverRawRecipients (array $decodedData) {
                // First clear all recipients
                $this->clearRecipients();
 
index f29ab1cdea6979f0284b565aa2d5fbbd2213b98e..d7e067dcbb9b01ad847b6c241feef78b4db97a01 100644 (file)
@@ -49,9 +49,9 @@ class BaseRawDataHandler extends BaseHandler {
        const PACKAGE_ERROR_CODE   = 'error_code';
 
        /**
-        * Stacker for decoded data
+        * Stacker for raw data
         */
-       const STACKER_NAME_DECODED_DATA = 'decoded_data';
+       const STACKER_NAME_RAW_DATA = 'raw_data';
 
        /**
         * Error code from socket
@@ -71,12 +71,6 @@ class BaseRawDataHandler extends BaseHandler {
                // Set error code to 'unknown'
                $this->setErrorCode(self::SOCKET_ERROR_UNKNOWN);
 
-               // Get an input stream instance
-               $streamInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_input_stream_class', array($this));
-
-               // Set it in this network-package handler
-               $this->setInputStreamInstance($streamInstance);
-
                // Init stacker instance for processed raw data
                $stackerInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_stacker_class');
 
@@ -93,50 +87,50 @@ class BaseRawDataHandler extends BaseHandler {
         * @return      void
         */
        protected function initStacker () {
-               $this->getStackerInstance()->initStacker(self::STACKER_NAME_DECODED_DATA);
+               $this->getStackerInstance()->initStacker(self::STACKER_NAME_RAW_DATA);
        }
 
        /**
-        * Adds given decoded data to the raw data stacker
+        * Adds given raw data to the raw data stacker
         *
-        * @param       $decodedData    Decoded data from the socket resource
+        * @param       $rawData        raw data from the socket resource
         * @return      void
         */
-       protected function addDecodedDataToStacker ($decodedData) {
+       protected function addRawDataToStacker ($rawData) {
                /*
                 * Add the deocoded data and error code to the stacker so other classes
                 * (e.g. NetworkPackage) can "pop" it from the stacker.
                 */
-               $this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECODED_DATA, array(
-                       self::PACKAGE_DECODED_DATA => $decodedData,
-                       self::PACKAGE_ERROR_CODE   => $this->getErrorCode()
+               $this->getStackerInstance()->pushNamed(self::STACKER_NAME_RAW_DATA, array(
+                       self::PACKAGE_RAW_DATA   => $rawData,
+                       self::PACKAGE_ERROR_CODE => $this->getErrorCode()
                ));
        }
 
        /**
-        * Checks whether decoded data is pending for further processing.
+        * Checks whether raw data is pending for further processing.
         *
-        * @return      $isPending      Whether decoded data is pending
+        * @return      $isPending      Whether raw data is pending
         */
-       public function isDecodedDataPending () {
+       public function isRawDataPending () {
                // Does the stacker have some entries (not empty)?
-               $isPending = (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_DECODED_DATA));
+               $isPending = (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_RAW_DATA));
 
                // Return it
                return $isPending;
        }
 
        /**
-        * "Getter" for next decoded data from the stacker
+        * "Getter" for next raw data from the stacker
         *
-        * @return      $decodedData    Decoded data from the stacker
+        * @return      $rawData        Raw data from the stacker
         */
-       public function getNextDecodedData () {
-               // "Pop" the decoded data from the stacker
-               $decodedData = $this->getStackerInstance()->popNamed(self::STACKER_NAME_DECODED_DATA);
+       public function getNextRawData () {
+               // "Pop" the raw data from the stacker
+               $rawData = $this->getStackerInstance()->popNamed(self::STACKER_NAME_RAW_DATA);
 
                // And return it
-               return $decodedData;
+               return $rawData;
        }
 
        /**
index 12e9a351d7d9d5cd5427fb783f6d8559ffd9e8c2..2f485eaae75d47adc0fbab3536b3d09651f27141 100644 (file)
@@ -65,9 +65,6 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable {
                // Reset error code to unhandled
                $this->setErrorCode(self::SOCKET_ERROR_UNHANDLED);
 
-               // Init variables
-               $decodedData = false;
-
                // Debug message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('TCP-HANDLER: Handling TCP package from resource=' . $socketArray[BasePool::SOCKET_ARRAY_RESOURCE] . ',type=' . $socketArray[BasePool::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror(socket_last_error($socketArray[BasePool::SOCKET_ARRAY_RESOURCE])));
 
@@ -102,25 +99,10 @@ class TcpRawDataHandler extends BaseRawDataHandler implements Networkable {
                } elseif (empty($rawData)) {
                        // The peer did send nothing to us which is now being ignored
                        return;
-               } else {
-                       /*
-                        * Low-level checks of the raw data went all fine, now decode the
-                        * raw data. This may still fail because of invalid encoded data.
-                        */
-                       try {
-                               $decodedData = $this->getInputStreamInstance()->streamData($rawData);
-                       } catch (AssertionException $e) {
-                               /*
-                                * This may happen with a multi-chunk stream (more data sent
-                                * than output/input buffers can handle) so the raw data needs
-                                * to be handled somewhere else.
-                                */
-                               $decodedData = $rawData;
-                       }
                }
 
-               // Add the (maybe above decoded) data to the stacker
-               $this->addDecodedDataToStacker($decodedData);
+               // Add the raw data to the stacker
+               $this->addRawDataToStacker($rawData);
        }
 }
 
index 6a5160de43672701177fc1f2d7a00e61c8e9d80f..2cc53b7fe070e5a2bef018508855e3778332ba92 100644 (file)
@@ -139,7 +139,7 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable {
                } // END - if
 
                // Does the handler have some decoded data pending?
-               if (!$handlerInstance->isDecodedDataPending()) {
+               if (!$handlerInstance->isRawDataPending()) {
                        // No data is pending so skip further code silently
                        return;
                } // END - if
@@ -151,7 +151,7 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable {
                 * if the decoded data origins from a TCP or UDP connection so we can
                 * just pass it over to the network package receiver
                 */
-               $receiverInstance->addDecodedDataToIncomingStack($handlerInstance);
+               $receiverInstance->addRawDataToIncomingStack($handlerInstance);
        }
 }
 
index 0defa3a36eda700f65540e9d0e7dab4a345eaca6..1a5a8d46e475ab34128bfab79f0f77e4a41d1a3b 100644 (file)
@@ -365,7 +365,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
        /**
         * "Getter" for hash from given content and sender's session id
         *
-        * @param       $decodedContent         Decoded package content
+        * @param       $decodedContent         Raw package content
         * @param       $sessionId                      Session id of the sender
         * @return      $hash                           Hash for given package content
         */
@@ -772,7 +772,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         *
         * @return      $isPending      Whether decoded raw data is pending
         */
-       private function isDecodedDataPending () {
+       private function isRawDataPending () {
                // Just return whether the stack is not empty
                $isPending = (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_DECODED_INCOMING));
 
@@ -791,7 +791,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                $poolInstance->accept($this->getVisitorInstance());
 
                // Check for new data arrival
-               $hasArrived = $this->isDecodedDataPending();
+               $hasArrived = $this->isRawDataPending();
 
                // Return the status
                return $hasArrived;
@@ -804,12 +804,12 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         *
         * @return      void
         */
-       public function handleIncomingDecodedData () {
+       public function handleIncomingRawData () {
                /*
                 * This method should only be called if decoded raw data is pending,
                 * so check it again.
                 */
-               if (!$this->isDecodedDataPending()) {
+               if (!$this->isRawDataPending()) {
                        // This is not fatal but should be avoided
                        // @TODO Add some logging here
                        return;
@@ -851,12 +851,12 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         * @param       $handlerInstance        An instance of a Networkable class
         * @return      void
         */
-       public function addDecodedDataToIncomingStack (Networkable $handlerInstance) {
+       public function addRawDataToIncomingStack (Networkable $handlerInstance) {
                /*
                 * Get the decoded data from the handler, this is an array with
                 * 'decoded_data' and 'error_code' as elements.
                 */
-               $decodedData = $handlerInstance->getNextDecodedData();
+               $decodedData = $handlerInstance->getNextRawData();
 
                // Very noisy debug message:
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, true));
@@ -870,7 +870,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         *
         * @return      $isHandled      Whether incoming decoded data is handled
         */
-       public function isIncomingDecodedDataHandled () {
+       public function isIncomingRawDataHandled () {
                // Determine if the stack is not empty
                $isHandled = (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_DECODED_HANDLED));
 
@@ -909,11 +909,11 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         *
         * @return      void
         */
-       public function assembleDecodedDataToPackage () {
+       public function assembleRawDataToPackage () {
                // Make sure the raw decoded package data is handled
-               assert($this->isIncomingDecodedDataHandled());
+               assert($this->isIncomingRawDataHandled());
 
-               // Get current package content (an array with two elements; see handleIncomingDecodedData() for details)
+               // Get current package content (an array with two elements; see handleIncomingRawData() for details)
                $packageContent = $this->getStackerInstance()->getNamed(self::STACKER_NAME_DECODED_HANDLED);
 
                // Start assembling the raw package data array by chunking it
@@ -1023,7 +1023,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         * @return      void
         * @throws      InvalidDataChecksumException    If the checksum doesn't match
         */
-       public function handleDecodedData (array $decodedData) {
+       public function handleRawData (array $decodedData) {
                /*
                 * "Decode" the package's content by a simple explode() call, for
                 * details of the array elements, see comments for constant
index 9b08be432870e55dfccce7e3111fd5d7371afcda..8f7971ea698929c07d6604929ad8b5523099f9ea 100644 (file)
@@ -90,16 +90,16 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable {
                         * XML) and then pushing it on the next stack "processed messages".
                         */
                        $this->getPackageInstance()->handleNewlyArrivedMessage();
-               } elseif ($this->getPackageInstance()->isIncomingDecodedDataHandled()) {
+               } elseif ($this->getPackageInstance()->isIncomingRawDataHandled()) {
                        /*
                         * Incoming decoded data has been handled (see below) so it needs to
                         * be assembled back to a "package array". Please see NetworkPackage
                         * for further details (what array elements are required et cetera).
                         */
-                       $this->getPackageInstance()->assembleDecodedDataToPackage();
+                       $this->getPackageInstance()->assembleRawDataToPackage();
                } elseif ($this->getPackageInstance()->isNewRawDataPending($this->getListenerPoolInstance())) {
                        // Raw, decoded data has been received
-                       $this->getPackageInstance()->handleIncomingDecodedData();
+                       $this->getPackageInstance()->handleIncomingRawData();
                } elseif ($this->getPackageInstance()->ifAssemblerHasPendingDataLeft()) {
                        // Handle any pending data from the package assembler
                        $this->getPackageInstance()->handleAssemblerPendingData();