]> git.mxchange.org Git - hub.git/commitdiff
Generator/helper class for generating test units introduced:
authorRoland Häder <roland@mxchange.org>
Mon, 14 Mar 2011 20:39:55 +0000 (20:39 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 14 Mar 2011 20:39:55 +0000 (20:39 +0000)
- There is currently a loop in the cruncher class which is not recommended but maybe fine here

12 files changed:
.gitattributes
application/hub/config.php
application/hub/interfaces/work_units/.htaccess [new file with mode: 0644]
application/hub/interfaces/work_units/class_UnitHelper.php [new file with mode: 0644]
application/hub/main/cruncher/class_BaseHubCruncher.php
application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php
application/hub/main/helper/work_units/.htaccess [new file with mode: 0644]
application/hub/main/helper/work_units/class_ [new file with mode: 0644]
application/hub/main/helper/work_units/class_BaseWorkUnitHelper.php [new file with mode: 0644]
application/hub/main/helper/work_units/cruncher/.htaccess [new file with mode: 0644]
application/hub/main/helper/work_units/cruncher/class_CruncherTestUnitHelper.php [new file with mode: 0644]
docs/TODOs.txt

index a612fca3ac82a3dba0c250faef07db306cb07f42..b0c18b7814ce1876a0180e86119b78d3464323f8 100644 (file)
@@ -107,6 +107,8 @@ application/hub/interfaces/visitor/queue/.htaccess svneol=native#text/plain
 application/hub/interfaces/visitor/queue/class_QueueVisitor.php svneol=native#text/plain
 application/hub/interfaces/visitor/tasks/.htaccess -text svneol=unset#text/plain
 application/hub/interfaces/visitor/tasks/class_TaskVisitor.php -text svneol=unset#text/plain
+application/hub/interfaces/work_units/.htaccess svneol=native#text/plain
+application/hub/interfaces/work_units/class_UnitHelper.php svneol=native#text/plain
 application/hub/loader.php -text svneol=unset#text/plain
 application/hub/main/.htaccess -text svneol=unset#text/plain
 application/hub/main/class_ -text svneol=unset#text/plain
@@ -264,6 +266,11 @@ application/hub/main/helper/hub/class_ -text svneol=unset#text/plain
 application/hub/main/helper/hub/class_BaseHubHelper.php -text svneol=unset#text/plain
 application/hub/main/helper/hub/connection/.htaccess -text svneol=unset#text/plain
 application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php svneol=native#text/plain
+application/hub/main/helper/work_units/.htaccess svneol=native#text/plain
+application/hub/main/helper/work_units/class_ -text
+application/hub/main/helper/work_units/class_BaseWorkUnitHelper.php svneol=native#text/plain
+application/hub/main/helper/work_units/cruncher/.htaccess svneol=native#text/plain
+application/hub/main/helper/work_units/cruncher/class_CruncherTestUnitHelper.php svneol=native#text/plain
 application/hub/main/iterator/.htaccess -text svneol=unset#text/plain
 application/hub/main/iterator/class_ -text svneol=unset#text/plain
 application/hub/main/iterator/class_BaseIterator.php -text svneol=unset#text/plain
index 8d69b82e4b3704ef0cf1adf57d3b3eead5f0588e..4de98c8733beb9a1c9d01f5c148663578e3df357 100644 (file)
@@ -510,11 +510,17 @@ $cfg->setConfigEntry('external_ip', '');
 // CFG: PACKAGE-FRAGMENTER-CLASS
 $cfg->setConfigEntry('package_fragmenter_class', 'PackageFragmenter');
 
-// CFG: CRUNCHER-ALLOW-TEST-WORK-UNITS
-$cfg->setConfigEntry('cruncher_allow_test_units', 'Y');
+// CFG: CRUNCHER-TEST-UNITS-ENABLED
+$cfg->setConfigEntry('cruncher_test_units_enabled', 'Y');
 
 // CFG: CRUNCHER-IN-BUFFER-MIN-THRESHOLD
 $cfg->setConfigEntry('cruncher_in_buffer_min_threshold', 3);
 
+// CFG: CRUNCHER-TEST-UNIT-GENERATOR-CLASS
+$cfg->setConfigEntry('cruncher_test_unit_generator_class', 'CruncherTestUnitHelper');
+
+// CFG: CRUNCHER-MAX-TEST-UNIT-AMOUNT
+$cfg->setConfigEntry('cruncher_max_text_unit_amount', 10);
+
 // [EOF]
 ?>
diff --git a/application/hub/interfaces/work_units/.htaccess b/application/hub/interfaces/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/work_units/class_UnitHelper.php b/application/hub/interfaces/work_units/class_UnitHelper.php
new file mode 100644 (file)
index 0000000..cada8eb
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/**
+ * An interface for work/test/foo unit helper
+ *
+ * @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 UnitHelper extends FrameworkInterface {
+       /**
+        * Generates a work/test/foo unit instance
+        *
+        * @return      $unitInstance   A work unit instance
+        */
+       function generateUnit ();
+}
+
+// [EOF]
+?>
index 8a353d01029a323675d0a53e2874b335de395c40..5e09d9e385d4ceccd9d1c674651a778b4f827288 100644 (file)
@@ -137,7 +137,7 @@ class BaseHubCruncher extends BaseHubSystem implements Updateable {
                        $this->fillInBufferQueueWithWorkUnits();
 
                        // Is the buffer still not filled and are test-packages allowed?
-                       if ((!$this->isInBufferQueueFilled()) && ($this->getConfigInstance()->getConfigEntry('cruncher_allow_test_units') == 'Y')) {
+                       if ((!$this->isInBufferQueueFilled()) && ($this->getConfigInstance()->getConfigEntry('cruncher_test_units_enabled') == 'Y')) {
                                // Then fill the in-buffer with (one) test-unit(s)
                                $this->fillInBufferQueueWithTestUnits();
                        } // END - if
index dd0c874f6987871ca5754610f55121d030d80643..35e5dda0a0928185d937a831be30472b1e1ed8f1 100644 (file)
@@ -60,7 +60,23 @@ class HubMcryptCruncher extends BaseHubCruncher implements CruncherHelper, Regis
         * @return      void
         */
        protected function fillInBufferQueueWithTestUnits () {
-               $this->partialStub('Please implement this method.');
+               // Are test units enabled?
+               if ($this->getConfigInstance()->getConfigEntry('cruncher_test_units_enabled') == 'N') {
+                       // They are disabled, so skip any further steps
+                       return;
+               } // END - if
+
+               // Get a test-unit generator instance
+               $generatorInstance = ObjectFactory::createObjectByConfiguredName('cruncher_test_unit_generator_class');
+
+               // We don't need an iterator here because we just need to generate some test units
+               for ($idx = 0; $idx < $this->getConfigInstance()->getConfigEntry('cruncher_max_text_unit_amount'); $idx++) {
+                       // Get a test unit from it
+                       $unitInstance = $generatorInstance->generateUnit();
+
+                       // ... and finally queue it to the in-buffer queue
+                       $this->queueUnitInstanceToInBuffer($unitInstance);
+               } // END - for
        }
 
        /**
diff --git a/application/hub/main/helper/work_units/.htaccess b/application/hub/main/helper/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/helper/work_units/class_ b/application/hub/main/helper/work_units/class_
new file mode 100644 (file)
index 0000000..1c6100e
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * A ??? work unit helper
+ *
+ * @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 ???WorkUnitHelper extends BaseWorkUnitHelper implements UnitHelper {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $unitInstance   An instance of a UnitHelper class
+        */
+       public final static function create???WorkUnitHelper () {
+               // Get new instance
+               $unitInstance = new ???WorkUnitHelper();
+
+               // Return the prepared instance
+               return $unitInstance;
+       }
+
+       /**
+        * Generates a work/test/foo unit instance
+        *
+        * @return      $unitInstance   A work unit instance
+        * @todo        0% done
+        */
+       public function generateUnit () {
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/helper/work_units/class_BaseWorkUnitHelper.php b/application/hub/main/helper/work_units/class_BaseWorkUnitHelper.php
new file mode 100644 (file)
index 0000000..22811cb
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * A general WorkUnit 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 BaseWorkUnitHelper 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/helper/work_units/cruncher/.htaccess b/application/hub/main/helper/work_units/cruncher/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/helper/work_units/cruncher/class_CruncherTestUnitHelper.php b/application/hub/main/helper/work_units/cruncher/class_CruncherTestUnitHelper.php
new file mode 100644 (file)
index 0000000..1096f08
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * A ??? work unit helper
+ *
+ * @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 CruncherTestUnitHelper extends BaseWorkUnitHelper implements UnitHelper {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $unitInstance   An instance of a UnitHelper class
+        */
+       public final static function createCruncherTestUnitHelper () {
+               // Get new instance
+               $unitInstance = new CruncherTestUnitHelper();
+
+               // Return the prepared instance
+               return $unitInstance;
+       }
+
+       /**
+        * Generates a work/test/foo unit instance
+        *
+        * @return      $unitInstance   A work unit instance
+        * @todo        0% done
+        */
+       public function generateUnit () {
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
index 3b0fc8c743934150bf9ba3d6982951d51b2007d5..f1ebd40ee2b0d0eb3ec0dfa51d6774f18b400e87 100644 (file)
@@ -9,9 +9,9 @@
 ./application/hub/main/connectors/query/local/class_LocalQueryConnector.php:10: * @todo                Find an interface for: handleAllQueries()
 ./application/hub/main/connectors/query/local/class_LocalQueryConnector.php:78:         * @TODO        0% done: Unfinished work here
 ./application/hub/main/connectors/queues/local/class_LocalQueueConnector.php:58:        * @TODO        0% done: Unfinished work here
-./application/hub/main/cruncher/class_BaseHubCruncher.php:131:  * @todo        Try to make this method more generic so we can move it in BaseFrameworkSystem
-./application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php:112:         * @todo        0% done
-./application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php:61:  * @todo        Implement this method
+./application/hub/main/cruncher/class_BaseHubCruncher.php:154:  * @todo        Try to make this method more generic so we can move it in BaseFrameworkSystem
+./application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php:128:         * @todo        0% done
+./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
@@ -39,6 +39,7 @@
 ./application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php:10: * @todo               Find an interface for hub helper
 ./application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php:65:        * @todo        Rewrite the ->renderXmlContent() call to no arguments
 ./application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php:10: * @todo                Find an interface for hub helper
+./application/hub/main/helper/work_units/cruncher/class_CruncherTestUnitHelper.php:52:  * @todo        0% done
 ./application/hub/main/iterator/network/class_NetworkListenIterator.php:10: * @todo            This current implementation is not recommended, use a
 ./application/hub/main/iterator/network/class_NetworkListenIterator.php:11: * @todo            latency-based iteration or similar approaches
 ./application/hub/main/iterator/pool/handler/class_HandlerPoolIterator.php:10: * @todo         This current implementation is not recommended, use a