From: Roland Häder Date: Wed, 15 Feb 2012 22:57:36 +0000 (+0000) Subject: Added a stacker for chunk handler which handles final chunks, implemented adding... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2723e02a704353f760de5094d6d42f37d3dc9b05;p=hub.git Added a stacker for chunk handler which handles final chunks, implemented adding all chunks to that new stacker --- diff --git a/application/hub/config.php b/application/hub/config.php index 09d31a793..4c60d5ea9 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -246,6 +246,9 @@ $cfg->setConfigEntry('network_package_stacker_class', 'FiFoStacker'); // CFG: NODE-RAW-DATA-STACKER-CLASS $cfg->setConfigEntry('node_raw_data_stacker_class', 'FiFoStacker'); +// CFG: CHUNK-HANDLER-STACKER-CLASS +$cfg->setConfigEntry('chunk_handler_stacker_class', 'FiFoStacker'); + // CFG: PRODUCER-OUTGOING-QUEUE $cfg->setConfigEntry('producer_outgoing_queue', 'FiFoStacker'); @@ -294,6 +297,9 @@ $cfg->setConfigEntry('stacker_package_decoded_data_max_size', 200); // CFG: STACKER-PACKAGE-HANDLED-DECODED-MAX-SIZE $cfg->setConfigEntry('stacker_package_handled_decoded_max_size', 200); +// CFG: STACKER-FINAL-CHUNKS-MAX-SIZE +$cfg->setConfigEntry('stacker_final_chunks_max_size', 100); + // CFG: NEWS-MAIN-LIMIT $cfg->setConfigEntry('news_main_limit', 5); diff --git a/application/hub/main/handler/chunks/class_ChunkHandler.php b/application/hub/main/handler/chunks/class_ChunkHandler.php index 100fab1a4..456f1ea08 100644 --- a/application/hub/main/handler/chunks/class_ChunkHandler.php +++ b/application/hub/main/handler/chunks/class_ChunkHandler.php @@ -22,6 +22,11 @@ * along with this program. If not, see . */ class ChunkHandler extends BaseHandler implements Registerable { + /** + * Stacker for chunks with final EOP + */ + const STACKER_NAME_CHUNKS_WITH_FINAL_EOP = 'final_chunks'; + /** * Protected constructor * @@ -33,6 +38,15 @@ class ChunkHandler extends BaseHandler implements Registerable { // Set handler name $this->setHandlerName('chunk'); + + // Get a FIFO stacker + $stackerInstance = ObjectFactory::createObjectByConfiguredName('chunk_handler_stacker_class'); + + // Init all stacker + $stackerInstance->initStacker(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP); + + // Set the stacker in this handler + $this->setStackerInstance($stackerInstance); } /** @@ -62,8 +76,11 @@ class ChunkHandler extends BaseHandler implements Registerable { throw new FinalChunkVerificationException(array($this, $chunks), BaseListener::EXCEPTION_FINAL_CHUNK_VERIFICATION); } // END - if - // Not yet finished - $this->partialStub('Not yet implemented.'); + // Add all chunks to the FIFO stacker + foreach ($chunk as $chunk) { + // Add the chunk + $this->getStackerInstance()->pushNamed(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP, $chunk); + } // END - foreach } } diff --git a/application/hub/main/pools/peer/class_DefaultPeerPool.php b/application/hub/main/pools/peer/class_DefaultPeerPool.php index b5fd4a945..3e469aecc 100644 --- a/application/hub/main/pools/peer/class_DefaultPeerPool.php +++ b/application/hub/main/pools/peer/class_DefaultPeerPool.php @@ -153,7 +153,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { foreach ($this->getAllSockets() as $socket) { // Is this a server socket? if ($socket === $this->getListenerInstance()->getSocketResource()) { - // Skip this + // Skip 'server' sockets (local socket) continue; } // END - if