From ecfe3c8077fa94964dfab3423e189db81b721a74 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sun, 3 Apr 2011 00:57:05 +0000 Subject: [PATCH] Added all node types, moved iterator class: - Added all types of (hub/cloud) nodes for easy coding - Moved key producer iterator class to sub directory - TODOs.txt updated --- .gitattributes | 2 + .../class_TestUnitKeyProducerIterator.php | 102 +---------------- .../hub/main/iterator/producer/keys/.htaccess | 1 + .../class_TestUnitKeyProducerIterator.php | 103 ++++++++++++++++++ .../hub/main/nodes/boot/class_HubBootNode.php | 6 +- .../hub/main/nodes/class_BaseHubNode.php | 8 ++ .../class_CruncherTestUnitProducer.php | 2 +- docs/TODOs.txt | 18 +-- 8 files changed, 129 insertions(+), 113 deletions(-) create mode 100644 application/hub/main/iterator/producer/keys/.htaccess create mode 100644 application/hub/main/iterator/producer/keys/class_TestUnitKeyProducerIterator.php diff --git a/.gitattributes b/.gitattributes index 0cc3d8ac5..4217c86de 100644 --- a/.gitattributes +++ b/.gitattributes @@ -318,6 +318,8 @@ application/hub/main/iterator/pool/tasks/.htaccess -text svneol=unset#text/plain application/hub/main/iterator/pool/tasks/class_TaskPoolIterator.php -text svneol=unset#text/plain application/hub/main/iterator/producer/.htaccess svneol=native#text/plain application/hub/main/iterator/producer/class_TestUnitKeyProducerIterator.php svneol=native#text/plain +application/hub/main/iterator/producer/keys/.htaccess svneol=native#text/plain +application/hub/main/iterator/producer/keys/class_TestUnitKeyProducerIterator.php svneol=native#text/plain application/hub/main/listener/.htaccess -text svneol=unset#text/plain application/hub/main/listener/class_ -text svneol=unset#text/plain application/hub/main/listener/class_BaseListener.php -text svneol=unset#text/plain diff --git a/application/hub/main/iterator/producer/class_TestUnitKeyProducerIterator.php b/application/hub/main/iterator/producer/class_TestUnitKeyProducerIterator.php index 189eb0ee8..f551ef47b 100644 --- a/application/hub/main/iterator/producer/class_TestUnitKeyProducerIterator.php +++ b/application/hub/main/iterator/producer/class_TestUnitKeyProducerIterator.php @@ -1,103 +1,3 @@ - * @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 . - */ -class TestUnitKeyProducerIterator extends BaseIterator implements Iterator { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - } - - /** - * Creates an instance of this class - * - * @return $iteratorInstance An instance of a Iterator class - */ - public final static function createTestUnitKeyProducerIterator () { - // Get new instance - $iteratorInstance = new TestUnitKeyProducerIterator(); - - // Return the prepared instance - return $iteratorInstance; - } - - /** - * Getter for current value from group or generic - * - * @return $current Current value in iteration - */ - public function current () { - // Default is null - $current = null; - - $this->partialStub('Please implement this method.'); - - // Return it - return $current; - } - - /** - * Getter for key from group or generic - * - * @return $key Current key in iteration - * @throws UnsupportedOperationException This method should not be called - */ - public function key () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Advances to the next entry - * - * @return void - */ - public function next () { - $this->partialStub('Please implement this method.'); - } - - /** - * Rewinds to the beginning of the iteration - * - * @return void - * @throws UnsupportedOperationException This method should not be called - */ - public function rewind () { - throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); - } - - /** - * Checks wether the current entry is valid (not at the end of the list) - * - * @return void - */ - public function valid () { - $this->partialStub('Please implement this method.'); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/iterator/producer/keys/.htaccess b/application/hub/main/iterator/producer/keys/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/iterator/producer/keys/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/iterator/producer/keys/class_TestUnitKeyProducerIterator.php b/application/hub/main/iterator/producer/keys/class_TestUnitKeyProducerIterator.php new file mode 100644 index 000000000..189eb0ee8 --- /dev/null +++ b/application/hub/main/iterator/producer/keys/class_TestUnitKeyProducerIterator.php @@ -0,0 +1,103 @@ + + * @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 . + */ +class TestUnitKeyProducerIterator extends BaseIterator implements Iterator { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + } + + /** + * Creates an instance of this class + * + * @return $iteratorInstance An instance of a Iterator class + */ + public final static function createTestUnitKeyProducerIterator () { + // Get new instance + $iteratorInstance = new TestUnitKeyProducerIterator(); + + // Return the prepared instance + return $iteratorInstance; + } + + /** + * Getter for current value from group or generic + * + * @return $current Current value in iteration + */ + public function current () { + // Default is null + $current = null; + + $this->partialStub('Please implement this method.'); + + // Return it + return $current; + } + + /** + * Getter for key from group or generic + * + * @return $key Current key in iteration + * @throws UnsupportedOperationException This method should not be called + */ + public function key () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Advances to the next entry + * + * @return void + */ + public function next () { + $this->partialStub('Please implement this method.'); + } + + /** + * Rewinds to the beginning of the iteration + * + * @return void + * @throws UnsupportedOperationException This method should not be called + */ + public function rewind () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Checks wether the current entry is valid (not at the end of the list) + * + * @return void + */ + public function valid () { + $this->partialStub('Please implement this method.'); + } +} + +// [EOF] +?> diff --git a/application/hub/main/nodes/boot/class_HubBootNode.php b/application/hub/main/nodes/boot/class_HubBootNode.php index ee6faf454..9b7de3925 100644 --- a/application/hub/main/nodes/boot/class_HubBootNode.php +++ b/application/hub/main/nodes/boot/class_HubBootNode.php @@ -71,13 +71,13 @@ class HubBootNode extends BaseHubNode implements NodeHelper, Registerable { // It is the same! $this->debugOutput('BOOTSTRAP: IP/port matches bootstrapping node ' . $this->getBootIpPort() . '.'); - // Now, does the mode match (should be 'boot'!) - if ($this->getRequestInstance()->getRequestElement('mode') == 'boot') { + // Now, does the mode match + if ($this->getRequestInstance()->getRequestElement('mode') == BaseHubNode::NODE_TYPE_BOOT) { // Output debug message $this->debugOutput('BOOTSTRAP: Our node is a valid bootstrapping node.'); } else { // Output warning - $this->debugOutput('BOOTSTRAP: WARNING: Mismatching mode ' . $this->getRequestInstance()->getRequestElement('mode') . '!=boot detected.'); + $this->debugOutput('BOOTSTRAP: WARNING: Mismatching mode ' . $this->getRequestInstance()->getRequestElement('mode') . '!=' . BaseHubNode::NODE_TYPE_BOOT . ' detected.'); } } else { // IP does match, but no port diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index f60f1fc79..0b95a0a35 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -22,6 +22,14 @@ * along with this program. If not, see . */ class BaseHubNode extends BaseHubSystem implements Updateable { + /** + * Node types + */ + const NODE_TYPE_BOOT = 'boot'; + const NODE_TYPE_MASTER = 'master'; + const NODE_TYPE_LIST = 'list'; + const NODE_TYPE_REGULAR = 'regular'; + // Exception constants const EXCEPTION_HUB_ALREADY_ANNOUNCED = 0xe00; diff --git a/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php b/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php index 172083521..673e9d037 100644 --- a/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php +++ b/application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php @@ -131,7 +131,7 @@ class CruncherTestUnitProducer extends BaseUnitProducer implements UnitProducer, $iteratorInstance->next(); } // END - while - die(__METHOD__.": Ended the key production.\n"); + die(__METHOD__ . ": Ended the key production.\n"); } } } diff --git a/docs/TODOs.txt b/docs/TODOs.txt index 189ba59a6..58dfcd9b6 100644 --- a/docs/TODOs.txt +++ b/docs/TODOs.txt @@ -51,9 +51,9 @@ ./application/hub/main/nodes/boot/class_HubBootNode.php:119: // @TODO Add some filters here ./application/hub/main/nodes/boot/class_HubBootNode.php:58: * @todo add some more special bootstrap things for this boot node ./application/hub/main/nodes/boot/class_HubBootNode.php:99: * @todo Unfinished method -./application/hub/main/nodes/class_BaseHubNode.php:444: * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem -./application/hub/main/nodes/class_BaseHubNode.php:484: * @todo Change the first if() block to check for a specific state -./application/hub/main/nodes/class_BaseHubNode.php:659: // @TODO Add some criteria, e.g. if the node is active or so +./application/hub/main/nodes/class_BaseHubNode.php:452: * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem +./application/hub/main/nodes/class_BaseHubNode.php:492: * @todo Change the first if() block to check for a specific state +./application/hub/main/nodes/class_BaseHubNode.php:667: // @TODO Add some criteria, e.g. if the node is active or so ./application/hub/main/nodes/list/class_HubListNode.php:58: * @todo Implement more bootstrap steps ./application/hub/main/nodes/list/class_HubListNode.php:68: * @todo Unfinished method ./application/hub/main/nodes/list/class_HubListNode.php:91: // @TODO Add some filters here @@ -70,6 +70,7 @@ ./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:127: // @TODO Do something with it ./application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php:78: * @todo ~30% done ./application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php:98: // @TODO Unfinished work here ./application/hub/main/resolver/state/network/class_NetworkStateResolver.php:68: * @todo ~30% done @@ -89,7 +90,7 @@ ./application/hub/main/template/objects/class_XmlObjectRegistryTemplateEngine.php:324: * @todo Handle $objectCount ./application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php:10: * @todo This template engine does not make use of setTemplateType() ./application/hub/main/template/producer/test_units/class_XmlCruncherTestUnitTemplateEngine.php:433: * @todo Handle $keyCount -./application/hub/main/tools/class_HubTools.php:128: // @TODO We may want to encapsulate this PHP call into an own class +./application/hub/main/tools/class_HubTools.php:129: // @TODO We may want to encapsulate this PHP call into an own class ./application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php:105: * @todo Does a query needs to perform some actions as an active task? ./application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php:116: * @todo Does a queue needs to perform some actions as an active task? ./application/hub/main/visitor/tasks/class_ShutdownTaskVisitor.php:100: * @todo Does a query needs to perform some actions as an active task? @@ -97,10 +98,10 @@ ./inc/classes/exceptions/main/class_MissingMethodException.php:13: * @todo Try to rewrite user/guest login classes and mark this exception as deprecated ./inc/classes/exceptions/main/class_NoConfigEntryException.php:10: * @todo Rename this class to NoFoundEntryException ./inc/classes/interfaces/class_FrameworkInterface.php:11: * @todo Find a better name for this interface -./inc/classes/main/class_BaseFrameworkSystem.php:1196: * @todo Write a logging mechanism for productive mode -./inc/classes/main/class_BaseFrameworkSystem.php:1210: // @TODO Finish this part! +./inc/classes/main/class_BaseFrameworkSystem.php:1197: * @todo Write a logging mechanism for productive mode +./inc/classes/main/class_BaseFrameworkSystem.php:1211: // @TODO Finish this part! ./inc/classes/main/class_BaseFrameworkSystem.php:169: // @todo Try to clean these constants up -./inc/classes/main/class_BaseFrameworkSystem.php:367: * @todo SearchableResult and UpdateableResult shall have a super interface to use here +./inc/classes/main/class_BaseFrameworkSystem.php:368: * @todo SearchableResult and UpdateableResult shall have a super interface to use here ./inc/classes/main/commands/web/class_WebLoginAreaCommand.php:64: * @todo Add some stuff here: Some personal data, app/game related data ./inc/classes/main/commands/web/class_WebProblemCommand.php:58: * @todo 0% done ./inc/classes/main/commands/web/class_WebStatusCommand.php:58: * @todo 0% done @@ -225,7 +226,8 @@ ./application/hub/main/filter/task/class_HubTaskHandlerInitializerFilter.php:2:// @DEPRECATED ./application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php:2:// @DEPRECATED ./application/hub/main/helper/messages/crypto/class_CryptoRandomMessageHelper.php:2:// @DEPRECATED -./application/hub/main/nodes/class_BaseHubNode.php:50: * @deprecated +./application/hub/main/iterator/producer/class_TestUnitKeyProducerIterator.php:2:// @DEPRECATED +./application/hub/main/nodes/class_BaseHubNode.php:58: * @deprecated ./application/hub/main/template/announcement/class_AnnouncementTemplateEngine.php:2:// @DEPRECATED ./application/hub/main/template/connect/class_SelfConnectTemplateEngine.php:2:// @DEPRECATED ./application/hub/main/template/objects/class_ObjectRegistryTemplateEngine.php:2:// @DEPRECATED -- 2.39.2