From 908351536bc4b941f71da717cf11ad22a2c23f65 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 17 Jul 2013 22:25:56 +0000 Subject: [PATCH] Rewrote to use constants and newly introduced method initStackers() --- .../main/cruncher/class_BaseHubCruncher.php | 16 ++++++++++++-- .../handler/chunks/class_ChunkHandler.php | 8 ++++--- .../hub/main/producer/class_BaseProducer.php | 22 ++++++++++++++----- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/application/hub/main/cruncher/class_BaseHubCruncher.php b/application/hub/main/cruncher/class_BaseHubCruncher.php index d55ba6bef..4f55a45a5 100644 --- a/application/hub/main/cruncher/class_BaseHubCruncher.php +++ b/application/hub/main/cruncher/class_BaseHubCruncher.php @@ -37,6 +37,16 @@ abstract class BaseHubCruncher extends BaseHubSystem implements Updateable { */ private $bufferInstance = NULL; + /** + * Stacker name for incoming queue + */ + const STACKER_NAME_IN_QUEUE = 'in_queue'; + + /** + * Stacker name for outcoming queue + */ + const STACKER_NAME_OUT_QUEUE = 'out_queue'; + /** * Protected constructor * @@ -148,8 +158,10 @@ abstract class BaseHubCruncher extends BaseHubSystem implements Updateable { $this->bufferInstance = ObjectFactory::createObjectByConfiguredName('cruncher_buffer_stacker_class'); // Initialize common stackers, like in/out - $this->bufferInstance->initStacker('in_queue'); - $this->bufferInstance->initStacker('out_queue'); + $this->bufferInstance->initStackers(array( + self::STACKER_NAME_IN_QUEUE, + self::STACKER_NAME_OUT_QUEUE + )); // Output debug message self::createDebugInstance(__CLASS__)->debugOutput('CRUNCHER: All buffers are now initialized.'); diff --git a/application/hub/main/handler/chunks/class_ChunkHandler.php b/application/hub/main/handler/chunks/class_ChunkHandler.php index 03f514957..5a188e525 100644 --- a/application/hub/main/handler/chunks/class_ChunkHandler.php +++ b/application/hub/main/handler/chunks/class_ChunkHandler.php @@ -91,9 +91,11 @@ class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable $stackerInstance = ObjectFactory::createObjectByConfiguredName('chunk_handler_stacker_class'); // Init all stacker - $stackerInstance->initStacker(self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP); - $stackerInstance->initStacker(self::STACKER_NAME_CHUNKS_WITHOUT_FINAL); - $stackerInstance->initStacker(self::STACKER_NAME_ASSEMBLED_RAW_DATA); + $stackerInstance->initStackers(array( + self::STACKER_NAME_CHUNKS_WITH_FINAL_EOP, + self::STACKER_NAME_CHUNKS_WITHOUT_FINAL, + self::STACKER_NAME_ASSEMBLED_RAW_DATA + )); // Set the stacker in this handler $handlerInstance->setStackerInstance($stackerInstance); diff --git a/application/hub/main/producer/class_BaseProducer.php b/application/hub/main/producer/class_BaseProducer.php index 898c9edf8..0dca07cad 100644 --- a/application/hub/main/producer/class_BaseProducer.php +++ b/application/hub/main/producer/class_BaseProducer.php @@ -32,6 +32,16 @@ abstract class BaseProducer extends BaseFrameworkSystem { */ private $incomingQueueInstance = NULL; + /** + * Stacker name for incoming work + */ + const STACKER_NAME_IN_QUEUE = 'incoming_queue'; + + /** + * Stacker name for outgoing work + */ + const STACKER_NAME_OUT_QUEUE = 'outgoing_queue'; + /** * Protected constructor * @@ -123,7 +133,7 @@ abstract class BaseProducer extends BaseFrameworkSystem { * @return void */ protected function initOutgoingQueue () { - $this->getOutgoingQueueInstance()->initStacker('outgoing_queue', true); + $this->getOutgoingQueueInstance()->initStacker(self::STACKER_NAME_OUT_QUEUE, true); } /** @@ -133,7 +143,7 @@ abstract class BaseProducer extends BaseFrameworkSystem { * @return void */ protected function addValueToOutgoingQueue ($value) { - $this->getOutgoingQueueInstance()->pushNamed('outgoing_queue', $value); + $this->getOutgoingQueueInstance()->pushNamed(self::STACKER_NAME_OUT_QUEUE, $value); } /** @@ -143,7 +153,7 @@ abstract class BaseProducer extends BaseFrameworkSystem { * @return $isReached Whether the limit is reached */ protected function isOutgoingQueueLimitReached($configEntry) { - return ($this->getConfigInstance()->getConfigEntry($configEntry) <= $this->getOutgoingQueueInstance()->getStackCount('outgoing_queue')); + return ($this->getConfigInstance()->getConfigEntry($configEntry) <= $this->getOutgoingQueueInstance()->getStackCount(self::STACKER_NAME_OUT_QUEUE)); } /** @@ -152,7 +162,7 @@ abstract class BaseProducer extends BaseFrameworkSystem { * @return void */ protected function initIncomingQueue () { - $this->getIncomingQueueInstance()->initStacker('incoming_queue', true); + $this->getIncomingQueueInstance()->initStacker(self::STACKER_NAME_IN_QUEUE, true); } /** @@ -162,7 +172,7 @@ abstract class BaseProducer extends BaseFrameworkSystem { * @return void */ protected function addValueToIncomingQueue ($value) { - $this->getIncomingQueueInstance()->pushNamed('incoming_queue', $value); + $this->getIncomingQueueInstance()->pushNamed(self::STACKER_NAME_IN_QUEUE, $value); } /** @@ -172,7 +182,7 @@ abstract class BaseProducer extends BaseFrameworkSystem { * @return $isReached Whether the limit is reached */ protected function isIncomingQueueLimitReached($configEntry) { - return ($this->getConfigInstance()->getConfigEntry($configEntry) <= $this->getIncomingQueueInstance()->getStackCount('incoming_queue')); + return ($this->getConfigInstance()->getConfigEntry($configEntry) <= $this->getIncomingQueueInstance()->getStackCount(self::STACKER_NAME_IN_QUEUE)); } } -- 2.39.5