]> git.mxchange.org Git - hub.git/commitdiff
Producer/Consumer Pattern introduced:
authorRoland Häder <roland@mxchange.org>
Wed, 16 Mar 2011 22:04:09 +0000 (22:04 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 16 Mar 2011 22:04:09 +0000 (22:04 +0000)
- Producer/Consumer interfaces added
- First producer for test units introduced
- TODOs.txt updated

18 files changed:
.gitattributes
application/hub/config.php
application/hub/interfaces/consumer/.htaccess [new file with mode: 0644]
application/hub/interfaces/consumer/class_Consumer.php [new file with mode: 0644]
application/hub/interfaces/producer/.htaccess [new file with mode: 0644]
application/hub/interfaces/producer/class_Producer.php [new file with mode: 0644]
application/hub/interfaces/producer/work_units/.htaccess [new file with mode: 0644]
application/hub/interfaces/producer/work_units/class_UnitProducer.php [new file with mode: 0644]
application/hub/main/producer/.htaccess [new file with mode: 0644]
application/hub/main/producer/class_ [new file with mode: 0644]
application/hub/main/producer/class_BaseProducer.php [new file with mode: 0644]
application/hub/main/producer/cruncher/.htaccess [new file with mode: 0644]
application/hub/main/producer/cruncher/work_units/.htaccess [new file with mode: 0644]
application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php [new file with mode: 0644]
application/hub/main/tasks/cruncher/class_CruncherTestUnitProducerTask.php
application/hub/main/tasks/cruncher/class_CruncherWorkUnitFetcherTask.php
docs/TODOs.txt
todo-builder.sh

index e6f5c57445a187b8a31435efdb74059ad3ae37f6..ca7c984f2951c3d592c9c78c302fd77438679cee 100644 (file)
@@ -30,6 +30,8 @@ application/hub/init.php -text svneol=unset#text/plain
 application/hub/interfaces/.htaccess -text svneol=unset#text/plain
 application/hub/interfaces/connectors/.htaccess -text svneol=unset#text/plain
 application/hub/interfaces/connectors/class_Connectable.php -text svneol=unset#text/plain
+application/hub/interfaces/consumer/.htaccess svneol=native#text/plain
+application/hub/interfaces/consumer/class_Consumer.php svneol=native#text/plain
 application/hub/interfaces/cruncher/.htaccess svneol=native#text/plain
 application/hub/interfaces/cruncher/class_CruncherHelper.php svneol=native#text/plain
 application/hub/interfaces/discovery/.htaccess -text svneol=unset#text/plain
@@ -64,6 +66,10 @@ application/hub/interfaces/pool/listener/.htaccess -text svneol=unset#text/plain
 application/hub/interfaces/pool/listener/class_PoolableListener.php -text svneol=unset#text/plain
 application/hub/interfaces/pool/peer/.htaccess -text svneol=unset#text/plain
 application/hub/interfaces/pool/peer/class_PoolablePeer.php -text svneol=unset#text/plain
+application/hub/interfaces/producer/.htaccess svneol=native#text/plain
+application/hub/interfaces/producer/class_Producer.php svneol=native#text/plain
+application/hub/interfaces/producer/work_units/.htaccess svneol=native#text/plain
+application/hub/interfaces/producer/work_units/class_UnitProducer.php svneol=native#text/plain
 application/hub/interfaces/protocol/.htaccess -text svneol=unset#text/plain
 application/hub/interfaces/protocol/class_ProtocolHandler.php svneol=native#text/plain
 application/hub/interfaces/query/.htaccess -text svneol=unset#text/plain
@@ -348,6 +354,12 @@ application/hub/main/pools/listener/.htaccess -text svneol=unset#text/plain
 application/hub/main/pools/listener/class_DefaultListenerPool.php -text svneol=unset#text/plain
 application/hub/main/pools/peer/.htaccess -text svneol=unset#text/plain
 application/hub/main/pools/peer/class_DefaultPeerPool.php -text svneol=unset#text/plain
+application/hub/main/producer/.htaccess svneol=native#text/plain
+application/hub/main/producer/class_ -text
+application/hub/main/producer/class_BaseProducer.php svneol=native#text/plain
+application/hub/main/producer/cruncher/.htaccess svneol=native#text/plain
+application/hub/main/producer/cruncher/work_units/.htaccess svneol=native#text/plain
+application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php svneol=native#text/plain
 application/hub/main/queries/.htaccess -text svneol=unset#text/plain
 application/hub/main/queries/class_ -text svneol=unset#text/plain
 application/hub/main/queries/class_BaseQuery.php -text svneol=unset#text/plain
index 8ae5ca096fb137a35bc7eeda00fb856b821d1647..f52c8ab0dfbac9d25cc44d74b17f01bda626af15 100644 (file)
@@ -534,5 +534,8 @@ $cfg->setConfigEntry('cruncher_test_unit_generator_class', 'CruncherTestUnitHelp
 // CFG: CRUNCHER-MAX-TEST-UNIT-AMOUNT
 $cfg->setConfigEntry('cruncher_max_text_unit_amount', 10);
 
+// CFG: CRUNCHER-TEST-UNIT-PRODUCER-CLASS
+$cfg->setConfigEntry('cruncher_test_unit_producer_class', 'CruncherTestUnitProducer');
+
 // [EOF]
 ?>
diff --git a/application/hub/interfaces/consumer/.htaccess b/application/hub/interfaces/consumer/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/consumer/class_Consumer.php b/application/hub/interfaces/consumer/class_Consumer.php
new file mode 100644 (file)
index 0000000..1a8fb50
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * An interface for the producer/consumer implementation
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface Consumer extends FrameworkInterface {
+}
+
+// [EOF]
+?>
diff --git a/application/hub/interfaces/producer/.htaccess b/application/hub/interfaces/producer/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/producer/class_Producer.php b/application/hub/interfaces/producer/class_Producer.php
new file mode 100644 (file)
index 0000000..8e274ab
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+/**
+ * An interface for the producer/consumer implementation
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface Producer extends FrameworkInterface {
+}
+
+// [EOF]
+?>
diff --git a/application/hub/interfaces/producer/work_units/.htaccess b/application/hub/interfaces/producer/work_units/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/producer/work_units/class_UnitProducer.php b/application/hub/interfaces/producer/work_units/class_UnitProducer.php
new file mode 100644 (file)
index 0000000..31f8bcc
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+/**
+ * An interface for the producer/consumer implementation, especially for work/
+ * test unit producers.
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface UnitProducer extends Producer {
+       /**
+        * Produces some work/test units and pushes them onto the queue
+        *
+        * @return      void
+        */
+       function produceUnits ();
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/producer/.htaccess b/application/hub/main/producer/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/producer/class_ b/application/hub/main/producer/class_
new file mode 100644 (file)
index 0000000..9f8f15d
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * A ??? producer class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Producer extends BaseFrameworkSystem implements Producer, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $producerInstance       An instance of a Producer class
+        */
+       public final static function create???Producer () {
+               // Get new instance
+               $producerInstance = new ???Producer();
+
+               // Return the prepared instance
+               return $producerInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/producer/class_BaseProducer.php b/application/hub/main/producer/class_BaseProducer.php
new file mode 100644 (file)
index 0000000..46fd68e
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * A general Producer class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseProducer extends BaseFrameworkSystem {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/producer/cruncher/.htaccess b/application/hub/main/producer/cruncher/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/producer/cruncher/work_units/.htaccess b/application/hub/main/producer/cruncher/work_units/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php b/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php
new file mode 100644 (file)
index 0000000..3b16468
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * A CruncherTestUnit producer class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class CruncherTestUnitProducer extends BaseFrameworkSystem implements UnitProducer, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $producerInstance       An instance of a Producer class
+        */
+       public final static function createCruncherTestUnitProducer () {
+               // Get new instance
+               $producerInstance = new CruncherTestUnitProducer();
+
+               // Return the prepared instance
+               return $producerInstance;
+       }
+
+       /**
+        * Produces some work/test units and pushes them onto the queue
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function produceUnits () {
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
index f6dabce6b3e8fef3f517e0960afbfbc2e8833012..acaa55798a71fed85aa2d451e95b779317b659bc 100644 (file)
@@ -64,7 +64,20 @@ class CruncherTestUnitProducerTask extends BaseTask implements Taskable, Visitab
         * @todo        0%
         */
        public function executeTask () {
-               $this->partialStub('Unimplemented task.');
+               // First we check if we already have an instance (which will happen at any later cyclus)
+               if (!Registry::getRegistry()->instanceExists('test_unit_producer')) {
+                       // No instance found, so we need to create a producer instance
+                       $producerInstance = ObjectFactory::createObjectByConfiguredName('cruncher_test_unit_producer_class');
+
+                       // ... and add it to the registry
+                       Registry::getRegistry()->addInstance('test_unit_producer', $producerInstance);
+               } else {
+                       // Get the producer instance from registry
+                       $producerInstance = Registry::getRegistry()->getInstance('test_unit_producer');
+               }
+
+               // We can now use that producer instance for generating some test units
+               $producerInstance->produceUnits();
        }
 }
 
index 6b1181bda67e194571f929baf2afd4c91e827ec9..5c75860694ea27dd910fe9382258a7e8bdbc7ea7 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 /**
- * A WorkUnitFetcher task for crunchers
+ * A WorkUnitFetcher task for crunchers which asks the cruncher to fetch work
+ * units or, if enabled in configuration, work on some test units.
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
index 9ae4064b3bae056ee523dbf357484ec8f9a5e06e..18ea404ef3002a37516b0026ec1cb21e78c55176 100644 (file)
@@ -14,7 +14,6 @@
 ./application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php:98:  * @todo        Implement this method
 ./application/hub/main/discovery/socket/class_PackageSocketDiscovery.php:102:                  // @TODO We may need some locking here
 ./application/hub/main/factories/socket/class_SocketFactory.php:10: * @todo            Find an interface for hub helper
-./application/hub/main/filter/activation/node/class_NodeActivationSelfAnnouncementFilter.php:54:        * @todo        0% done
 ./application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapBufferQueueInitializerFilter.php:54:    * @todo        0% done
 ./application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapGenericActivationFilter.php:54:         * @todo        Maybe we want to do somthing more here?
 ./application/hub/main/filter/cruncher/class_CruncherInitializationFilter.php:54:       * @todo        0% done
@@ -29,7 +28,7 @@
 ./application/hub/main/filter/shutdown/node/class_NodeShutdownFlushNodeListFilter.php:55:       * @todo        0% done
 ./application/hub/main/filter/shutdown/node/class_NodeShutdownTaskHandlerFilter.php:55:         * @todo        0% done
 ./application/hub/main/filter/task/cruncher/class_CruncherTaskHandlerInitializerFilter.php:55:  * @todo        5% done
-./application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php:55:  * @todo        0% done
+./application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php:55:  * @todo        Maybe some more tasks needs to be added?
 ./application/hub/main/handler/network/tcp/class_TcpNetworkPackageHandler.php:96:       * @todo        ~10% done
 ./application/hub/main/handler/network/udp/class_UdpNetworkPackageHandler.php:58:       * @todo        0%
 ./application/hub/main/handler/tasks/class_TaskHandler.php:140:                // @TODO Messurement can be added around this call
 ./application/hub/main/package/class_NetworkPackage.php:383:                   // @TODO Add some logging here
 ./application/hub/main/package/class_NetworkPackage.php:409:                   // @TODO Add some logging here
 ./application/hub/main/pools/peer/class_DefaultPeerPool.php:148:                       // @TODO Check for IP
+./application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php:52:      * @todo        0% done
 ./application/hub/main/resolver/state/network/class_NetworkStateResolver.php:68:        * @todo        ~30% done
 ./application/hub/main/resolver/state/network/class_NetworkStateResolver.php:80:                       // @TODO On some systems it is 134, on some 107?
-./application/hub/main/tasks/cruncher/class_CruncherWorkUnitFetcherTask.php:53:         * @todo        Maybe visit some sub-objects
+./application/hub/main/tasks/cruncher/class_CruncherTestUnitProducerTask.php:53:        * @todo        Maybe visit some sub-objects
+./application/hub/main/tasks/cruncher/class_CruncherTestUnitProducerTask.php:64:        * @todo        0%
+./application/hub/main/tasks/cruncher/class_CruncherWorkUnitFetcherTask.php:54:         * @todo        Maybe visit some sub-objects
 ./application/hub/main/tasks/hub/announcement/class_HubSelfAnnouncementTask.php:53:     * @todo        0%
 ./application/hub/main/tasks/hub/class_HubSelfConnectTask.php:53:       * @todo        0%
-./application/hub/main/tasks/hub/ping/class_HubPingTask.php:63:         * @todo        0%
+./application/hub/main/tasks/hub/ping/class_HubPingTask.php:73:         * @todo        0% done
 ./application/hub/main/tasks/hub/update/class_HubUpdateCheckTask.php:53:        * @todo        0%
 ./application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php:10: * @todo               This template engine does not make use of setTemplateType()
 ./application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.php:245:       * @todo        Find something useful with this!
index c1941f584768143926c054eb79a8b43971f576b6..7d75368bfdf423d80d9e4ff7581932182944d556 100755 (executable)
@@ -4,8 +4,8 @@
 # developers with SVN write-access
 
 if ! test -e "index.php"; then
-  echo "$0: Please execute this script from root directory."
-  exit 1
+       echo "$0: Please execute this script from root directory."
+       exit 1
 fi
 
 echo "$0: Generating TODOs.txt..."