From: Roland Häder Date: Sat, 4 Aug 2012 23:29:11 +0000 (+0000) Subject: Renamed methods (MAY BREAK THINGS) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c48b576d646576bab73a02afd6d5f923acca36de;p=hub.git Renamed methods (MAY BREAK THINGS) --- diff --git a/application/hub/config.php b/application/hub/config.php index 1eb266bb8..9422ef935 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -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); diff --git a/application/hub/interfaces/decoder/class_Decodeable.php b/application/hub/interfaces/decoder/class_Decodeable.php index ebcb427fd..afb3d4a7e 100644 --- a/application/hub/interfaces/decoder/class_Decodeable.php +++ b/application/hub/interfaces/decoder/class_Decodeable.php @@ -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 (); diff --git a/application/hub/interfaces/discovery/class_DiscoverableRecipient.php b/application/hub/interfaces/discovery/class_DiscoverableRecipient.php index afa752fe4..765d3de3e 100644 --- a/application/hub/interfaces/discovery/class_DiscoverableRecipient.php +++ b/application/hub/interfaces/discovery/class_DiscoverableRecipient.php @@ -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 diff --git a/application/hub/interfaces/handler/network/class_Networkable.php b/application/hub/interfaces/handler/network/class_Networkable.php index 9788a8a4c..93df1400c 100644 --- a/application/hub/interfaces/handler/network/class_Networkable.php +++ b/application/hub/interfaces/handler/network/class_Networkable.php @@ -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] diff --git a/application/hub/interfaces/package/class_Receivable.php b/application/hub/interfaces/package/class_Receivable.php index 0a6dcb384..821c8178e 100644 --- a/application/hub/interfaces/package/class_Receivable.php +++ b/application/hub/interfaces/package/class_Receivable.php @@ -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] diff --git a/application/hub/main/decoder/package/class_PackageDecoder.php b/application/hub/main/decoder/package/class_PackageDecoder.php index 2e62c63c8..f3f9257e1 100644 --- a/application/hub/main/decoder/package/class_PackageDecoder.php +++ b/application/hub/main/decoder/package/class_PackageDecoder.php @@ -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); } } diff --git a/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php b/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php index 3b12418dd..3ebcbe30f 100644 --- a/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php +++ b/application/hub/main/discovery/package/class_PackageRecipientDiscovery.php @@ -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(); diff --git a/application/hub/main/handler/network/class_BaseRawDataHandler.php b/application/hub/main/handler/network/class_BaseRawDataHandler.php index f29ab1cde..d7e067dcb 100644 --- a/application/hub/main/handler/network/class_BaseRawDataHandler.php +++ b/application/hub/main/handler/network/class_BaseRawDataHandler.php @@ -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; } /** diff --git a/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php b/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php index 12e9a351d..2f485eaae 100644 --- a/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php +++ b/application/hub/main/handler/network/tcp/class_TcpRawDataHandler.php @@ -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); } } diff --git a/application/hub/main/listener/class_BaseListenerDecorator.php b/application/hub/main/listener/class_BaseListenerDecorator.php index 6a5160de4..2cc53b7fe 100644 --- a/application/hub/main/listener/class_BaseListenerDecorator.php +++ b/application/hub/main/listener/class_BaseListenerDecorator.php @@ -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); } } diff --git a/application/hub/main/package/class_NetworkPackage.php b/application/hub/main/package/class_NetworkPackage.php index 0defa3a36..1a5a8d46e 100644 --- a/application/hub/main/package/class_NetworkPackage.php +++ b/application/hub/main/package/class_NetworkPackage.php @@ -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 diff --git a/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php b/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php index 9b08be432..8f7971ea6 100644 --- a/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php +++ b/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php @@ -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();